aboutsummaryrefslogtreecommitdiffstats
path: root/erts/aclocal.m4
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2010-06-01 13:51:34 +0000
committerErlang/OTP <[email protected]>2010-06-01 13:51:34 +0000
commitc68f1802ce375c3425795671c74c6b3fd9c3a8ef (patch)
treeb2fbb14797c866cc1470f85dbc6382cf586150d4 /erts/aclocal.m4
parentb53f8a67649a371a38dc6d97b0dfe52111236a3e (diff)
downloadotp-c68f1802ce375c3425795671c74c6b3fd9c3a8ef.tar.gz
otp-c68f1802ce375c3425795671c74c6b3fd9c3a8ef.tar.bz2
otp-c68f1802ce375c3425795671c74c6b3fd9c3a8ef.zip
OTP-8659 Add ethread support for gcc atomics
Support for using gcc's built-in functions for atomic memory access has been added. This functionallity will be used if available and no other native atomic implementation in ERTS is available.
Diffstat (limited to 'erts/aclocal.m4')
-rw-r--r--erts/aclocal.m428
1 files changed, 28 insertions, 0 deletions
diff --git a/erts/aclocal.m4 b/erts/aclocal.m4
index 3d935b7295..6a92fa5653 100644
--- a/erts/aclocal.m4
+++ b/erts/aclocal.m4
@@ -843,6 +843,23 @@ case "$THR_LIB_NAME" in
AC_DEFINE(ETHR_HAVE_PTHREAD_ATTR_SETGUARDSIZE, 1, \
[Define if you have the pthread_attr_setguardsize function.]))
+ AC_MSG_CHECKING([for GCC atomic operations])
+ ethr_have_gcc_atomic_ops=no
+ AC_TRY_LINK([],
+ [
+ long res;
+ volatile long val;
+ res = __sync_val_compare_and_swap(&val, (long) 1, (long) 0);
+ res = __sync_add_and_fetch(&val, (long) 1);
+ res = __sync_sub_and_fetch(&val, (long) 1);
+ res = __sync_fetch_and_and(&val, (long) 1);
+ res = __sync_fetch_and_or(&val, (long) 1);
+ ],
+ [ethr_have_native_atomics=yes
+ ethr_have_gcc_atomic_ops=yes])
+ AC_MSG_RESULT([$ethr_have_gcc_atomic_ops])
+ test $ethr_have_gcc_atomic_ops = yes && AC_DEFINE(ETHR_HAVE_GCC_ATOMIC_OPS, 1, [Define if you have gcc atomic operations])
+
dnl Restore LIBS
LIBS=$saved_libs
dnl restore CPPFLAGS
@@ -873,6 +890,17 @@ if test "X$disable_native_ethr_impls" = "Xyes"; then
AC_DEFINE(ETHR_DISABLE_NATIVE_IMPLS, 1, [Define if you want to disable native ethread implementations])
fi
+AC_ARG_ENABLE(prefer-gcc-native-ethr-impls,
+ AS_HELP_STRING([--enable-prefer-gcc-native-ethr-impls],
+ [enable prefer gcc native ethread implementations]),
+[ case "$enableval" in
+ yes) enable_prefer_gcc_native_ethr_impls=yes ;;
+ *) enable_prefer_gcc_native_ethr_impls=no ;;
+ esac ], enable_prefer_gcc_native_ethr_impls=no)
+
+test $enable_prefer_gcc_native_ethr_impls = yes &&
+ AC_DEFINE(ETHR_PREFER_GCC_NATIVE_IMPLS, 1, [Define if you prefer gcc native ethread implementations])
+
AC_DEFINE(ETHR_HAVE_ETHREAD_DEFINES, 1, \
[Define if you have all ethread defines])