diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2018-11-20 11:42:52 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2018-11-20 23:47:09 +0300 |
commit | 8d4ecdfc81edab312a9feef9b5985f327ec50bad (patch) | |
tree | a82708f3bf8ec83d025f319858a2801336a992ac /configure.ac | |
parent | a72365dad934afb78b1c670a8a86408aa8655b06 (diff) | |
download | bdwgc-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 'configure.ac')
-rw-r--r-- | configure.ac | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 9ffe81de..7db06459 100644 --- a/configure.ac +++ b/configure.ac @@ -1088,8 +1088,10 @@ AS_IF([test x"$with_libatomic_ops" != xno], AS_IF([test x"$THREADS" != xnone], [ AC_DEFINE([GC_BUILTIN_ATOMIC], [1], [Use C11 (GCC) atomic intrinsics instead of - libatomic_ops primitives.]) ]) ]) ], + libatomic_ops primitives.]) ]) ]) + AO_TRYLINK_CFLAGS="" ], [ AC_MSG_RESULT([internal]) + AO_TRYLINK_CFLAGS="-I${srcdir}/libatomic_ops/src" ATOMIC_OPS_CFLAGS='-I$(top_builddir)/libatomic_ops/src -I$(top_srcdir)/libatomic_ops/src' ATOMIC_OPS_LIBS="" AC_SUBST([ATOMIC_OPS_CFLAGS]) @@ -1100,6 +1102,26 @@ AM_CONDITIONAL([USE_INTERNAL_LIBATOMIC_OPS], AM_CONDITIONAL([NEED_ATOMIC_OPS_ASM], [test x$with_libatomic_ops = xno -a x$need_atomic_ops_asm = xtrue]) +# Check whether particular AO primitives are emulated with locks. +# The check below is based on the fact that linking with the libatomic_ops +# binary file is not needed in case of absence of the emulation (except for +# Solaris SPARC). +AS_IF([test x$with_libatomic_ops != xnone -a x$need_atomic_ops_asm != xtrue], + [ old_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $AO_TRYLINK_CFLAGS $CFLAGS_EXTRA" + AC_MSG_CHECKING([for lock-free AO load/store, test-and-set primitives]) + AC_TRY_LINK([#include "atomic_ops.h"], + [AO_t x=0;unsigned char c=0;AO_TS_t z=AO_TS_INITIALIZER; + (void)AO_test_and_set_acquire(&z);AO_CLEAR(&z);AO_compiler_barrier(); + AO_store(&x,AO_load(&x)+1);AO_char_store(&c,AO_char_load(&c)+1); + AO_store_release(&x,AO_load_acquire(&x)+1)], + [ AC_MSG_RESULT(yes) ], + [ AC_MSG_RESULT(no) + AC_DEFINE([BASE_ATOMIC_OPS_EMULATED], [1], + [AO load, store and/or test-and-set primitives are + implemented in libatomic_ops using locks.]) ]) + CFLAGS="$old_CFLAGS" ]) + dnl Produce the Files dnl ----------------- |