summaryrefslogtreecommitdiff
path: root/port
diff options
context:
space:
mode:
authorcostan <costan@google.com>2018-03-09 16:10:08 -0800
committerVictor Costan <pwnall@chromium.org>2018-03-09 16:37:44 -0800
commit594cc987af2e0af6417c4ac2b947ee8cdad59e5e (patch)
tree8f902951b4a954a29aba3fd7a10fa3c9411311e4 /port
parent49f35d3fc940a1e2d599d6ee3306eeb31a205e4b (diff)
downloadleveldb-594cc987af2e0af6417c4ac2b947ee8cdad59e5e.tar.gz
Bypass OSMemoryBarrier() warning on Mac.
This is a stopgap for removing warnings on Mac builds, so -Werror can be turned on. C++11 will be required in the nearby future, which guarantees <atomic> support. Once that happens, the simplified version of this will match https://github.com/google/leveldb/pull/503 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=188553251
Diffstat (limited to 'port')
-rw-r--r--port/atomic_pointer.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/port/atomic_pointer.h b/port/atomic_pointer.h
index 54f0885..43dab2a 100644
--- a/port/atomic_pointer.h
+++ b/port/atomic_pointer.h
@@ -21,13 +21,12 @@
#include <stdint.h>
#ifdef LEVELDB_ATOMIC_PRESENT
#include <atomic>
+#elif defined(__APPLE__)
+#include <libkern/OSAtomic.h>
#endif
#ifdef OS_WIN
#include <windows.h>
#endif
-#ifdef __APPLE__
-#include <libkern/OSAtomic.h>
-#endif
#if defined(_M_X64) || defined(__x86_64__)
#define ARCH_CPU_X86_FAMILY 1
@@ -56,7 +55,11 @@ namespace port {
// Mac OS
#elif defined(__APPLE__)
inline void MemoryBarrier() {
+#if defined(LEVELDB_ATOMIC_PRESENT)
+ std::atomic_thread_fence(std::memory_order_seq_cst);
+#else
OSMemoryBarrier();
+#endif // defined(LEVELDB_ATOMIC_PRESENT)
}
#define LEVELDB_HAVE_MEMORY_BARRIER