move WC_BARRIER() definition from wolfssl/wolfcrypt/types.h to wolfssl/wolfcrypt/wc_port.h, and strengthen it.

This commit is contained in:
Daniel Pouzzner
2026-04-01 16:20:10 -05:00
parent e6713372ee
commit faf2ff26de
2 changed files with 12 additions and 6 deletions
-6
View File
@@ -489,12 +489,6 @@ enum {
static WC_INLINE WARN_UNUSED_RESULT int WC_WUR_INT(int x) { return x; }
#endif
/* XFENCE() is a no-op on some targets. WC_BARRIER() uses C89 intrinsics as an
* additional portable barrier.
*/
#define WC_BARRIER() do { volatile byte _xfence = 0; (void)_xfence; XFENCE(); \
} while(0)
#ifdef WORD64_AVAILABLE
#define WC_MAX_UINT_OF(x) \
((x)((((word64)1 << ((sizeof(x) * (word64)CHAR_BIT) - \
+12
View File
@@ -1808,6 +1808,18 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
#define XFENCE() WC_DO_NOTHING
#endif
#ifdef WC_BARRIER
/* use user-supplied WC_BARRIER() definition. */
#elif defined(__GNUC__) && !defined(WOLFSSL_NO_ASM)
#define WC_BARRIER() __asm__ __volatile__("" ::: "memory")
#else
/* XFENCE() is a no-op on some targets. The fallback construct uses C89
* intrinsics as an additional (but weak) portable barrier.
*/
#define WC_BARRIER() do { volatile byte _xfence = 0; (void)_xfence; XFENCE(); \
} while(0)
#endif
/* AFTER user_settings.h is loaded,
** determine if POSIX multi-threaded: HAVE_PTHREAD */