Follow-up for spin-lock unification, ref #123

This commit is contained in:
Norman Feske
2012-03-01 09:31:00 +01:00
parent 319813a59b
commit e4cb3ed929
11 changed files with 126 additions and 35 deletions

40
base-codezero/src/base/env/utcb.cc vendored Normal file
View File

@ -0,0 +1,40 @@
/*
* \brief Helper functions UTCB access on Codezero
* \author Norman Feske
* \date 2012-03-01
*/
/*
* Copyright (C) 2012 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/thread.h>
/**
* Resolve 'Thread_base::myself' when not linking the thread library
*
* This weak symbol is primarily used by test cases. Most other Genode programs
* use the thread library. If the thread library is not used, 'myself' can only
* be called by the main thread, for which 'myself' is defined as zero.
*/
Genode::Thread_base * __attribute__((weak)) Genode::Thread_base::myself() { return 0; }
Genode::Native_utcb *Genode::Thread_base::utcb()
{
/*
* If 'utcb' is called on the object returned by 'myself',
* the 'this' pointer may be NULL (if the calling thread is
* the main thread). Therefore we handle this special case
* here.
*/
if (this == 0) return 0;
return &_context->utcb;
}

View File

@ -22,30 +22,6 @@
#include <codezero/syscalls.h>
/**
* Resolve 'Thread_base::myself' when not linking the thread library
*
* This weak symbol is primarily used by test cases. Most other Genode programs
* use the thread library. If the thread library is not used, 'myself' can only
* be called by the main thread, for which 'myself' is defined as zero.
*/
Genode::Thread_base * __attribute__((weak)) Genode::Thread_base::myself() { return 0; }
Genode::Native_utcb *Genode::Thread_base::utcb()
{
/*
* If 'utcb' is called on the object returned by 'myself',
* the 'this' pointer may be NULL (if the calling thread is
* the main thread). Therefore we handle this special case
* here.
*/
if (this == 0) return 0;
return &_context->utcb;
}
static Codezero::l4_mutex main_running_lock = { -1 };
@ -61,7 +37,7 @@ static inline bool thread_id_valid(Genode::Native_thread_id tid)
}
static bool thread_check_stopped_and_restart(Genode::Native_thread_id tid)
static inline bool thread_check_stopped_and_restart(Genode::Native_thread_id tid)
{
if (!thread_id_valid(tid))
return false;