3 # AE_CC_ATOMIC_BUILTINS([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
7 # Copyright (c) 2023 Michael Jeanson <mjeanson@efficios.com>
9 # This program is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by the
11 # Free Software Foundation; either version 2 of the License, or (at your
12 # option) any later version.
14 # This program is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17 # Public License for more details.
19 # You should have received a copy of the GNU General Public License along
20 # with this program. If not, see <https://www.gnu.org/licenses/>.
22 # As a special exception, the respective Autoconf Macro's copyright owner
23 # gives unlimited permission to copy, distribute and modify the configure
24 # scripts that are the output of Autoconf when processing the Macro. You
25 # need not follow the terms of the GNU General Public License when using
26 # or distributing such scripts, even though portions of the text of the
27 # Macro appear in them. The GNU General Public License (GPL) does govern
28 # all other use of the material that constitutes the Autoconf Macro.
30 # This special exception to the GPL applies to versions of the Autoconf
31 # Macro released by the Autoconf Archive. When you make and distribute a
32 # modified version of the Autoconf Macro, you may extend this special
33 # exception to the GPL to apply to your modified version as well.
37 AC_DEFUN([AE_CC_ATOMIC_BUILTINS], [
38 AC_REQUIRE([AC_PROG_CC])
42 [whether $CC supports atomic builtins],
43 [ae_cv_cc_atomic_builtins],
49 __atomic_store_n(&x, 0, __ATOMIC_RELAXED);
50 __atomic_load_n(&x, __ATOMIC_RELAXED);
51 y = __atomic_exchange_n(&x, 1, __ATOMIC_RELAXED);
52 __atomic_compare_exchange_n(&x, &y, 0, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED);
53 __atomic_add_fetch(&x, 1, __ATOMIC_RELAXED);
54 __atomic_sub_fetch(&x, 1, __ATOMIC_RELAXED);
55 __atomic_and_fetch(&x, 0x01, __ATOMIC_RELAXED);
56 __atomic_or_fetch(&x, 0x01, __ATOMIC_RELAXED);
57 __atomic_thread_fence(__ATOMIC_RELAXED);
58 __atomic_signal_fence(__ATOMIC_RELAXED);
61 ae_cv_cc_atomic_builtins=yes
63 ae_cv_cc_atomic_builtins=no
68 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
69 if test "x$ae_cv_cc_atomic_builtins" = "xyes"; then
78 ])dnl AE_CC_ATOMIC_BUILTINS