Atomic.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/Support/Atomic.h - Atomic Operations -----------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file declares the llvm::sys atomic operations.
  15. //
  16. // DO NOT USE IN NEW CODE!
  17. //
  18. // New code should always rely on the std::atomic facilities in C++11.
  19. //
  20. //===----------------------------------------------------------------------===//
  21. #ifndef LLVM_SUPPORT_ATOMIC_H
  22. #define LLVM_SUPPORT_ATOMIC_H
  23. #include "llvm/Support/DataTypes.h"
  24. // Windows will at times define MemoryFence.
  25. #ifdef MemoryFence
  26. #undef MemoryFence
  27. #endif
  28. namespace llvm {
  29. namespace sys {
  30. void MemoryFence();
  31. #ifdef _MSC_VER
  32. typedef long cas_flag;
  33. #else
  34. typedef uint32_t cas_flag;
  35. #endif
  36. cas_flag CompareAndSwap(volatile cas_flag* ptr,
  37. cas_flag new_value,
  38. cas_flag old_value);
  39. }
  40. }
  41. #endif
  42. #ifdef __GNUC__
  43. #pragma GCC diagnostic pop
  44. #endif