diff --git a/repos/base-fiasco/include/base/cancelable_lock.h b/repos/base-fiasco/include/base/cancelable_lock.h deleted file mode 100644 index c684501dab..0000000000 --- a/repos/base-fiasco/include/base/cancelable_lock.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * \brief Basic locking primitive - * \author Norman Feske - * \date 2006-07-26 - */ - -/* - * Copyright (C) 2006-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. - */ - -#ifndef _INCLUDE__BASE__CANCELABLE_LOCK_H_ -#define _INCLUDE__BASE__CANCELABLE_LOCK_H_ - -#include -#include - -namespace Genode { - - class Cancelable_lock - { - private: - - int volatile _lock; - - public: - - enum State { LOCKED, UNLOCKED }; - - /** - * Constructor - */ - explicit Cancelable_lock(State initial = UNLOCKED); - - /** - * Try to aquire lock an block while lock is not free - * - * This function may throw a Genode::Blocking_canceled exception. - */ - void lock(); - - /** - * Release lock - */ - void unlock(); - - /** - * Lock guard - */ - typedef Genode::Lock_guard Guard; - }; -} - -#endif /* _INCLUDE__BASE__CANCELABLE_LOCK_H_ */ diff --git a/repos/base-fiasco/src/base/lock/lock.cc b/repos/base-fiasco/src/base/lock/lock.cc index 8cb6036d94..4516e3fee0 100644 --- a/repos/base-fiasco/src/base/lock/lock.cc +++ b/repos/base-fiasco/src/base/lock/lock.cc @@ -26,7 +26,7 @@ using namespace Genode; Cancelable_lock::Cancelable_lock(Cancelable_lock::State initial) -: _lock(UNLOCKED) +: _state(UNLOCKED), _owner(nullptr) { if (initial == LOCKED) lock(); @@ -39,7 +39,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(&_lock, UNLOCKED, LOCKED)) + while (!Genode::cmpxchg(&_state, UNLOCKED, LOCKED)) if (Fiasco::l4_ipc_sleep(Fiasco::l4_ipc_timeout(0, 0, 500, 0)) != L4_IPC_RETIMEOUT) throw Genode::Blocking_canceled(); } @@ -48,5 +48,5 @@ void Cancelable_lock::lock() void Cancelable_lock::unlock() { Genode::memory_barrier(); - _lock = UNLOCKED; + _state = UNLOCKED; } diff --git a/repos/base-sel4/include/base/cancelable_lock.h b/repos/base-sel4/include/base/cancelable_lock.h deleted file mode 100644 index c684501dab..0000000000 --- a/repos/base-sel4/include/base/cancelable_lock.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * \brief Basic locking primitive - * \author Norman Feske - * \date 2006-07-26 - */ - -/* - * Copyright (C) 2006-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. - */ - -#ifndef _INCLUDE__BASE__CANCELABLE_LOCK_H_ -#define _INCLUDE__BASE__CANCELABLE_LOCK_H_ - -#include -#include - -namespace Genode { - - class Cancelable_lock - { - private: - - int volatile _lock; - - public: - - enum State { LOCKED, UNLOCKED }; - - /** - * Constructor - */ - explicit Cancelable_lock(State initial = UNLOCKED); - - /** - * Try to aquire lock an block while lock is not free - * - * This function may throw a Genode::Blocking_canceled exception. - */ - void lock(); - - /** - * Release lock - */ - void unlock(); - - /** - * Lock guard - */ - typedef Genode::Lock_guard Guard; - }; -} - -#endif /* _INCLUDE__BASE__CANCELABLE_LOCK_H_ */ diff --git a/repos/base-sel4/src/base/lock/lock.cc b/repos/base-sel4/src/base/lock/lock.cc index 6db20e817c..45fe97c534 100644 --- a/repos/base-sel4/src/base/lock/lock.cc +++ b/repos/base-sel4/src/base/lock/lock.cc @@ -23,7 +23,7 @@ using namespace Genode; Cancelable_lock::Cancelable_lock(Cancelable_lock::State initial) -: _lock(UNLOCKED) +: _state(UNLOCKED), _owner(nullptr) { if (initial == LOCKED) lock(); @@ -32,7 +32,7 @@ Cancelable_lock::Cancelable_lock(Cancelable_lock::State initial) void Cancelable_lock::lock() { - while (!Genode::cmpxchg(&_lock, UNLOCKED, LOCKED)) + while (!Genode::cmpxchg(&_state, UNLOCKED, LOCKED)) seL4_Yield(); } @@ -40,5 +40,5 @@ void Cancelable_lock::lock() void Cancelable_lock::unlock() { Genode::memory_barrier(); - _lock = UNLOCKED; + _state = UNLOCKED; }