From 764656443fa6d6d7f609945e1d7579536e45508b Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 31 Dec 2017 01:23:58 +0100 Subject: [PATCH] Check if we can use inline asm code, not only on x86_64 --- configure.ac | 12 ++++++++++++ src/libsodium/sodium/utils.c | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 24a7ea68..7478f1c7 100644 --- a/configure.ac +++ b/configure.ac @@ -580,6 +580,18 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ CPPFLAGS="$CPPFLAGS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS" ]) +AC_MSG_CHECKING(whether we can use inline asm code) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +]], [[ +int a = 42; +int *pnt = &a; +__asm__ __volatile__ ("" : : "r"(pnt) : "memory"); +]])], + [AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_INLINE_ASM], [1], [inline asm code can be used])] + [AC_MSG_RESULT(no)] +) + HAVE_AMD64_ASM_V=0 AS_IF([test "$enable_asm" != "no"],[ AC_MSG_CHECKING(whether we can use x86_64 asm code) diff --git a/src/libsodium/sodium/utils.c b/src/libsodium/sodium/utils.c index 2e3fcea8..3a5f835b 100644 --- a/src/libsodium/sodium/utils.c +++ b/src/libsodium/sodium/utils.c @@ -113,7 +113,7 @@ sodium_memzero(void *const pnt, const size_t len) #elif HAVE_WEAK_SYMBOLS memset(pnt, 0, len); _sodium_dummy_symbol_to_prevent_memzero_lto(pnt, len); -# ifdef HAVE_AMD64_ASM +# ifdef HAVE_INLINE_ASM __asm__ __volatile__ ("" : : "r"(pnt) : "memory"); # endif #else