//===-- A simple equivalent of std::atomic ----------------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_ATOMIC_H #define LLVM_LIBC_SRC___SUPPORT_CPP_ATOMIC_H #include "src/__support/macros/attributes.h" #include "src/__support/macros/config.h" #include "src/__support/macros/properties/architectures.h" #include "type_traits.h" namespace LIBC_NAMESPACE_DECL { namespace cpp { enum class MemoryOrder : int { … }; // These are a clang extension, see the clang documenation for more information: // https://clang.llvm.org/docs/LanguageExtensions.html#scoped-atomic-builtins. enum class MemoryScope : int { … }; template <typename T> struct Atomic { … }; // Issue a thread fence with the given memory ordering. LIBC_INLINE void atomic_thread_fence([[maybe_unused]] MemoryOrder mem_ord) { … } // Establishes memory synchronization ordering of non-atomic and relaxed atomic // accesses, as instructed by order, between a thread and a signal handler // executed on the same thread. This is equivalent to atomic_thread_fence, // except no instructions for memory ordering are issued. Only reordering of // the instructions by the compiler is suppressed as order instructs. LIBC_INLINE void atomic_signal_fence([[maybe_unused]] MemoryOrder mem_ord) { … } } // namespace cpp } // namespace LIBC_NAMESPACE_DECL #endif // LLVM_LIBC_SRC___SUPPORT_CPP_ATOMIC_H