Merge pull request #7938 from billphipps/atomic_fence

Modernized memory fence support for C11 and clang
This commit is contained in:
Daniel Pouzzner
2024-09-04 13:17:26 -05:00
committed by GitHub

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__)