diff --git a/configure.ac b/configure.ac index f136d13f..41e34e9e 100644 --- a/configure.ac +++ b/configure.ac @@ -675,7 +675,7 @@ AS_IF([test "x$EMSCRIPTEN" = "x"],[ AC_CHECK_FUNCS([arc4random arc4random_buf]) AC_CHECK_FUNCS([mmap mlock madvise mprotect explicit_bzero nanosleep]) ]) -AC_CHECK_FUNCS([posix_memalign getpid]) +AC_CHECK_FUNCS([posix_memalign getpid _xgetbv]) AC_SUBST([LIBTOOL_EXTRA_FLAGS]) diff --git a/src/libsodium/sodium/runtime.c b/src/libsodium/sodium/runtime.c index 6c3cfb4f..a66bfb57 100644 --- a/src/libsodium/sodium/runtime.c +++ b/src/libsodium/sodium/runtime.c @@ -3,8 +3,8 @@ #ifdef HAVE_ANDROID_GETCPUFEATURES # include #endif -#if defined(_MSC_VER) && \ - (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)) +#if (defined(_MSC_VER) && \ + (defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86))) || defined(HAVE__XGETBV) # include #endif @@ -149,7 +149,9 @@ _sodium_runtime_intel_cpu_features(CPUFeatures * const cpu_features) if ((cpu_info[2] & (CPUID_ECX_AVX | CPUID_ECX_XSAVE | CPUID_ECX_OSXSAVE)) == (CPUID_ECX_AVX | CPUID_ECX_XSAVE | CPUID_ECX_OSXSAVE)) { uint32_t xcr0 = 0U; -# if defined(_MSC_VER) && defined(_XCR_XFEATURE_ENABLED_MASK) && _MSC_FULL_VER >= 160040219 +# if defined(HAVE__XGETBV) || + (defined(_MSC_VER) && defined(_XCR_XFEATURE_ENABLED_MASK) && + _MSC_FULL_VER >= 160040219) xcr0 = (uint32_t) _xgetbv(0); # elif defined(_MSC_VER) && defined(_M_IX86) __asm {