Dmitry Vyukov | fce5bd4 | 2012-06-29 16:58:33 +0000 | [diff] [blame] | 1 | //===-- sanitizer_atomic.h --------------------------------------*- C++ -*-===// |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Dmitry Vyukov | a3eca81 | 2012-06-29 17:32:18 +0000 | [diff] [blame] | 9 | // |
| 10 | // This file is a part of ThreadSanitizer/AddressSanitizer runtime. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 13 | |
Dmitry Vyukov | fce5bd4 | 2012-06-29 16:58:33 +0000 | [diff] [blame] | 14 | #ifndef SANITIZER_ATOMIC_H |
| 15 | #define SANITIZER_ATOMIC_H |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 16 | |
Dmitry Vyukov | fce5bd4 | 2012-06-29 16:58:33 +0000 | [diff] [blame] | 17 | #include "sanitizer_internal_defs.h" |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 18 | |
Dmitry Vyukov | fce5bd4 | 2012-06-29 16:58:33 +0000 | [diff] [blame] | 19 | namespace __sanitizer { |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 20 | |
| 21 | enum memory_order { |
| 22 | memory_order_relaxed = 1 << 0, |
| 23 | memory_order_consume = 1 << 1, |
| 24 | memory_order_acquire = 1 << 2, |
| 25 | memory_order_release = 1 << 3, |
| 26 | memory_order_acq_rel = 1 << 4, |
Alexey Samsonov | 62f2940 | 2012-07-02 06:48:10 +0000 | [diff] [blame] | 27 | memory_order_seq_cst = 1 << 5 |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 28 | }; |
| 29 | |
Dmitry Vyukov | fce5bd4 | 2012-06-29 16:58:33 +0000 | [diff] [blame] | 30 | struct atomic_uint8_t { |
| 31 | typedef u8 Type; |
| 32 | volatile Type val_dont_use; |
| 33 | }; |
| 34 | |
| 35 | struct atomic_uint16_t { |
| 36 | typedef u16 Type; |
| 37 | volatile Type val_dont_use; |
| 38 | }; |
| 39 | |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 40 | struct atomic_uint32_t { |
| 41 | typedef u32 Type; |
| 42 | volatile Type val_dont_use; |
| 43 | }; |
| 44 | |
| 45 | struct atomic_uint64_t { |
| 46 | typedef u64 Type; |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 47 | // On 32-bit platforms u64 is not necessary aligned on 8 bytes. |
| 48 | volatile ALIGNED(8) Type val_dont_use; |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | struct atomic_uintptr_t { |
| 52 | typedef uptr Type; |
| 53 | volatile Type val_dont_use; |
| 54 | }; |
| 55 | |
Dmitry Vyukov | fce5bd4 | 2012-06-29 16:58:33 +0000 | [diff] [blame] | 56 | } // namespace __sanitizer |
Kostya Serebryany | 7ac4148 | 2012-05-10 13:48:04 +0000 | [diff] [blame] | 57 | |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 58 | #if defined(__clang__) || defined(__GNUC__) |
Dmitry Vyukov | b6eb56f | 2012-06-29 18:00:38 +0000 | [diff] [blame] | 59 | # include "sanitizer_atomic_clang.h" |
| 60 | #elif defined(_MSC_VER) |
| 61 | # include "sanitizer_atomic_msvc.h" |
| 62 | #else |
| 63 | # error "Unsupported compiler" |
| 64 | #endif |
| 65 | |
Dmitry Vyukov | fce5bd4 | 2012-06-29 16:58:33 +0000 | [diff] [blame] | 66 | #endif // SANITIZER_ATOMIC_H |