Index: contrib/llvm-project/compiler-rt/lib/builtins/atomic.c =================================================================== --- contrib/llvm-project/compiler-rt/lib/builtins/atomic.c +++ contrib/llvm-project/compiler-rt/lib/builtins/atomic.c @@ -336,6 +336,7 @@ return tmp; \ } +#if __has_builtin(__c11_atomic_fetch_nand) #define ATOMIC_RMW_NAND(n, lockfree, type) \ type __atomic_fetch_nand_##n(type *ptr, type val, int model) { \ if (lockfree(ptr)) \ @@ -347,6 +348,17 @@ unlock(l); \ return tmp; \ } +#else +#define ATOMIC_RMW_NAND(n, lockfree, type) \ + type __atomic_fetch_nand_##n(type *ptr, type val, int model) { \ + Lock *l = lock_for_pointer(ptr); \ + lock(l); \ + type tmp = *ptr; \ + *ptr = ~(tmp & val); \ + unlock(l); \ + return tmp; \ + } +#endif #define OPTIMISED_CASE(n, lockfree, type) ATOMIC_RMW(n, lockfree, type, add, +) OPTIMISED_CASES