mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
Remove 'Native_lock' type from 'native_types.h'
This commit is contained in:
parent
b1f63e3356
commit
bbca9912e2
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* \brief Lock implementation
|
||||
* \author Norman Feske
|
||||
* \date 2007-10-15
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2007-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/cancelable_lock.h>
|
||||
#include <base/printf.h>
|
||||
#include <cpu/atomic.h>
|
||||
|
||||
/* Codezero includes */
|
||||
#include <codezero/syscalls.h>
|
||||
|
||||
using namespace Genode;
|
||||
|
||||
|
||||
Cancelable_lock::Cancelable_lock(Cancelable_lock::State initial)
|
||||
:
|
||||
_native_lock(UNLOCKED)
|
||||
{
|
||||
if (initial == LOCKED)
|
||||
lock();
|
||||
}
|
||||
|
||||
|
||||
void Cancelable_lock::lock()
|
||||
{
|
||||
while (!cmpxchg(&_native_lock, UNLOCKED, LOCKED))
|
||||
Codezero::l4_thread_switch(-1);
|
||||
}
|
||||
|
||||
|
||||
void Cancelable_lock::unlock()
|
||||
{
|
||||
_native_lock = UNLOCKED;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Printf implementation to make Codezero's syscall bindings happy.
|
||||
*
|
||||
* We need a better place for this function - actually, the best would be not
|
||||
* to need this function at all. As of now, 'printf' is referenced by
|
||||
* Codezero's libl4, in particular by the mutex implementation.
|
||||
*/
|
||||
extern "C" void printf(const char *format, ...) __attribute__((weak));
|
||||
extern "C" void printf(const char *format, ...)
|
||||
{
|
||||
va_list list;
|
||||
va_start(list, format);
|
||||
|
||||
vprintf(format, list);
|
||||
|
||||
va_end(list);
|
||||
}
|
@ -24,7 +24,7 @@ namespace Genode {
|
||||
{
|
||||
private:
|
||||
|
||||
Native_lock _native_lock;
|
||||
int volatile _lock;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -23,8 +23,6 @@ namespace Fiasco {
|
||||
|
||||
namespace Genode {
|
||||
|
||||
typedef volatile int Native_lock;
|
||||
|
||||
class Platform_thread;
|
||||
|
||||
typedef Fiasco::l4_threadid_t Native_thread_id;
|
||||
|
@ -25,7 +25,7 @@ using namespace Genode;
|
||||
|
||||
|
||||
Cancelable_lock::Cancelable_lock(Cancelable_lock::State initial)
|
||||
: _native_lock(UNLOCKED)
|
||||
: _lock(UNLOCKED)
|
||||
{
|
||||
if (initial == LOCKED)
|
||||
lock();
|
||||
@ -38,7 +38,7 @@ void Cancelable_lock::lock()
|
||||
* XXX: How to notice cancel-blocking signals issued when being outside the
|
||||
* 'l4_ipc_sleep' system call?
|
||||
*/
|
||||
while (!Genode::cmpxchg(&_native_lock, UNLOCKED, LOCKED))
|
||||
while (!Genode::cmpxchg(&_lock, UNLOCKED, LOCKED))
|
||||
if (Fiasco::l4_ipc_sleep(Fiasco::l4_ipc_timeout(0, 0, 500, 0)) != L4_IPC_RETIMEOUT)
|
||||
throw Genode::Blocking_canceled();
|
||||
}
|
||||
@ -46,5 +46,5 @@ void Cancelable_lock::lock()
|
||||
|
||||
void Cancelable_lock::unlock()
|
||||
{
|
||||
_native_lock = UNLOCKED;
|
||||
_lock = UNLOCKED;
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ namespace Fiasco {
|
||||
|
||||
namespace Genode {
|
||||
|
||||
typedef volatile int Native_lock;
|
||||
typedef Fiasco::l4_cap_idx_t Native_thread_id;
|
||||
typedef Fiasco::l4_cap_idx_t Native_thread;
|
||||
typedef Fiasco::l4_cap_idx_t Native_task;
|
||||
|
@ -26,7 +26,6 @@ namespace Genode {
|
||||
static void copy(void* dst, Native_capability_tpl<Cap_dst_policy>* src);
|
||||
};
|
||||
|
||||
typedef volatile int Native_lock;
|
||||
typedef int Native_thread;
|
||||
typedef Native_thread Native_thread_id;
|
||||
typedef struct { } Native_utcb;
|
||||
|
@ -24,7 +24,6 @@ namespace Genode
|
||||
class Platform_thread;
|
||||
class Tlb;
|
||||
|
||||
typedef int volatile Native_lock;
|
||||
typedef Platform_thread * Native_thread;
|
||||
typedef unsigned Native_thread_id;
|
||||
typedef int Native_connection_state;
|
||||
|
@ -28,21 +28,6 @@
|
||||
|
||||
namespace Genode {
|
||||
|
||||
/**
|
||||
* Native lock type
|
||||
*
|
||||
* We are using a sleeping spinlock as lock implementation on Linux. This
|
||||
* is a temporary solution until we have implemented futex-based locking.
|
||||
* In a previous version, we have relied on POSIX semaphores as provided by
|
||||
* the glibc. However, relying on the glibc badly interferes with a custom
|
||||
* libc implementation. The glibc semaphore implementation expects to find
|
||||
* a valid pthread structure via the TLS pointer. We do not have such a
|
||||
* structure because we create threads via the 'clone' system call rather
|
||||
* than 'pthread_create'. Hence we have to keep the base framework clean
|
||||
* from glibc usage altogether.
|
||||
*/
|
||||
typedef volatile int Native_lock;
|
||||
|
||||
/**
|
||||
* Thread ID used in lock implementation
|
||||
*
|
||||
|
@ -23,8 +23,6 @@ namespace Pistachio {
|
||||
|
||||
namespace Genode {
|
||||
|
||||
typedef volatile int Native_lock;
|
||||
|
||||
class Platform_thread;
|
||||
|
||||
typedef Pistachio::L4_ThreadId_t Native_thread_id;
|
||||
|
Loading…
x
Reference in New Issue
Block a user