Skip to content

Commit

Permalink
Bypass OSMemoryBarrier() warning on Mac.
Browse files Browse the repository at this point in the history
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 #503

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=188553251
  • Loading branch information
pwnall committed Mar 10, 2018
1 parent 49f35d3 commit 594cc98
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions port/atomic_pointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 594cc98

Please sign in to comment.