mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-22 02:26:11 +00:00
AK: Add free function to wrap around __atomic_is_lock_free built-in
Note: this exact implementation is needed for __atomic_is_lock_free to link with both GCC (for the SerenityOS build) and Clang (for the Fuzzer build). The size argument must be a compile-time constant, otherwise it fails to link with both compilers. Alternatively, the following definition links with GCC but fails with Clang: template<size_t S> static inline bool atomic_is_lock_free(volatile void* ptr = nullptr) { return __atomic_is_lock_free(S, ptr); }
This commit is contained in:
parent
33eb830929
commit
d9c2447999
|
@ -133,6 +133,12 @@ static inline void atomic_store(volatile T** var, std::nullptr_t, MemoryOrder or
|
|||
__atomic_store_n(const_cast<V**>(var), nullptr, order);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static inline bool atomic_is_lock_free(volatile T* ptr = nullptr) noexcept
|
||||
{
|
||||
return __atomic_is_lock_free(sizeof(T), ptr);
|
||||
}
|
||||
|
||||
template<typename T, MemoryOrder DefaultMemoryOrder = AK::MemoryOrder::memory_order_seq_cst>
|
||||
class Atomic {
|
||||
T m_value { 0 };
|
||||
|
|
Loading…
Reference in a new issue