core: bitop: add atomic compare-exchange

This commit is contained in:
2025-08-09 19:48:01 +01:00
parent a1c1fee301
commit ed8e51ed5e

View File

@@ -7,4 +7,15 @@ BLUE_API int b_popcountl(long v);
BLUE_API int b_ctzl(long v); BLUE_API int b_ctzl(long v);
BLUE_API int b_clzl(long v); BLUE_API int b_clzl(long v);
#endif #if defined(__GNUC__) || defined(__clang__)
#define b_cmpxchg(v, expected_val, new_val) \
__atomic_compare_exchange_n( \
v, expected_val, new_val, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED)
#elif defined(_MSC_VER)
/* TODO add MSVC support */
#error MSVC intrinsics not yet supported
#else
#error Unsupported compiler
#endif
#endif