wxWidgets/build/aclocal/atomic_builtins.m4
Vadim Zeitlin cf66ce5f94 Return the new value from wxAtomicInc() too
This is easy to do and can be useful when using an atomic initialization
counter.

The only platform where not returning the new value might be more
efficient than returning it is Solaris which is not really relevant any
more and on all the other platforms the functions we were already using
provided this value already (or almost, in case of using gcc builtins,
when we just have to use a different one).
2022-05-11 00:16:47 +02:00

27 lines
790 B
Plaintext

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
AC_MSG_CHECKING([for __sync_xxx_and_fetch builtins])
AC_CACHE_VAL(wx_cv_cc_gcc_atomic_builtins, [
AC_TRY_LINK(
[],
[
unsigned int value=0;
volatile unsigned int r1 = __sync_add_and_fetch(&value, 2);
volatile unsigned int r2 = __sync_sub_and_fetch(&value, 1);
],
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
])