From bbca9912e2f373abcf96f828fe33adfa2d6abf8d Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Wed, 13 Feb 2013 22:13:47 +0100 Subject: [PATCH] Remove 'Native_lock' type from 'native_types.h' --- base-codezero/src/base/lock/lock.cc | 63 ---------------------- base-fiasco/include/base/cancelable_lock.h | 2 +- base-fiasco/include/base/native_types.h | 2 - base-fiasco/src/base/lock/lock.cc | 6 +-- base-foc/include/base/native_types.h | 1 - base-host/include/base/native_types.h | 1 - base-hw/include/base/native_types.h | 1 - base-linux/include/base/native_types.h | 15 ------ base-pistachio/include/base/native_types.h | 2 - 9 files changed, 4 insertions(+), 89 deletions(-) delete mode 100644 base-codezero/src/base/lock/lock.cc diff --git a/base-codezero/src/base/lock/lock.cc b/base-codezero/src/base/lock/lock.cc deleted file mode 100644 index dbe166f4d..000000000 --- a/base-codezero/src/base/lock/lock.cc +++ /dev/null @@ -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 -#include -#include - -/* Codezero includes */ -#include - -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); -} diff --git a/base-fiasco/include/base/cancelable_lock.h b/base-fiasco/include/base/cancelable_lock.h index 75871ff99..d2bfcf74f 100644 --- a/base-fiasco/include/base/cancelable_lock.h +++ b/base-fiasco/include/base/cancelable_lock.h @@ -24,7 +24,7 @@ namespace Genode { { private: - Native_lock _native_lock; + int volatile _lock; public: diff --git a/base-fiasco/include/base/native_types.h b/base-fiasco/include/base/native_types.h index 20f5609cf..7efc64626 100644 --- a/base-fiasco/include/base/native_types.h +++ b/base-fiasco/include/base/native_types.h @@ -23,8 +23,6 @@ namespace Fiasco { namespace Genode { - typedef volatile int Native_lock; - class Platform_thread; typedef Fiasco::l4_threadid_t Native_thread_id; diff --git a/base-fiasco/src/base/lock/lock.cc b/base-fiasco/src/base/lock/lock.cc index 103e0d914..9f3952c3c 100644 --- a/base-fiasco/src/base/lock/lock.cc +++ b/base-fiasco/src/base/lock/lock.cc @@ -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; } diff --git a/base-foc/include/base/native_types.h b/base-foc/include/base/native_types.h index 3b341ff8e..6b55694e8 100644 --- a/base-foc/include/base/native_types.h +++ b/base-foc/include/base/native_types.h @@ -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; diff --git a/base-host/include/base/native_types.h b/base-host/include/base/native_types.h index 2d1a857fd..4e752f887 100644 --- a/base-host/include/base/native_types.h +++ b/base-host/include/base/native_types.h @@ -26,7 +26,6 @@ namespace Genode { static void copy(void* dst, Native_capability_tpl* src); }; - typedef volatile int Native_lock; typedef int Native_thread; typedef Native_thread Native_thread_id; typedef struct { } Native_utcb; diff --git a/base-hw/include/base/native_types.h b/base-hw/include/base/native_types.h index acb1b329a..4f253f1bb 100644 --- a/base-hw/include/base/native_types.h +++ b/base-hw/include/base/native_types.h @@ -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; diff --git a/base-linux/include/base/native_types.h b/base-linux/include/base/native_types.h index ef4a1c034..75b9a1e2c 100644 --- a/base-linux/include/base/native_types.h +++ b/base-linux/include/base/native_types.h @@ -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 * diff --git a/base-pistachio/include/base/native_types.h b/base-pistachio/include/base/native_types.h index f56437d4c..0df6b187c 100644 --- a/base-pistachio/include/base/native_types.h +++ b/base-pistachio/include/base/native_types.h @@ -23,8 +23,6 @@ namespace Pistachio { namespace Genode { - typedef volatile int Native_lock; - class Platform_thread; typedef Pistachio::L4_ThreadId_t Native_thread_id;