Browse Source

leveldb: Rename SNAPPY to HAVE_SNAPPY.

This follows the general naming convention for preprocessor macros used
to detect feature (library / header file / symbol) presence.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=171184641
xry
costan 7 years ago
committed by Victor Costan
parent
commit
ca216e493f
2 changed files with 14 additions and 14 deletions
  1. +6
    -6
      build_detect_platform
  2. +8
    -8
      port/port_posix.h

+ 6
- 6
build_detect_platform View File

@ -21,8 +21,8 @@
# The PLATFORM_CCFLAGS and PLATFORM_CXXFLAGS might include the following:
#
# -DLEVELDB_ATOMIC_PRESENT if <atomic> 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

+ 8
- 8
port/port_posix.h View File

@ -39,9 +39,9 @@
#endif
#include <pthread.h>
#ifdef SNAPPY
#ifdef HAVE_SNAPPY
#include <snappy.h>
#endif
#endif // defined(HAVE_SNAPPY)
#include <stdint.h>
#include <string>
#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) {

Loading…
Cancel
Save