diff --git a/compiler-rt/lib/builtins/atomic.c b/compiler-rt/lib/builtins/atomic.c index 852bb20f0867..9b3777e5d29f 100644 --- a/compiler-rt/lib/builtins/atomic.c +++ b/compiler-rt/lib/builtins/atomic.c @@ -92,8 +92,11 @@ __inline static void lock(Lock *l) { OSSpinLockLock(l); } static Lock locks[SPINLOCK_COUNT]; // initialized to OS_SPINLOCK_INIT which is 0 #else +#ifndef __CHERI_PURE_CAPABILITY__ +// FIXME: needs https://github.com/CTSRD-CHERI/llvm-project/pull/721 _Static_assert(__atomic_always_lock_free(sizeof(uintptr_t), 0), "Implementation assumes lock-free pointer-size cmpxchg"); +#endif typedef _Atomic(uintptr_t) Lock; /// Unlock a lock. This is a release operation. __inline static void unlock(Lock *l) { diff --git a/libcxx/include/atomic b/libcxx/include/atomic index 92da4820e928..e0258b136d4e 100644 --- a/libcxx/include/atomic +++ b/libcxx/include/atomic @@ -1408,6 +1408,13 @@ _Tp __cxx_atomic_fetch_xor(__cxx_atomic_lock_impl<_Tp>* __a, template struct __cxx_is_always_lock_free { enum { __value = __atomic_always_lock_free(sizeof(_Tp), 0) }; }; +#ifdef __CHERI_PURE_CAPABILITY__ +// FIXME: can be removed after https://github.com/CTSRD-CHERI/llvm-project/pull/721 lands +template struct __cxx_is_always_lock_free { enum { __value = 2 == ATOMIC_POINTER_LOCK_FREE }; }; +template struct __cxx_is_always_lock_free { enum { __value = 2 == ATOMIC_POINTER_LOCK_FREE }; }; +template struct __cxx_is_always_lock_free<_Tp*> { enum { __value = 2 == ATOMIC_POINTER_LOCK_FREE }; }; +template<> struct __cxx_is_always_lock_free { enum { __value = 2 == ATOMIC_POINTER_LOCK_FREE }; }; +#endif #else