Lines Matching +full:trade +full:- +full:off

1 //===-- atomic.c - Implement support functions for atomic operations.------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 // arbitrary-sized memory locations. This design uses locks that should
19 // To avoid needing a per-object lock, this code allocates an array of
24 //===----------------------------------------------------------------------===//
32 // We use __builtin_mem* here to avoid dependencies on libc-provided headers.
46 /// Number of locks. This allocates one page on 32-bit platforms, two on
47 /// 64-bit. This can be specified externally if a different trade between
52 static const long SPINLOCK_MASK = SPINLOCK_COUNT - 1;
55 // Platform-specific lock implementation. Falls back to spinlocks if none is
71 // clang-format off
75 // clang-format on
78 __c11_atomic_store((_Atomic(uint32_t) *)&l->_count, 1, __ATOMIC_RELEASE); in unlock()
80 if (l->_has_waiters) in unlock()
85 while (!__c11_atomic_compare_exchange_weak((_Atomic(uint32_t) *)&l->_count, in lock()
93 static Lock locks[SPINLOCK_COUNT] = {[0 ... SPINLOCK_COUNT - 1] = {0, 1, 0}};
106 "Implementation assumes lock-free pointer-size cmpxchg");
151 /// Macro that calls the compiler-generated lock-free versions of functions
178 /// Whether atomic operations for the given size (and alignment) are lock-free.
337 // Atomic read-modify-write operations for integers of various sizes.
366 #define OPTIMISED_CASE(n, lockfree, type) ATOMIC_RMW(n, lockfree, type, sub, -)
378 // Allow build with clang without __c11_atomic_fetch_nand builtin (pre-14)