Benaphores are nice and fast, but they aren't useful for debugging at

all.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23820 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-02-01 23:05:26 +00:00
parent 3037952b5f
commit 5ccd99565d
2 changed files with 14 additions and 2 deletions
+9 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2007, Axel Dörfler, [email protected].
* Copyright 2002-2008, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
@@ -81,20 +81,28 @@ benaphore_lock_etc(benaphore *ben, uint32 flags, bigtime_t timeout)
static inline status_t
benaphore_lock(benaphore *ben)
{
#ifdef KDEBUG
return acquire_sem(ben->sem);
#else
if (atomic_add(&ben->count, -1) <= 0)
return acquire_sem(ben->sem);
return B_OK;
#endif
}
static inline status_t
benaphore_unlock(benaphore *ben)
{
#ifdef KDEBUG
release_sem(ben->sem);
#else
if (atomic_add(&ben->count, 1) < 0)
return release_sem(ben->sem);
return B_OK;
#endif
}
extern status_t rw_lock_init(rw_lock *lock, const char *name);