@ -25,8 +25,8 @@
# define PORT_ATOMIC_POINTER_H_
# define PORT_ATOMIC_POINTER_H_
# include <stdint.h>
# include <stdint.h>
# ifdef LEVELDB_CSTD ATOMIC_PRESENT
# ifdef ROCKSDB_ ATOMIC_PRESENT
# include <cstd atomic>
# include <atomic>
# endif
# endif
# ifdef OS_WIN
# ifdef OS_WIN
# include <windows.h>
# include <windows.h>
@ -51,7 +51,7 @@ namespace port {
# if defined(OS_WIN) && defined(COMPILER_MSVC) && defined(ARCH_CPU_X86_FAMILY)
# if defined(OS_WIN) && defined(COMPILER_MSVC) && defined(ARCH_CPU_X86_FAMILY)
// windows.h already provides a MemoryBarrier(void) macro
// windows.h already provides a MemoryBarrier(void) macro
// http://msdn.microsoft.com/en-us/library/ms684208(v=vs.85).aspx
// http://msdn.microsoft.com/en-us/library/ms684208(v=vs.85).aspx
# define LEVEL DB_HAVE_MEMORY_BARRIER
# define ROCKS DB_HAVE_MEMORY_BARRIER
// Gcc on x86
// Gcc on x86
# elif defined(ARCH_CPU_X86_FAMILY) && defined(__GNUC__)
# elif defined(ARCH_CPU_X86_FAMILY) && defined(__GNUC__)
@ -60,7 +60,7 @@ inline void MemoryBarrier() {
// this idiom. Also see http://en.wikipedia.org/wiki/Memory_ordering.
// this idiom. Also see http://en.wikipedia.org/wiki/Memory_ordering.
__asm__ __volatile__ ( " " : : : " memory " ) ;
__asm__ __volatile__ ( " " : : : " memory " ) ;
}
}
# define LEVEL DB_HAVE_MEMORY_BARRIER
# define ROCKS DB_HAVE_MEMORY_BARRIER
// Sun Studio
// Sun Studio
# elif defined(ARCH_CPU_X86_FAMILY) && defined(__SUNPRO_CC)
# elif defined(ARCH_CPU_X86_FAMILY) && defined(__SUNPRO_CC)
@ -69,14 +69,14 @@ inline void MemoryBarrier() {
// this idiom. Also see http://en.wikipedia.org/wiki/Memory_ordering.
// this idiom. Also see http://en.wikipedia.org/wiki/Memory_ordering.
asm volatile ( " " : : : " memory " ) ;
asm volatile ( " " : : : " memory " ) ;
}
}
# define LEVEL DB_HAVE_MEMORY_BARRIER
# define ROCKS DB_HAVE_MEMORY_BARRIER
// Mac OS
// Mac OS
# elif defined(OS_MACOSX)
# elif defined(OS_MACOSX)
inline void MemoryBarrier ( ) {
inline void MemoryBarrier ( ) {
OSMemoryBarrier ( ) ;
OSMemoryBarrier ( ) ;
}
}
# define LEVEL DB_HAVE_MEMORY_BARRIER
# define ROCKS DB_HAVE_MEMORY_BARRIER
// ARM Linux
// ARM Linux
# elif defined(ARCH_CPU_ARM_FAMILY) && defined(__linux__)
# elif defined(ARCH_CPU_ARM_FAMILY) && defined(__linux__)
@ -94,12 +94,12 @@ typedef void (*LinuxKernelMemoryBarrierFunc)(void);
inline void MemoryBarrier ( ) {
inline void MemoryBarrier ( ) {
( * ( LinuxKernelMemoryBarrierFunc ) 0xffff0fa0 ) ( ) ;
( * ( LinuxKernelMemoryBarrierFunc ) 0xffff0fa0 ) ( ) ;
}
}
# define LEVEL DB_HAVE_MEMORY_BARRIER
# define ROCKS DB_HAVE_MEMORY_BARRIER
# endif
# endif
// AtomicPointer built using platform-specific MemoryBarrier()
// AtomicPointer built using platform-specific MemoryBarrier()
# if defined(LEVEL DB_HAVE_MEMORY_BARRIER)
# if defined(ROCKS DB_HAVE_MEMORY_BARRIER)
class AtomicPointer {
class AtomicPointer {
private :
private :
void * rep_ ;
void * rep_ ;
@ -119,8 +119,8 @@ class AtomicPointer {
}
}
} ;
} ;
// AtomicPointer based on <cstd atomic>
// AtomicPointer based on <atomic>
# elif defined(LEVELDB_CSTD ATOMIC_PRESENT)
# elif defined(ROCKSDB_ ATOMIC_PRESENT)
class AtomicPointer {
class AtomicPointer {
private :
private :
std : : atomic < void * > rep_ ;
std : : atomic < void * > rep_ ;
@ -147,7 +147,7 @@ class AtomicPointer {
# endif
# endif
# undef LEVEL DB_HAVE_MEMORY_BARRIER
# undef ROCKS DB_HAVE_MEMORY_BARRIER
# undef ARCH_CPU_X86_FAMILY
# undef ARCH_CPU_X86_FAMILY
# undef ARCH_CPU_ARM_FAMILY
# undef ARCH_CPU_ARM_FAMILY