sanitizer_atomic.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. //===-- sanitizer_atomic.h --------------------------------------*- C++ -*-===//
  2. //
  3. // This file is distributed under the University of Illinois Open Source
  4. // License. See LICENSE.TXT for details.
  5. //
  6. //===----------------------------------------------------------------------===//
  7. //
  8. // This file is a part of ThreadSanitizer/AddressSanitizer runtime.
  9. //
  10. //===----------------------------------------------------------------------===//
  11. #ifndef SANITIZER_ATOMIC_H
  12. #define SANITIZER_ATOMIC_H
  13. #include "sanitizer_internal_defs.h"
  14. namespace __sanitizer {
  15. enum memory_order {
  16. memory_order_relaxed = 1 << 0,
  17. memory_order_consume = 1 << 1,
  18. memory_order_acquire = 1 << 2,
  19. memory_order_release = 1 << 3,
  20. memory_order_acq_rel = 1 << 4,
  21. memory_order_seq_cst = 1 << 5
  22. };
  23. struct atomic_uint8_t {
  24. typedef u8 Type;
  25. volatile Type val_dont_use;
  26. };
  27. struct atomic_uint16_t {
  28. typedef u16 Type;
  29. volatile Type val_dont_use;
  30. };
  31. struct atomic_uint32_t {
  32. typedef u32 Type;
  33. volatile Type val_dont_use;
  34. };
  35. struct atomic_uint64_t {
  36. typedef u64 Type;
  37. // On 32-bit platforms u64 is not necessary aligned on 8 bytes.
  38. volatile ALIGNED(8) Type val_dont_use;
  39. };
  40. struct atomic_uintptr_t {
  41. typedef uptr Type;
  42. volatile Type val_dont_use;
  43. };
  44. } // namespace __sanitizer
  45. #if defined(__GNUC__)
  46. # include "sanitizer_atomic_clang.h"
  47. #elif defined(_MSC_VER)
  48. # include "sanitizer_atomic_msvc.h"
  49. #else
  50. # error "Unsupported compiler"
  51. #endif
  52. #endif // SANITIZER_ATOMIC_H