Fix deadlocks in write and suspend handlers if AO test-and-set is emulated
authorIvan Maidanski <ivmai@mail.ru>
Tue, 20 Nov 2018 08:42:52 +0000 (11:42 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 20 Nov 2018 20:47:09 +0000 (23:47 +0300)
commit8d4ecdfc81edab312a9feef9b5985f327ec50bad
treea82708f3bf8ec83d025f319858a2801336a992ac
parenta72365dad934afb78b1c670a8a86408aa8655b06
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().
configure.ac
include/private/gcconfig.h
mark.c
misc.c
pthread_stop_world.c