mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-22 10:24:26 +00:00
[C++11] Replace LLVM atomics with std::atomic.
With C++11 we finally have a standardized way to specify atomic operations. Use them to replace the existing custom implemention. Sadly the translation is not entirely trivial as std::atomic allows more fine-grained control over the atomicity. I tried to preserve the old semantics as well as possible. Differential Revision: http://llvm-reviews.chandlerc.com/D2915 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202730 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -14,9 +14,9 @@
|
||||
#ifndef LLVM_SUPPORT_MANAGED_STATIC_H
|
||||
#define LLVM_SUPPORT_MANAGED_STATIC_H
|
||||
|
||||
#include "llvm/Support/Atomic.h"
|
||||
#include "llvm/Support/Threading.h"
|
||||
#include "llvm/Support/Valgrind.h"
|
||||
#include <atomic>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@ -64,7 +64,8 @@ public:
|
||||
// Accessors.
|
||||
C &operator*() {
|
||||
void* tmp = Ptr;
|
||||
if (llvm_is_multithreaded()) sys::MemoryFence();
|
||||
if (llvm_is_multithreaded())
|
||||
std::atomic_thread_fence(std::memory_order_seq_cst);
|
||||
if (!tmp) RegisterManagedStatic(object_creator<C>, object_deleter<C>::call);
|
||||
TsanHappensAfter(this);
|
||||
|
||||
@ -72,7 +73,8 @@ public:
|
||||
}
|
||||
C *operator->() {
|
||||
void* tmp = Ptr;
|
||||
if (llvm_is_multithreaded()) sys::MemoryFence();
|
||||
if (llvm_is_multithreaded())
|
||||
std::atomic_thread_fence(std::memory_order_seq_cst);
|
||||
if (!tmp) RegisterManagedStatic(object_creator<C>, object_deleter<C>::call);
|
||||
TsanHappensAfter(this);
|
||||
|
||||
@ -80,7 +82,8 @@ public:
|
||||
}
|
||||
const C &operator*() const {
|
||||
void* tmp = Ptr;
|
||||
if (llvm_is_multithreaded()) sys::MemoryFence();
|
||||
if (llvm_is_multithreaded())
|
||||
std::atomic_thread_fence(std::memory_order_seq_cst);
|
||||
if (!tmp) RegisterManagedStatic(object_creator<C>, object_deleter<C>::call);
|
||||
TsanHappensAfter(this);
|
||||
|
||||
@ -88,7 +91,8 @@ public:
|
||||
}
|
||||
const C *operator->() const {
|
||||
void* tmp = Ptr;
|
||||
if (llvm_is_multithreaded()) sys::MemoryFence();
|
||||
if (llvm_is_multithreaded())
|
||||
std::atomic_thread_fence(std::memory_order_seq_cst);
|
||||
if (!tmp) RegisterManagedStatic(object_creator<C>, object_deleter<C>::call);
|
||||
TsanHappensAfter(this);
|
||||
|
||||
|
Reference in New Issue
Block a user