diff --git a/Makefile b/Makefile index 0fb28f9aa..0027870cd 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ include build_config.mk WARNING_FLAGS = -Wall -Werror CFLAGS += -g $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CCFLAGS) $(OPT) -CXXFLAGS += -g $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) -std=gnu++0x -Woverloaded-virtual +CXXFLAGS += -g $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) -Woverloaded-virtual LDFLAGS += $(PLATFORM_LDFLAGS) diff --git a/build_tools/build_detect_platform b/build_tools/build_detect_platform index 2730cd078..073953dd4 100755 --- a/build_tools/build_detect_platform +++ b/build_tools/build_detect_platform @@ -37,12 +37,16 @@ if test -z "$OUTPUT"; then exit 1 fi +# we depend on C++11 +PLATFORM_CXXFLAGS="-std=gnu++11" +# we currently depend on POSIX platform +COMMON_FLAGS="-DROCKSDB_PLATFORM_POSIX" + # Default to fbcode gcc on internal fb machines if [ -d /mnt/gvfs/third-party -a -z "$CXX" ]; then FBCODE_BUILD="true" - PLATFORM_CXXFLAGS="-std=c++0x" if [ -z "$USE_CLANG" ]; then - source $PWD/build_tools/fbcode.gcc471.sh + source $PWD/build_tools/fbcode.gcc481.sh else source $PWD/build_tools/fbcode.clang31.sh fi @@ -65,10 +69,10 @@ if test -z "$TARGET_OS"; then TARGET_OS=`uname -s` fi -COMMON_FLAGS="${CFLAGS}" +COMMON_FLAGS="$COMMON_FLAGS ${CFLAGS}" CROSS_COMPILE= PLATFORM_CCFLAGS= -PLATFORM_CXXFLAGS="${CXXFLAGS}" +PLATFORM_CXXFLAGS="$PLATFORM_CXXFLAGS ${CXXFLAGS}" PLATFORM_LDFLAGS="$PLATFORM_LDFLAGS" PLATFORM_SHARED_EXT="so" PLATFORM_SHARED_LDFLAGS="${EXEC_LDFLAGS_SHARED} -shared -Wl,-soname -Wl," @@ -164,16 +168,13 @@ if [ "$CROSS_COMPILE" = "true" -o "$FBCODE_BUILD" = "true" ]; then # Also don't need any compilation tests if compiling on fbcode true else - # If -std=c++0x works, use . Otherwise use port_posix.h. + # If -std=c++0x works, use . Otherwise use port_posix.h. $CXX $CFLAGS -std=c++0x -x c++ - -o /dev/null 2>/dev/null < + #include int main() {} EOF if [ "$?" = 0 ]; then - COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX -DLEVELDB_CSTDATOMIC_PRESENT" - PLATFORM_CXXFLAGS="-std=c++0x" - else - COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX" + COMMON_FLAGS="$COMMON_FLAGS -DROCKSDB_ATOMIC_PRESENT" fi # Test whether Snappy library is installed diff --git a/build_tools/fbcode.gcc471.sh b/build_tools/fbcode.gcc471.sh index 2ffbe9bb5..846198312 100644 --- a/build_tools/fbcode.gcc471.sh +++ b/build_tools/fbcode.gcc471.sh @@ -49,7 +49,7 @@ RANLIB=$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/ranlib CFLAGS="-B$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/gold -m64 -mtune=generic -fPIC" CFLAGS+=" -I $TOOLCHAIN_LIB_BASE/jemalloc/$TOOL_JEMALLOC/include -DHAVE_JEMALLOC" -CFLAGS+=" -DLEVELDB_PLATFORM_POSIX" +CFLAGS+=" -DROCKSDB_PLATFORM_POSIX -DROCKSDB_ATOMIC_PRESENT" CFLAGS+=" -DSNAPPY -DGFLAGS -DZLIB -DBZIP2" EXEC_LDFLAGS=" -Wl,--whole-archive $TOOLCHAIN_LIB_BASE/jemalloc/$TOOL_JEMALLOC/lib/libjemalloc.a" diff --git a/build_tools/fbcode.gcc481.sh b/build_tools/fbcode.gcc481.sh index e6663e93f..c72e05d8b 100644 --- a/build_tools/fbcode.gcc481.sh +++ b/build_tools/fbcode.gcc481.sh @@ -5,7 +5,12 @@ # uses jemalloc TOOLCHAIN_REV=53dc1fe83f84e9145b9ffb81b81aa7f6a49c87cc -TOOLCHAIN_EXECUTABLES="/mnt/gvfs/third-party/$TOOLCHAIN_REV/centos6-native" +CENTOS_VERSION=`rpm -q --qf "%{VERSION}" $(rpm -q --whatprovides redhat-release)` +if [ "$CENTOS_VERSION" = "6" ]; then + TOOLCHAIN_EXECUTABLES="/mnt/gvfs/third-party/$TOOLCHAIN_REV/centos6-native" +else + TOOLCHAIN_EXECUTABLES="/mnt/gvfs/third-party/$TOOLCHAIN_REV/centos5.2-native" +fi TOOLCHAIN_LIB_BASE="/mnt/gvfs/third-party/$TOOLCHAIN_REV/gcc-4.8.1-glibc-2.17" TOOL_JEMALLOC=jemalloc-3.3.1/4d53c6f @@ -49,7 +54,7 @@ RANLIB=$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/ranlib CFLAGS="-B$TOOLCHAIN_EXECUTABLES/binutils/binutils-2.21.1/da39a3e/bin/gold -m64 -mtune=generic -fPIC" CFLAGS+=" -I $TOOLCHAIN_LIB_BASE/jemalloc/$TOOL_JEMALLOC/include -DHAVE_JEMALLOC -nostdlib" -CFLAGS+=" -DLEVELDB_PLATFORM_POSIX" +CFLAGS+=" -DROCKSDB_PLATFORM_POSIX -DROCKSDB_ATOMIC_PRESENT" CFLAGS+=" -DSNAPPY -DGFLAGS -DZLIB -DBZIP2" EXEC_LDFLAGS="-Wl,--dynamic-linker,/usr/local/fbcode/gcc-4.8.1-glibc-2.17/lib/ld.so" diff --git a/port/atomic_pointer.h b/port/atomic_pointer.h index 2527ff977..db3580bde 100644 --- a/port/atomic_pointer.h +++ b/port/atomic_pointer.h @@ -25,8 +25,8 @@ #define PORT_ATOMIC_POINTER_H_ #include -#ifdef LEVELDB_CSTDATOMIC_PRESENT -#include +#ifdef ROCKSDB_ATOMIC_PRESENT +#include #endif #ifdef OS_WIN #include @@ -51,7 +51,7 @@ namespace port { #if defined(OS_WIN) && defined(COMPILER_MSVC) && defined(ARCH_CPU_X86_FAMILY) // windows.h already provides a MemoryBarrier(void) macro // http://msdn.microsoft.com/en-us/library/ms684208(v=vs.85).aspx -#define LEVELDB_HAVE_MEMORY_BARRIER +#define ROCKSDB_HAVE_MEMORY_BARRIER // Gcc on x86 #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. __asm__ __volatile__("" : : : "memory"); } -#define LEVELDB_HAVE_MEMORY_BARRIER +#define ROCKSDB_HAVE_MEMORY_BARRIER // Sun Studio #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. asm volatile("" : : : "memory"); } -#define LEVELDB_HAVE_MEMORY_BARRIER +#define ROCKSDB_HAVE_MEMORY_BARRIER // Mac OS #elif defined(OS_MACOSX) inline void MemoryBarrier() { OSMemoryBarrier(); } -#define LEVELDB_HAVE_MEMORY_BARRIER +#define ROCKSDB_HAVE_MEMORY_BARRIER // ARM Linux #elif defined(ARCH_CPU_ARM_FAMILY) && defined(__linux__) @@ -94,12 +94,12 @@ typedef void (*LinuxKernelMemoryBarrierFunc)(void); inline void MemoryBarrier() { (*(LinuxKernelMemoryBarrierFunc)0xffff0fa0)(); } -#define LEVELDB_HAVE_MEMORY_BARRIER +#define ROCKSDB_HAVE_MEMORY_BARRIER #endif // AtomicPointer built using platform-specific MemoryBarrier() -#if defined(LEVELDB_HAVE_MEMORY_BARRIER) +#if defined(ROCKSDB_HAVE_MEMORY_BARRIER) class AtomicPointer { private: void* rep_; @@ -119,8 +119,8 @@ class AtomicPointer { } }; -// AtomicPointer based on -#elif defined(LEVELDB_CSTDATOMIC_PRESENT) +// AtomicPointer based on +#elif defined(ROCKSDB_ATOMIC_PRESENT) class AtomicPointer { private: std::atomic rep_; @@ -147,7 +147,7 @@ class AtomicPointer { #endif -#undef LEVELDB_HAVE_MEMORY_BARRIER +#undef ROCKSDB_HAVE_MEMORY_BARRIER #undef ARCH_CPU_X86_FAMILY #undef ARCH_CPU_ARM_FAMILY diff --git a/port/port.h b/port/port.h index 53a581621..2dc9a0fa6 100644 --- a/port/port.h +++ b/port/port.h @@ -15,10 +15,8 @@ // Include the appropriate platform specific file below. If you are // porting to a new platform, see "port_example.h" for documentation // of what the new port_.h file must provide. -#if defined(LEVELDB_PLATFORM_POSIX) +#if defined(ROCKSDB_PLATFORM_POSIX) # include "port/port_posix.h" -#elif defined(LEVELDB_PLATFORM_CHROMIUM) -# include "port/port_chromium.h" #endif #endif // STORAGE_LEVELDB_PORT_PORT_H_ diff --git a/util/blob_store_test.cc b/util/blob_store_test.cc index bc4900795..f199f5ddd 100644 --- a/util/blob_store_test.cc +++ b/util/blob_store_test.cc @@ -144,7 +144,7 @@ TEST(BlobStoreTest, CreateAndStoreTest) { Env::Default()); vector> ranges; - for (int i = 0; i < 20000; ++i) { + for (int i = 0; i < 2000; ++i) { int decision = rand() % 5; if (decision <= 2 || ranges.size() == 0) { string buf;