Move libroot synchronization functions to private namespace
* Prefix lock functions with __ to mark them as private. Add forwarding macros to keep existing code working. * Avoids symbol name clashes with kernel lock APIs, occuring when using kernellandemu-lib in userlandfs. Thanks to Ingo for the suggestion.
This commit is contained in:
parent
2e75b75292
commit
b916156a83
@ -21,11 +21,17 @@ typedef struct mutex {
|
||||
#define MUTEX_FLAG_ADAPTIVE 0x2
|
||||
#define MUTEX_INITIALIZER(name) { name, 0, 0 }
|
||||
|
||||
void mutex_init(mutex *lock, const char *name);
|
||||
void mutex_init_etc(mutex *lock, const char *name, uint32 flags);
|
||||
void mutex_destroy(mutex *lock);
|
||||
status_t mutex_lock(mutex *lock);
|
||||
void mutex_unlock(mutex *lock);
|
||||
#define mutex_init(lock, name) __mutex_init(lock, name)
|
||||
#define mutex_init_etc(lock, name, flags) __mutex_init_etc(lock, name, flags)
|
||||
#define mutex_destroy(lock) __mutex_destroy(lock)
|
||||
#define mutex_lock(lock) __mutex_lock(lock)
|
||||
#define mutex_unlock(lock) __mutex_unlock(lock)
|
||||
|
||||
void __mutex_init(mutex *lock, const char *name);
|
||||
void __mutex_init_etc(mutex *lock, const char *name, uint32 flags);
|
||||
void __mutex_destroy(mutex *lock);
|
||||
status_t __mutex_lock(mutex *lock);
|
||||
void __mutex_unlock(mutex *lock);
|
||||
|
||||
|
||||
typedef struct rw_lock {
|
||||
@ -42,13 +48,22 @@ typedef struct rw_lock {
|
||||
#define RW_LOCK_INITIALIZER(name) { MUTEX_INITIALIZER(name), NULL, \
|
||||
NULL, -1, 0, 0, 0 }
|
||||
|
||||
void rw_lock_init(rw_lock *lock, const char *name);
|
||||
void rw_lock_init_etc(rw_lock *lock, const char *name, uint32 flags);
|
||||
void rw_lock_destroy(rw_lock *lock);
|
||||
status_t rw_lock_read_lock(rw_lock *lock);
|
||||
status_t rw_lock_read_unlock(rw_lock *lock);
|
||||
status_t rw_lock_write_lock(rw_lock *lock);
|
||||
status_t rw_lock_write_unlock(rw_lock *lock);
|
||||
#define rw_lock_init(lock, name) __rw_lock_init(lock, name)
|
||||
#define rw_lock_init_etc(lock, name, flags) \
|
||||
__rw_lock_init_etc(lock, name, flags)
|
||||
#define rw_lock_destroy(lock) __rw_lock_destroy(lock)
|
||||
#define rw_lock_read_lock(lock) __rw_lock_read_lock(lock)
|
||||
#define rw_lock_read_unlock(lock) __rw_lock_read_unlock(lock)
|
||||
#define rw_lock_write_lock(lock) __rw_lock_write_lock(lock)
|
||||
#define rw_lock_write_unlock(lock) __rw_lock_write_unlock(lock)
|
||||
|
||||
void __rw_lock_init(rw_lock *lock, const char *name);
|
||||
void __rw_lock_init_etc(rw_lock *lock, const char *name, uint32 flags);
|
||||
void __rw_lock_destroy(rw_lock *lock);
|
||||
status_t __rw_lock_read_lock(rw_lock *lock);
|
||||
status_t __rw_lock_read_unlock(rw_lock *lock);
|
||||
status_t __rw_lock_write_lock(rw_lock *lock);
|
||||
status_t __rw_lock_write_unlock(rw_lock *lock);
|
||||
|
||||
|
||||
typedef struct recursive_lock {
|
||||
@ -60,13 +75,21 @@ typedef struct recursive_lock {
|
||||
#define RECURSIVE_LOCK_FLAG_CLONE_NAME MUTEX_FLAG_CLONE_NAME
|
||||
#define RECURSIVE_LOCK_INITIALIZER(name) { MUTEX_INITIALIZER(name), -1, 0 }
|
||||
|
||||
void recursive_lock_init(recursive_lock *lock, const char *name);
|
||||
void recursive_lock_init_etc(recursive_lock *lock, const char *name,
|
||||
#define recursive_lock_init(lock, name) __recursive_lock_init(lock, name)
|
||||
#define recursive_lock_init_etc(lock, name, flags) \
|
||||
__recursive_lock_init_etc(lock, name, flags)
|
||||
#define recursive_lock_destroy(lock) __recursive_lock_destroy(lock)
|
||||
#define recursive_lock_lock(lock) __recursive_lock_lock(lock)
|
||||
#define recursive_lock_unlock(lock) __recursive_lock_unlock(lock)
|
||||
#define recursive_lock_get_recursion(lock) __recursive_lock_get_recursion(lock)
|
||||
|
||||
void __recursive_lock_init(recursive_lock *lock, const char *name);
|
||||
void __recursive_lock_init_etc(recursive_lock *lock, const char *name,
|
||||
uint32 flags);
|
||||
void recursive_lock_destroy(recursive_lock *lock);
|
||||
status_t recursive_lock_lock(recursive_lock *lock);
|
||||
void recursive_lock_unlock(recursive_lock *lock);
|
||||
int32 recursive_lock_get_recursion(recursive_lock *lock);
|
||||
void __recursive_lock_destroy(recursive_lock *lock);
|
||||
status_t __recursive_lock_lock(recursive_lock *lock);
|
||||
void __recursive_lock_unlock(recursive_lock *lock);
|
||||
int32 __recursive_lock_get_recursion(recursive_lock *lock);
|
||||
|
||||
|
||||
#define INIT_ONCE_UNINITIALIZED -1
|
||||
|
@ -28,7 +28,7 @@ extern int32 __gCPUCount;
|
||||
|
||||
|
||||
void
|
||||
mutex_init(mutex *lock, const char *name)
|
||||
__mutex_init(mutex *lock, const char *name)
|
||||
{
|
||||
lock->name = name;
|
||||
lock->lock = 0;
|
||||
@ -37,7 +37,7 @@ mutex_init(mutex *lock, const char *name)
|
||||
|
||||
|
||||
void
|
||||
mutex_init_etc(mutex *lock, const char *name, uint32 flags)
|
||||
__mutex_init_etc(mutex *lock, const char *name, uint32 flags)
|
||||
{
|
||||
lock->name = (flags & MUTEX_FLAG_CLONE_NAME) != 0 ? strdup(name) : name;
|
||||
lock->lock = 0;
|
||||
@ -49,7 +49,7 @@ mutex_init_etc(mutex *lock, const char *name, uint32 flags)
|
||||
|
||||
|
||||
void
|
||||
mutex_destroy(mutex *lock)
|
||||
__mutex_destroy(mutex *lock)
|
||||
{
|
||||
if ((lock->flags & MUTEX_FLAG_CLONE_NAME) != 0)
|
||||
free(const_cast<char*>(lock->name));
|
||||
@ -57,7 +57,7 @@ mutex_destroy(mutex *lock)
|
||||
|
||||
|
||||
status_t
|
||||
mutex_lock(mutex *lock)
|
||||
__mutex_lock(mutex *lock)
|
||||
{
|
||||
uint32 count = 0;
|
||||
const uint32 kMaxCount
|
||||
@ -87,7 +87,7 @@ mutex_lock(mutex *lock)
|
||||
|
||||
|
||||
void
|
||||
mutex_unlock(mutex *lock)
|
||||
__mutex_unlock(mutex *lock)
|
||||
{
|
||||
// clear the locked flag
|
||||
int32 oldValue = atomic_and(&lock->lock, ~(int32)B_USER_MUTEX_LOCKED);
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
|
||||
int32
|
||||
recursive_lock_get_recursion(recursive_lock *lock)
|
||||
__recursive_lock_get_recursion(recursive_lock *lock)
|
||||
{
|
||||
if (lock->holder == find_thread(NULL))
|
||||
return lock->recursion;
|
||||
@ -28,14 +28,14 @@ recursive_lock_get_recursion(recursive_lock *lock)
|
||||
|
||||
|
||||
void
|
||||
recursive_lock_init(recursive_lock *lock, const char *name)
|
||||
__recursive_lock_init(recursive_lock *lock, const char *name)
|
||||
{
|
||||
recursive_lock_init_etc(lock, name, 0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
recursive_lock_init_etc(recursive_lock *lock, const char *name, uint32 flags)
|
||||
__recursive_lock_init_etc(recursive_lock *lock, const char *name, uint32 flags)
|
||||
{
|
||||
lock->holder = -1;
|
||||
lock->recursion = 0;
|
||||
@ -44,7 +44,7 @@ recursive_lock_init_etc(recursive_lock *lock, const char *name, uint32 flags)
|
||||
|
||||
|
||||
void
|
||||
recursive_lock_destroy(recursive_lock *lock)
|
||||
__recursive_lock_destroy(recursive_lock *lock)
|
||||
{
|
||||
if (lock == NULL)
|
||||
return;
|
||||
@ -54,7 +54,7 @@ recursive_lock_destroy(recursive_lock *lock)
|
||||
|
||||
|
||||
status_t
|
||||
recursive_lock_lock(recursive_lock *lock)
|
||||
__recursive_lock_lock(recursive_lock *lock)
|
||||
{
|
||||
thread_id thread = find_thread(NULL);
|
||||
|
||||
@ -69,7 +69,7 @@ recursive_lock_lock(recursive_lock *lock)
|
||||
|
||||
|
||||
void
|
||||
recursive_lock_unlock(recursive_lock *lock)
|
||||
__recursive_lock_unlock(recursive_lock *lock)
|
||||
{
|
||||
if (find_thread(NULL) != lock->holder) {
|
||||
debugger("recursive_lock unlocked by non-holder thread!\n");
|
||||
|
@ -80,14 +80,14 @@ rw_lock_unblock(rw_lock *lock)
|
||||
|
||||
|
||||
void
|
||||
rw_lock_init(rw_lock *lock, const char *name)
|
||||
__rw_lock_init(rw_lock *lock, const char *name)
|
||||
{
|
||||
rw_lock_init_etc(lock, name, 0);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
rw_lock_init_etc(rw_lock *lock, const char *name, uint32 flags)
|
||||
__rw_lock_init_etc(rw_lock *lock, const char *name, uint32 flags)
|
||||
{
|
||||
lock->waiters = NULL;
|
||||
lock->holder = -1;
|
||||
@ -99,7 +99,7 @@ rw_lock_init_etc(rw_lock *lock, const char *name, uint32 flags)
|
||||
|
||||
|
||||
void
|
||||
rw_lock_destroy(rw_lock *lock)
|
||||
__rw_lock_destroy(rw_lock *lock)
|
||||
{
|
||||
mutex_lock(&lock->lock);
|
||||
|
||||
@ -114,7 +114,7 @@ rw_lock_destroy(rw_lock *lock)
|
||||
|
||||
|
||||
status_t
|
||||
rw_lock_read_lock(rw_lock *lock)
|
||||
__rw_lock_read_lock(rw_lock *lock)
|
||||
{
|
||||
MutexLocker locker(lock->lock);
|
||||
|
||||
@ -133,7 +133,7 @@ rw_lock_read_lock(rw_lock *lock)
|
||||
|
||||
|
||||
status_t
|
||||
rw_lock_read_unlock(rw_lock *lock)
|
||||
__rw_lock_read_unlock(rw_lock *lock)
|
||||
{
|
||||
MutexLocker locker(lock->lock);
|
||||
|
||||
@ -161,7 +161,7 @@ rw_lock_read_unlock(rw_lock *lock)
|
||||
|
||||
|
||||
status_t
|
||||
rw_lock_write_lock(rw_lock *lock)
|
||||
__rw_lock_write_lock(rw_lock *lock)
|
||||
{
|
||||
MutexLocker locker(lock->lock);
|
||||
|
||||
@ -194,7 +194,7 @@ rw_lock_write_lock(rw_lock *lock)
|
||||
|
||||
|
||||
status_t
|
||||
rw_lock_write_unlock(rw_lock *lock)
|
||||
__rw_lock_write_unlock(rw_lock *lock)
|
||||
{
|
||||
MutexLocker locker(lock->lock);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user