From 594cc987af2e0af6417c4ac2b947ee8cdad59e5e Mon Sep 17 00:00:00 2001 From: costan Date: Fri, 9 Mar 2018 16:10:08 -0800 Subject: [PATCH] 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 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 --- port/atomic_pointer.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/port/atomic_pointer.h b/port/atomic_pointer.h index 54f088585d..43dab2ab3d 100644 --- a/port/atomic_pointer.h +++ b/port/atomic_pointer.h @@ -21,13 +21,12 @@ #include #ifdef LEVELDB_ATOMIC_PRESENT #include +#elif defined(__APPLE__) +#include #endif #ifdef OS_WIN #include #endif -#ifdef __APPLE__ -#include -#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