1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-19 10:05:05 -07:00

Check if atomic operations are supported

This commit is contained in:
Frank Denis 2016-12-16 16:37:12 +01:00
parent 4c6f704084
commit db97a35502
2 changed files with 12 additions and 1 deletions

View File

@ -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"],[

View File

@ -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;