Atomic.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //===- llvm/Support/Atomic.h - Atomic Operations -----------------*- 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 declares the llvm::sys atomic operations.
  10. //
  11. // DO NOT USE IN NEW CODE!
  12. //
  13. // New code should always rely on the std::atomic facilities in C++11.
  14. //
  15. //===----------------------------------------------------------------------===//
  16. #ifndef LLVM_SUPPORT_ATOMIC_H
  17. #define LLVM_SUPPORT_ATOMIC_H
  18. #include "llvm/Support/DataTypes.h"
  19. // Windows will at times define MemoryFence.
  20. #ifdef MemoryFence
  21. #undef MemoryFence
  22. #endif
  23. namespace llvm {
  24. namespace sys {
  25. void MemoryFence();
  26. #ifdef _MSC_VER
  27. typedef long cas_flag;
  28. #else
  29. typedef uint32_t cas_flag;
  30. #endif
  31. cas_flag CompareAndSwap(volatile cas_flag* ptr,
  32. cas_flag new_value,
  33. cas_flag old_value);
  34. }
  35. }
  36. #endif