2007-09-10 18:27:15 -04:00
|
|
|
|
|
|
|
dnl Checks for availability of GCC's atomic operations builtins.
|
|
|
|
dnl Defines HAVE_GCC_ATOMIC_BUILTINS if available.
|
|
|
|
|
|
|
|
AC_DEFUN([WX_ATOMIC_BUILTINS],
|
|
|
|
[
|
|
|
|
AC_REQUIRE([AC_PROG_CC])
|
|
|
|
if test -n "$GCC"; then
|
2022-05-10 18:12:43 -04:00
|
|
|
AC_MSG_CHECKING([for __sync_xxx_and_fetch builtins])
|
2007-09-10 18:27:15 -04:00
|
|
|
AC_CACHE_VAL(wx_cv_cc_gcc_atomic_builtins, [
|
2007-12-04 10:29:17 -05:00
|
|
|
AC_TRY_LINK(
|
2007-09-10 18:27:15 -04:00
|
|
|
[],
|
|
|
|
[
|
2007-12-04 10:29:17 -05:00
|
|
|
unsigned int value=0;
|
2022-05-10 18:12:43 -04:00
|
|
|
volatile unsigned int r1 = __sync_add_and_fetch(&value, 2);
|
2013-10-04 19:48:22 -04:00
|
|
|
volatile unsigned int r2 = __sync_sub_and_fetch(&value, 1);
|
2007-09-10 18:27:15 -04:00
|
|
|
],
|
|
|
|
wx_cv_cc_gcc_atomic_builtins=yes,
|
|
|
|
wx_cv_cc_gcc_atomic_builtins=no)
|
|
|
|
])
|
|
|
|
AC_MSG_RESULT([$wx_cv_cc_gcc_atomic_builtins])
|
|
|
|
if test $wx_cv_cc_gcc_atomic_builtins = yes; then
|
|
|
|
AC_DEFINE([HAVE_GCC_ATOMIC_BUILTINS])
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
])
|