mirror of
https://github.com/google/leveldb.git
synced 2025-03-28 12:10:08 +08:00
Switch HAVE_ library detection macros to 0/1.
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=188488298
This commit is contained in:
parent
41172a2401
commit
8c8024ea33
@ -200,6 +200,8 @@ EOF
|
|||||||
if [ "$?" = 0 ]; then
|
if [ "$?" = 0 ]; then
|
||||||
COMMON_FLAGS="$COMMON_FLAGS -DHAVE_CRC32C=1"
|
COMMON_FLAGS="$COMMON_FLAGS -DHAVE_CRC32C=1"
|
||||||
PLATFORM_LIBS="$PLATFORM_LIBS -lcrc32c"
|
PLATFORM_LIBS="$PLATFORM_LIBS -lcrc32c"
|
||||||
|
else
|
||||||
|
COMMON_FLAGS="$COMMON_FLAGS -DHAVE_CRC32C=0"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test whether Snappy library is installed
|
# Test whether Snappy library is installed
|
||||||
@ -211,6 +213,8 @@ EOF
|
|||||||
if [ "$?" = 0 ]; then
|
if [ "$?" = 0 ]; then
|
||||||
COMMON_FLAGS="$COMMON_FLAGS -DHAVE_SNAPPY=1"
|
COMMON_FLAGS="$COMMON_FLAGS -DHAVE_SNAPPY=1"
|
||||||
PLATFORM_LIBS="$PLATFORM_LIBS -lsnappy"
|
PLATFORM_LIBS="$PLATFORM_LIBS -lsnappy"
|
||||||
|
else
|
||||||
|
COMMON_FLAGS="$COMMON_FLAGS -DHAVE_SNAPPY=0"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test whether tcmalloc is available
|
# Test whether tcmalloc is available
|
||||||
|
@ -39,12 +39,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#if defined(HAVE_CRC32C)
|
#if HAVE_CRC32C
|
||||||
#include <crc32c/crc32c.h>
|
#include <crc32c/crc32c.h>
|
||||||
#endif // defined(HAVE_CRC32C)
|
#endif // HAVE_CRC32C
|
||||||
#ifdef HAVE_SNAPPY
|
#if HAVE_SNAPPY
|
||||||
#include <snappy.h>
|
#include <snappy.h>
|
||||||
#endif // defined(HAVE_SNAPPY)
|
#endif // HAVE_SNAPPY
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "port/atomic_pointer.h"
|
#include "port/atomic_pointer.h"
|
||||||
@ -110,33 +110,33 @@ extern void InitOnce(OnceType* once, void (*initializer)());
|
|||||||
|
|
||||||
inline bool Snappy_Compress(const char* input, size_t length,
|
inline bool Snappy_Compress(const char* input, size_t length,
|
||||||
::std::string* output) {
|
::std::string* output) {
|
||||||
#ifdef HAVE_SNAPPY
|
#if HAVE_SNAPPY
|
||||||
output->resize(snappy::MaxCompressedLength(length));
|
output->resize(snappy::MaxCompressedLength(length));
|
||||||
size_t outlen;
|
size_t outlen;
|
||||||
snappy::RawCompress(input, length, &(*output)[0], &outlen);
|
snappy::RawCompress(input, length, &(*output)[0], &outlen);
|
||||||
output->resize(outlen);
|
output->resize(outlen);
|
||||||
return true;
|
return true;
|
||||||
#endif // defined(HAVE_SNAPPY)
|
#endif // HAVE_SNAPPY
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Snappy_GetUncompressedLength(const char* input, size_t length,
|
inline bool Snappy_GetUncompressedLength(const char* input, size_t length,
|
||||||
size_t* result) {
|
size_t* result) {
|
||||||
#ifdef HAVE_SNAPPY
|
#if HAVE_SNAPPY
|
||||||
return snappy::GetUncompressedLength(input, length, result);
|
return snappy::GetUncompressedLength(input, length, result);
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif // defined(HAVE_SNAPPY)
|
#endif // HAVE_SNAPPY
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Snappy_Uncompress(const char* input, size_t length,
|
inline bool Snappy_Uncompress(const char* input, size_t length,
|
||||||
char* output) {
|
char* output) {
|
||||||
#ifdef HAVE_SNAPPY
|
#if HAVE_SNAPPY
|
||||||
return snappy::RawUncompress(input, length, output);
|
return snappy::RawUncompress(input, length, output);
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif // defined(HAVE_SNAPPY)
|
#endif // HAVE_SNAPPY
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) {
|
inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) {
|
||||||
@ -144,11 +144,11 @@ inline bool GetHeapProfile(void (*func)(void*, const char*, int), void* arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline uint32_t AcceleratedCRC32C(uint32_t crc, const char* buf, size_t size) {
|
inline uint32_t AcceleratedCRC32C(uint32_t crc, const char* buf, size_t size) {
|
||||||
#if defined(HAVE_CRC32C)
|
#if HAVE_CRC32C
|
||||||
return ::crc32c::Extend(crc, reinterpret_cast<const uint8_t*>(buf), size);
|
return ::crc32c::Extend(crc, reinterpret_cast<const uint8_t*>(buf), size);
|
||||||
#else
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
#endif // defined(HAVE_CRC32C)
|
#endif // HAVE_CRC32C
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace port
|
} // namespace port
|
||||||
|
Loading…
Reference in New Issue
Block a user