mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 07:30:19 +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
Notes:
sideshowbarker
2024-07-18 09:01:06 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/d9c2447999a Pull-request: https://github.com/SerenityOS/serenity/pull/8752 Reviewed-by: https://github.com/linusg ✅
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);
|
||||
}
|
||||
|
||||
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