Skip to content

Commit 157753d

Browse files
committed
Detect if using C99 and use correct inline asm notation
1 parent 4b21cf3 commit 157753d

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

wolfssl/wolfcrypt/wc_port.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,15 +1180,22 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
11801180
#endif
11811181
#endif
11821182

1183+
#ifdef WOLF_C99
1184+
/* use alternate keyword for compatibility with -std=c99 */
1185+
#define XASM_VOLATILE(a) __asm__ volatile(a)
1186+
#else
1187+
#define XASM_VOLATILE(a) asm volatile(a)
1188+
#endif
1189+
11831190
#ifndef WOLFSSL_NO_FENCE
11841191
#if defined (__i386__) || defined(__x86_64__)
1185-
#define XFENCE() asm volatile("lfence")
1192+
#define XFENCE() XASM_VOLATILE("lfence")
11861193
#elif defined (__arm__) || defined(__aarch64__)
1187-
#define XFENCE() asm volatile("isb")
1194+
#define XFENCE() XASM_VOLATILE("isb")
11881195
#elif defined(__riscv)
1189-
#define XFENCE() asm volatile("fence")
1196+
#define XFENCE() XASM_VOLATILE("fence")
11901197
#elif defined(__PPC__)
1191-
#define XFENCE() asm volatile("isync; sync")
1198+
#define XFENCE() XASM_VOLATILE("isync; sync")
11921199
#else
11931200
#define XFENCE() do{}while(0)
11941201
#endif

0 commit comments

Comments
 (0)