summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2019-05-30 22:53:12 +0300
committerIvan Maidanski <ivmai@mail.ru>2019-05-30 22:53:12 +0300
commitf00da23cae44697b56f55b08cb5bb848dbe9c833 (patch)
tree1c4313a4ca4fbc9659327f40a3bf0fb3c9953d24 /misc.c
parente10f17bef86319878877d5023f2afa098c25307b (diff)
downloadbdwgc-f00da23cae44697b56f55b08cb5bb848dbe9c833.tar.gz
New API standalone functions to acquire and release the allocator lock
Issue #282 (bdwgc). Public GC_alloc_lock() and GC_alloc_unlock() are introduced to simplify dealing with the GC lock compared to GC_call_with_alloc_lock(). * include/gc.h [GC_THREADS] (GC_alloc_lock, GC_alloc_unlock): Declare new API function. * include/gc.h [!GC_THREADS] (GC_alloc_lock, GC_alloc_unlock): Define as a no-op macro. * misc.c [THREADS] (GC_alloc_lock, GC_alloc_unlock): Define API function. * tests/test.c (reachable_objs_count_enumerator): Remove function. * tests/test.c (check_heap_stats): Call GC_alloc_lock(); call GC_enumerate_reachable_objects_inner() directly; call GC_alloc_unlock().
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/misc.c b/misc.c
index 322422fb..15570ca8 100644
--- a/misc.c
+++ b/misc.c
@@ -2310,6 +2310,18 @@ GC_API GC_word GC_CALL GC_get_gc_no(void)
return GC_parallel;
}
+ GC_API void GC_CALL GC_alloc_lock(void)
+ {
+ DCL_LOCK_STATE;
+ LOCK();
+ }
+
+ GC_API void GC_CALL GC_alloc_unlock(void)
+ {
+ /* no DCL_LOCK_STATE */
+ UNLOCK();
+ }
+
GC_INNER GC_on_thread_event_proc GC_on_thread_event = 0;
GC_API void GC_CALL GC_set_on_thread_event(GC_on_thread_event_proc fn)