diff --git a/build_detect_platform b/build_detect_platform index 997730c..d1bb17e 100755 --- a/build_detect_platform +++ b/build_detect_platform @@ -21,8 +21,8 @@ # The PLATFORM_CCFLAGS and PLATFORM_CXXFLAGS might include the following: # # -DLEVELDB_ATOMIC_PRESENT if is present -# -DLEVELDB_PLATFORM_POSIX for Posix-based platforms -# -DSNAPPY if the Snappy library is present +# -DLEVELDB_PLATFORM_POSIX=1 for Posix-based platforms +# -DHAVE_SNAPPY=1 if the Snappy library is present # OUTPUT=$1 @@ -133,7 +133,7 @@ case "$TARGET_OS" in ;; OS_ANDROID_CROSSCOMPILE) PLATFORM=OS_ANDROID - COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_ANDROID -DLEVELDB_PLATFORM_POSIX" + COMMON_FLAGS="$MEMCMP_FLAG -D_REENTRANT -DOS_ANDROID -DLEVELDB_PLATFORM_POSIX=1" PLATFORM_LDFLAGS="" # All pthread features are in the Android C library PORT_FILE=port/port_posix.cc PORT_SSE_FILE=port/port_posix_sse.cc @@ -196,10 +196,10 @@ else int main() {} EOF if [ "$?" = 0 ]; then - COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX -DLEVELDB_ATOMIC_PRESENT" + COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX=1 -DLEVELDB_ATOMIC_PRESENT" PLATFORM_CXXFLAGS="-std=c++0x" else - COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX" + COMMON_FLAGS="$COMMON_FLAGS -DLEVELDB_PLATFORM_POSIX=1" fi # Test whether Snappy library is installed @@ -209,7 +209,7 @@ EOF int main() {} EOF if [ "$?" = 0 ]; then - COMMON_FLAGS="$COMMON_FLAGS -DSNAPPY" + COMMON_FLAGS="$COMMON_FLAGS -DHAVE_SNAPPY=1" PLATFORM_LIBS="$PLATFORM_LIBS -lsnappy" fi diff --git a/port/port_posix.h b/port/port_posix.h index 1f4f6fc..2bc5223 100644 --- a/port/port_posix.h +++ b/port/port_posix.h @@ -39,9 +39,9 @@ #endif #include -#ifdef SNAPPY +#ifdef HAVE_SNAPPY #include -#endif +#endif // defined(HAVE_SNAPPY) #include #include #include "port/atomic_pointer.h" @@ -106,33 +106,33 @@ extern void InitOnce(OnceType* once, void (*initializer)()); inline bool Snappy_Compress(const char* input, size_t length, ::std::string* output) { -#ifdef SNAPPY +#ifdef HAVE_SNAPPY output->resize(snappy::MaxCompressedLength(length)); size_t outlen; snappy::RawCompress(input, length, &(*output)[0], &outlen); output->resize(outlen); return true; -#endif +#endif // defined(HAVE_SNAPPY) return false; } inline bool Snappy_GetUncompressedLength(const char* input, size_t length, size_t* result) { -#ifdef SNAPPY +#ifdef HAVE_SNAPPY return snappy::GetUncompressedLength(input, length, result); #else return false; -#endif +#endif // defined(HAVE_SNAPPY) } inline bool Snappy_Uncompress(const char* input, size_t length, char* output) { -#ifdef SNAPPY +#ifdef HAVE_SNAPPY return snappy::RawUncompress(input, length, output); #else return false; -#endif +#endif // defined(HAVE_SNAPPY) } inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) {