mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 06:37:35 +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
1 changed files with 6 additions and 0 deletions
|
@ -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);
|
__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>
|
template<typename T, MemoryOrder DefaultMemoryOrder = AK::MemoryOrder::memory_order_seq_cst>
|
||||||
class Atomic {
|
class Atomic {
|
||||||
T m_value { 0 };
|
T m_value { 0 };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue