From 157753defe4abf611c563c940de86d56d0d34c4f Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Wed, 27 Dec 2023 17:25:08 +0100 Subject: [PATCH] Detect if using C99 and use correct inline asm notation --- wolfssl/wolfcrypt/wc_port.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/wolfssl/wolfcrypt/wc_port.h b/wolfssl/wolfcrypt/wc_port.h index 3f490549f..8815effff 100644 --- a/wolfssl/wolfcrypt/wc_port.h +++ b/wolfssl/wolfcrypt/wc_port.h @@ -1180,15 +1180,22 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void); #endif #endif +#ifdef WOLF_C99 + /* use alternate keyword for compatibility with -std=c99 */ + #define XASM_VOLATILE(a) __asm__ volatile(a) +#else + #define XASM_VOLATILE(a) asm volatile(a) +#endif + #ifndef WOLFSSL_NO_FENCE #if defined (__i386__) || defined(__x86_64__) - #define XFENCE() asm volatile("lfence") + #define XFENCE() XASM_VOLATILE("lfence") #elif defined (__arm__) || defined(__aarch64__) - #define XFENCE() asm volatile("isb") + #define XFENCE() XASM_VOLATILE("isb") #elif defined(__riscv) - #define XFENCE() asm volatile("fence") + #define XFENCE() XASM_VOLATILE("fence") #elif defined(__PPC__) - #define XFENCE() asm volatile("isync; sync") + #define XFENCE() XASM_VOLATILE("isync; sync") #else #define XFENCE() do{}while(0) #endif