c++: Fix crash in gimplifier with paren init of aggregates [PR94155]
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_atomic.h
bloba798a0cf25d9ce02ab540b4a4a9f9c69b6976dfc
1 //===-- sanitizer_atomic.h --------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file is a part of ThreadSanitizer/AddressSanitizer runtime.
11 //===----------------------------------------------------------------------===//
13 #ifndef SANITIZER_ATOMIC_H
14 #define SANITIZER_ATOMIC_H
16 #include "sanitizer_internal_defs.h"
18 namespace __sanitizer {
20 enum memory_order {
21 memory_order_relaxed = 1 << 0,
22 memory_order_consume = 1 << 1,
23 memory_order_acquire = 1 << 2,
24 memory_order_release = 1 << 3,
25 memory_order_acq_rel = 1 << 4,
26 memory_order_seq_cst = 1 << 5
29 struct atomic_uint8_t {
30 typedef u8 Type;
31 volatile Type val_dont_use;
34 struct atomic_uint16_t {
35 typedef u16 Type;
36 volatile Type val_dont_use;
39 struct atomic_sint32_t {
40 typedef s32 Type;
41 volatile Type val_dont_use;
44 struct atomic_uint32_t {
45 typedef u32 Type;
46 volatile Type val_dont_use;
49 struct atomic_uint64_t {
50 typedef u64 Type;
51 // On 32-bit platforms u64 is not necessary aligned on 8 bytes.
52 volatile ALIGNED(8) Type val_dont_use;
55 struct atomic_uintptr_t {
56 typedef uptr Type;
57 volatile Type val_dont_use;
60 } // namespace __sanitizer
62 #if defined(__clang__) || defined(__GNUC__)
63 # include "sanitizer_atomic_clang.h"
64 #elif defined(_MSC_VER)
65 # include "sanitizer_atomic_msvc.h"
66 #else
67 # error "Unsupported compiler"
68 #endif
70 namespace __sanitizer {
72 // Clutter-reducing helpers.
74 template<typename T>
75 INLINE typename T::Type atomic_load_relaxed(const volatile T *a) {
76 return atomic_load(a, memory_order_relaxed);
79 template<typename T>
80 INLINE void atomic_store_relaxed(volatile T *a, typename T::Type v) {
81 atomic_store(a, v, memory_order_relaxed);
84 } // namespace __sanitizer
86 #endif // SANITIZER_ATOMIC_H