From 74592da9a0a26c200ce02bf6714a9680aae19d4c Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Sat, 14 Mar 2020 15:18:01 -0400 Subject: [PATCH] headers: Remove libroot_lock.h. Not used (the one file that included it did not actually use it), and no longer needed with the introduction of user_mutex. --- headers/private/libroot/libroot_lock.h | 90 ------------------- .../libroot/posix/pthread/pthread_rwlock.cpp | 1 - 2 files changed, 91 deletions(-) delete mode 100644 headers/private/libroot/libroot_lock.h diff --git a/headers/private/libroot/libroot_lock.h b/headers/private/libroot/libroot_lock.h deleted file mode 100644 index 597821fde7..0000000000 --- a/headers/private/libroot/libroot_lock.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. - * Distributed under the terms of the MIT License. - * - * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. - * Distributed under the terms of the NewOS License. - */ -#ifndef _LIBROOT_LOCK_H -#define _LIBROOT_LOCK_H - -#include - - -// TODO: Copied from the kernel private lock.h/lock.c. We should somehow make -// that code reusable. - - -namespace BPrivate { - - -typedef struct benaphore { - sem_id sem; - int32 count; -} benaphore; - - -static inline status_t -benaphore_init(benaphore *ben, const char *name) -{ - if (ben == NULL || name == NULL) - return B_BAD_VALUE; - - ben->count = 1; - ben->sem = create_sem(0, name); - if (ben->sem >= B_OK) - return B_OK; - - return ben->sem; -} - - -static inline status_t -benaphore_lock_etc(benaphore *ben, uint32 flags, bigtime_t timeout) -{ -// TODO: This function really shouldn't be used, since timeouts screw the -// benaphore behavior. - if (atomic_add(&ben->count, -1) <= 0) - return acquire_sem_etc(ben->sem, 1, flags, timeout); - - return B_OK; -} - - -static inline status_t -benaphore_lock(benaphore *ben) -{ - if (atomic_add(&ben->count, -1) <= 0) { - status_t error; - do { - error = acquire_sem(ben->sem); - } while (error == B_INTERRUPTED); - - return error; - } - - return B_OK; -} - - -static inline status_t -benaphore_unlock(benaphore *ben) -{ - if (atomic_add(&ben->count, 1) < 0) - return release_sem(ben->sem); - - return B_OK; -} - - -} // namespace BPrivate - - -using BPrivate::benaphore; -using BPrivate::benaphore_init; -using BPrivate::benaphore_lock_etc; -using BPrivate::benaphore_lock; -using BPrivate::benaphore_unlock; - - -#endif // _LIBROOT_LOCK_H diff --git a/src/system/libroot/posix/pthread/pthread_rwlock.cpp b/src/system/libroot/posix/pthread/pthread_rwlock.cpp index b2470aea08..7765c5e95b 100644 --- a/src/system/libroot/posix/pthread/pthread_rwlock.cpp +++ b/src/system/libroot/posix/pthread/pthread_rwlock.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include #include