diff --git a/configure.ac b/configure.ac index b36a0877..90ff5413 100644 --- a/configure.ac +++ b/configure.ac @@ -660,6 +660,17 @@ AS_IF([test "x$aligned_access_required" = "xyes"], [AC_MSG_RESULT(no) AC_DEFINE([CPU_UNALIGNED_ACCESS], [1], [unaligned memory access is supported])]) +AC_MSG_CHECKING(if atomic operations are supported) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[ +static volatile int _sodium_lock; +__sync_lock_test_and_set(&_sodium_lock, 1); +__sync_lock_release(&_sodium_lock); +]] +)], +[AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_ATOMIC_OPS], [1], [atomic operations are supported])], +[AC_MSG_RESULT(no)]) + dnl Checks for functions and headers AS_IF([test "x$EMSCRIPTEN" = "x"],[ diff --git a/src/libsodium/sodium/core.c b/src/libsodium/sodium/core.c index aa23726e..1ac12cab 100644 --- a/src/libsodium/sodium/core.c +++ b/src/libsodium/sodium/core.c @@ -123,7 +123,7 @@ sodium_crit_leave(void) return 0; } -#elif defined(__GNUC__) && !defined(__EMSCRIPTEN__) && !defined(__native_client__) +#elif defined(HAVE_ATOMIC_OPS) && !defined(__EMSCRIPTEN__) && !defined(__native_client__) static volatile int _sodium_lock;