genode/repos/base-nova/src/base/lock/lock_helper.h
Christian Helmuth 976d669253 base-nova: remove special Thread_base::myself()
The weak implementation was added for quite special purposes years ago
and is no longer needed. On the other hand, the weak attribute does not
help if the implementation ends up in a shared library, which first
resolves symbols locally before asking ldso (that includes the acutal
thread library) *shiver*
2014-09-04 14:45:39 +02:00

60 lines
1.3 KiB
C++

/*
* \brief Helper functions for the Lock implementation
* \author Norman Feske
* \author Alexander Boettcher
* \date 2009-10-02
*
* For documentation about the interface, please revisit the 'base-pistachio'
* implementation.
*/
/*
* Copyright (C) 2009-2013 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
/* Genode includes */
#include <base/native_types.h>
#include <base/thread.h>
#include <base/stdint.h>
/* NOVA includes */
#include <nova/syscalls.h>
#include <nova/util.h>
extern int main_thread_running_semaphore();
static inline bool thread_check_stopped_and_restart(Genode::Thread_base *thread_base)
{
Genode::addr_t sem = thread_base ?
thread_base->tid().exc_pt_sel + Nova::SM_SEL_EC :
main_thread_running_semaphore();
Nova::sm_ctrl(sem, Nova::SEMAPHORE_UP);
return true;
}
static inline void thread_switch_to(Genode::Thread_base *thread_base) { }
static inline void thread_stop_myself()
{
using namespace Genode;
using namespace Nova;
addr_t sem;
Thread_base *myself = Thread_base::myself();
if (myself)
sem = myself->tid().exc_pt_sel + SM_SEL_EC;
else
sem = main_thread_running_semaphore();
if (sm_ctrl(sem, SEMAPHORE_DOWNZERO))
nova_die();
}