From e698b1b000e7d600df8d41a0b25126ebbd0f7e82 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sat, 5 Aug 2023 23:04:35 +0200 Subject: [PATCH] Check _M_ARM64 in addition to __aarch64__ --- src/libsodium/sodium/core.c | 2 +- src/libsodium/sodium/runtime.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libsodium/sodium/core.c b/src/libsodium/sodium/core.c index 398944aa..b5beec92 100644 --- a/src/libsodium/sodium/core.c +++ b/src/libsodium/sodium/core.c @@ -154,7 +154,7 @@ sodium_crit_enter(void) (void) nanosleep(&q, NULL); # elif defined(__x86_64__) || defined(__i386__) __asm__ __volatile__ ("pause":::"memory"); -# elif defined(__aarch64__) +# elif defined(__aarch64__) || defined(_M_ARM64) __asm__ __volatile__ ("yield":::"memory"); # endif } diff --git a/src/libsodium/sodium/runtime.c b/src/libsodium/sodium/runtime.c index f15b5b2d..68ec607c 100644 --- a/src/libsodium/sodium/runtime.c +++ b/src/libsodium/sodium/runtime.c @@ -64,12 +64,12 @@ _sodium_runtime_arm_cpu_features(CPUFeatures * const cpu_features) return -1; /* LCOV_EXCL_LINE */ #endif -#if defined(__ARM_NEON) || defined(__aarch64__) +#if defined(__ARM_NEON) || defined(__aarch64__) || defined(_M_ARM64) cpu_features->has_neon = 1; #elif defined(HAVE_ANDROID_GETCPUFEATURES) && defined(ANDROID_CPU_ARM_FEATURE_NEON) cpu_features->has_neon = (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0x0; -#elif defined(__aarch64__) && defined(AT_HWCAP) +#elif (defined(__aarch64__) || defined(_M_ARM64)) && defined(AT_HWCAP) # ifdef HAVE_GETAUXVAL cpu_features->has_neon = (getauxval(AT_HWCAP) & (1L << 1)) != 0; # elif defined(HAVE_ELF_AUX_INFO) @@ -118,7 +118,7 @@ _sodium_runtime_arm_cpu_features(CPUFeatures * const cpu_features) #elif defined(HAVE_ANDROID_GETCPUFEATURES) && defined(ANDROID_CPU_ARM_FEATURE_AES) cpu_features->has_armcrypto = (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_AES) != 0x0; -#elif defined(__aarch64__) && defined(AT_HWCAP) +#elif (defined(__aarch64__) || defined(_M_ARM64)) && defined(AT_HWCAP) # ifdef HAVE_GETAUXVAL cpu_features->has_armcrypto = (getauxval(AT_HWCAP) & (1L << 3)) != 0; # elif defined(HAVE_ELF_AUX_INFO)