summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2013-07-15 13:08:45 +0200
committerIvan Maidanski <ivmai@mail.ru>2013-07-15 13:08:45 +0200
commit89ff5faae1af92198706fa406b5780e6a10df0bf (patch)
treeb4121f1a019baaac7e56281a4a7b035bdfb9a78a
parent2fd2a4436aeed76f16274fe24fea735bbc7077c8 (diff)
Add assertion to LOCK definition that lock is not already held
* include/private/gc_locks.h (UNCOND_LOCK): Add assertion that I_DONT_HOLD_LOCK (lock is not held precondition).
-rw-r--r--include/private/gc_locks.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/include/private/gc_locks.h b/include/private/gc_locks.h
index fb8a463..6696651 100644
--- a/include/private/gc_locks.h
+++ b/include/private/gc_locks.h
@@ -59,7 +59,8 @@
GC_EXTERN CRITICAL_SECTION GC_allocate_ml;
# ifdef GC_ASSERTIONS
# define UNCOND_LOCK() \
- { EnterCriticalSection(&GC_allocate_ml); \
+ { GC_ASSERT(I_DONT_HOLD_LOCK()); \
+ EnterCriticalSection(&GC_allocate_ml); \
SET_LOCK_HOLDER(); }
# define UNCOND_UNLOCK() \
{ GC_ASSERT(I_HOLD_LOCK()); UNSET_LOCK_HOLDER(); \
@@ -116,7 +117,8 @@
/* GC_call_with_alloc_lock. */
# ifdef GC_ASSERTIONS
# define UNCOND_LOCK() \
- { if (AO_test_and_set_acquire(&GC_allocate_lock) == AO_TS_SET) \
+ { GC_ASSERT(I_DONT_HOLD_LOCK()); \
+ if (AO_test_and_set_acquire(&GC_allocate_lock) == AO_TS_SET) \
GC_lock(); \
SET_LOCK_HOLDER(); }
# define UNCOND_UNLOCK() \
@@ -124,7 +126,8 @@
AO_CLEAR(&GC_allocate_lock); }
# else
# define UNCOND_LOCK() \
- { if (AO_test_and_set_acquire(&GC_allocate_lock) == AO_TS_SET) \
+ { GC_ASSERT(I_DONT_HOLD_LOCK()); \
+ if (AO_test_and_set_acquire(&GC_allocate_lock) == AO_TS_SET) \
GC_lock(); }
# define UNCOND_UNLOCK() AO_CLEAR(&GC_allocate_lock)
# endif /* !GC_ASSERTIONS */
@@ -137,7 +140,8 @@
# include <pthread.h>
GC_EXTERN pthread_mutex_t GC_allocate_ml;
# ifdef GC_ASSERTIONS
-# define UNCOND_LOCK() { GC_lock(); SET_LOCK_HOLDER(); }
+# define UNCOND_LOCK() { GC_ASSERT(I_DONT_HOLD_LOCK()); \
+ GC_lock(); SET_LOCK_HOLDER(); }
# define UNCOND_UNLOCK() \
{ GC_ASSERT(I_HOLD_LOCK()); UNSET_LOCK_HOLDER(); \
pthread_mutex_unlock(&GC_allocate_ml); }