1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00

Refine check for when atomics are available.

* configure.ac:
* libguile/atomics-internal.h: Use HAVE_STDATOMIC_H to know when to use
  atomics.
This commit is contained in:
Andy Wingo 2016-12-06 23:26:06 +01:00
parent 7ff3d3834d
commit b0ccf4dd4a
2 changed files with 4 additions and 5 deletions

View file

@ -326,6 +326,7 @@ AC_SUBST([SCM_I_GSC_T_PTRDIFF])
AC_CHECK_HEADERS([stdint.h]) AC_CHECK_HEADERS([stdint.h])
AC_CHECK_HEADERS([inttypes.h]) AC_CHECK_HEADERS([inttypes.h])
AC_CHECK_HEADERS([stdatomic.h])
AC_CHECK_SIZEOF(intmax_t) AC_CHECK_SIZEOF(intmax_t)

View file

@ -28,9 +28,7 @@
#define HAVE_C11_ATOMICS (__STDC_VERSION__ >= 201112L && !defined(__STDC_NO_ATOMICS__)) #ifdef HAVE_STDATOMIC_H
#if HAVE_C11_ATOMICS
#include <stdatomic.h> #include <stdatomic.h>
static inline uint32_t static inline uint32_t
@ -74,7 +72,7 @@ scm_atomic_compare_and_swap_scm (SCM *loc, SCM *expected, SCM desired)
{ {
return atomic_compare_exchange_weak (loc, expected, desired); return atomic_compare_exchange_weak (loc, expected, desired);
} }
#else /* HAVE_C11_ATOMICS */ #else /* HAVE_STDATOMIC_H */
/* Fallback implementation using locks. */ /* Fallback implementation using locks. */
#include "libguile/threads.h" #include "libguile/threads.h"
@ -171,6 +169,6 @@ scm_atomic_compare_and_swap_scm (SCM *loc, SCM *expected, SCM desired)
return ret; return ret;
} }
#endif /* HAVE_C11_ATOMICS */ #endif /* HAVE_STDATOMIC_H */
#endif /* SCM_ATOMICS_INTERNAL_H */ #endif /* SCM_ATOMICS_INTERNAL_H */