Modernized memory fence support for C11 and clang

pull/7938/head
Bill Phipps 2024-09-03 21:09:30 -04:00
parent ec6c7051a8
commit ae939e9e6a
1 changed files with 6 additions and 1 deletions

View File

@ -1266,8 +1266,13 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
#ifndef WOLFSSL_NO_FENCE
#ifdef XFENCE
/* use user-supplied XFENCE definition. */
#elif defined(__GNUC__) && (__GNUC__ >= 4)
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
#include <stdatomic.h>
#define XFENCE() atomic_thread_fence(__ATOMIC_SEQ_CST)
#elif defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC__ < 5)
#define XFENCE() __sync_synchronize()
#elif (defined(__GNUC__) && (__GNUC__ >= 5)) || defined (__clang__)
#define XFENCE() __atomic_thread_fence(__ATOMIC_SEQ_CST)
#elif defined (__i386__) || defined(__x86_64__)
#define XFENCE() XASM_VOLATILE("lfence")
#elif (defined (__arm__) && (__ARM_ARCH > 6)) || defined(__aarch64__)