summaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2018-11-20 11:42:52 +0300
committerIvan Maidanski <ivmai@mail.ru>2018-11-20 23:47:09 +0300
commit8d4ecdfc81edab312a9feef9b5985f327ec50bad (patch)
treea82708f3bf8ec83d025f319858a2801336a992ac /misc.c
parenta72365dad934afb78b1c670a8a86408aa8655b06 (diff)
downloadbdwgc-8d4ecdfc81edab312a9feef9b5985f327ec50bad.tar.gz
Fix deadlocks in write and suspend handlers if AO test-and-set is emulated
This could be tested with -D AO_USE_PTHREAD_DEFS passed to CFLAGS. * configure.ac (AO_TRYLINK_CFLAGS): New variable. * configure.ac [$with_libatomic_ops!=none && $need_atomic_ops_asm!=true] (BASE_ATOMIC_OPS_EMULATED): New AC_DEFINE (defined in case of failure of AC_TRY_LINK of a code snippet calling AO_test_and_set_acquire, AO_CLEAR, AO_compiler_barrier, AO_store, AO_load, AO_char_store, AO_char_load, AO_store_release, AO_load_acquire); use AO_TRYLINK_CFLAGS; add comment. * include/private/gcconfig.h [BASE_ATOMIC_OPS_EMULATED] (MPROTECT_VDB): Undefine. * mark.c [AO_CLEAR] (GC_noop6): Do not call AO_compiler_barrier() if BASE_ATOMIC_OPS_EMULATED. * misc.c [!GC_DISABLE_INCREMENTAL] (GC_init, GC_enable_incremental): Do not set GC_manual_vdb if BASE_ATOMIC_OPS_EMULATED. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (ao_load_acquire_async, ao_load_async, ao_store_release_async, ao_store_async): New macro; undefine it after the usage. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_store_stack_ptr): Use ao_store_async() instead of AO_store(). * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL] (GC_suspend_handler_inner): Use ao_load[_acquire]_async() and ao_store_release_async() instead of AO_load[_acquire]() and AO_store_release(), respectively. * pthread_stop_world.c [!GC_OPENBSD_UTHREADS && !NACL && GC_ENABLE_SUSPEND_THREAD] (suspend_self_inner): Use ao_load_acquire_async() instead of AO_load_acquire().
Diffstat (limited to 'misc.c')
-rw-r--r--misc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/misc.c b/misc.c
index bcf4c72d..7e0bef75 100644
--- a/misc.c
+++ b/misc.c
@@ -1258,7 +1258,8 @@ GC_API void GC_CALL GC_init(void)
# endif
# ifndef GC_DISABLE_INCREMENTAL
if (GC_incremental || 0 != GETENV("GC_ENABLE_INCREMENTAL")) {
-# if defined(CHECKSUMS) || defined(SMALL_CONFIG)
+# if defined(BASE_ATOMIC_OPS_EMULATED) || defined(CHECKSUMS) \
+ || defined(SMALL_CONFIG)
/* TODO: Implement CHECKSUMS for manual VDB. */
# else
if (manual_vdb_allowed) {
@@ -1403,7 +1404,8 @@ GC_API void GC_CALL GC_enable_incremental(void)
GC_init();
LOCK();
} else {
-# if !defined(CHECKSUMS) && !defined(SMALL_CONFIG)
+# if !defined(BASE_ATOMIC_OPS_EMULATED) && !defined(CHECKSUMS) \
+ && !defined(SMALL_CONFIG)
if (manual_vdb_allowed) {
GC_manual_vdb = TRUE;
GC_incremental = TRUE;