mirror of https://github.com/google/snappy.git
C++11 guarantees <cstddef> and <cstdint>.
The build configuration can be cleaned up a bit.
This commit is contained in:
parent
db082d2cd6
commit
7fefd231a1
|
@ -19,8 +19,6 @@ test_big_endian(SNAPPY_IS_BIG_ENDIAN)
|
|||
|
||||
include(CheckIncludeFile)
|
||||
check_include_file("byteswap.h" HAVE_BYTESWAP_H)
|
||||
check_include_file("stddef.h" HAVE_STDDEF_H)
|
||||
check_include_file("stdint.h" HAVE_STDINT_H)
|
||||
check_include_file("sys/endian.h" HAVE_SYS_ENDIAN_H)
|
||||
check_include_file("sys/mman.h" HAVE_SYS_MMAN_H)
|
||||
check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H)
|
||||
|
@ -90,15 +88,7 @@ configure_file(
|
|||
# We don't want to define HAVE_ macros in public headers. Instead, we use
|
||||
# CMake's variable substitution with 0/1 variables, which will be seen by the
|
||||
# preprocessor as constants.
|
||||
set(HAVE_STDINT_H_01 ${HAVE_STDINT_H})
|
||||
set(HAVE_STDDEF_H_01 ${HAVE_STDDEF_H})
|
||||
set(HAVE_SYS_UIO_H_01 ${HAVE_SYS_UIO_H})
|
||||
if(NOT HAVE_STDINT_H_01)
|
||||
set(HAVE_STDINT_H_01 0)
|
||||
endif(NOT HAVE_STDINT_H_01)
|
||||
if(NOT HAVE_STDDEF_H_01)
|
||||
set(HAVE_STDDEF_H_01 0)
|
||||
endif(NOT HAVE_STDDEF_H_01)
|
||||
if(NOT HAVE_SYS_UIO_H_01)
|
||||
set(HAVE_SYS_UIO_H_01 0)
|
||||
endif(NOT HAVE_SYS_UIO_H_01)
|
||||
|
|
|
@ -28,12 +28,6 @@
|
|||
/* Define to 1 if you have the `z' library (-lz). */
|
||||
#cmakedefine HAVE_LIBZ 1
|
||||
|
||||
/* Define to 1 if you have the <stddef.h> header file. */
|
||||
#cmakedefine HAVE_STDDEF_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#cmakedefine HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/endian.h> header file. */
|
||||
#cmakedefine HAVE_SYS_ENDIAN_H 1
|
||||
|
||||
|
|
|
@ -36,13 +36,9 @@
|
|||
#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
|
||||
#define THIRD_PARTY_SNAPPY_OPENSOURCE_SNAPPY_STUBS_PUBLIC_H_
|
||||
|
||||
#if ${HAVE_STDINT_H_01} // HAVE_STDINT_H
|
||||
#include <stdint.h>
|
||||
#endif // HAVE_STDDEF_H
|
||||
|
||||
#if ${HAVE_STDDEF_H_01} // HAVE_STDDEF_H
|
||||
#include <stddef.h>
|
||||
#endif // HAVE_STDDEF_H
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#if ${HAVE_SYS_UIO_H_01} // HAVE_SYS_UIO_H
|
||||
#include <sys/uio.h>
|
||||
|
@ -54,38 +50,25 @@
|
|||
#define SNAPPY_VERSION \
|
||||
((SNAPPY_MAJOR << 16) | (SNAPPY_MINOR << 8) | SNAPPY_PATCHLEVEL)
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace snappy {
|
||||
|
||||
#if ${HAVE_STDINT_H_01} // HAVE_STDINT_H
|
||||
typedef int8_t int8;
|
||||
typedef uint8_t uint8;
|
||||
typedef int16_t int16;
|
||||
typedef uint16_t uint16;
|
||||
typedef int32_t int32;
|
||||
typedef uint32_t uint32;
|
||||
typedef int64_t int64;
|
||||
typedef uint64_t uint64;
|
||||
#else
|
||||
typedef signed char int8;
|
||||
typedef unsigned char uint8;
|
||||
typedef short int16;
|
||||
typedef unsigned short uint16;
|
||||
typedef int int32;
|
||||
typedef unsigned int uint32;
|
||||
typedef long long int64;
|
||||
typedef unsigned long long uint64;
|
||||
#endif // HAVE_STDINT_H
|
||||
using int8 = std::int8_t;
|
||||
using uint8 = std::uint8_t;
|
||||
using int16 = std::int16_t;
|
||||
using uint16 = std::uint16_t;
|
||||
using int32 = std::int32_t;
|
||||
using uint32 = std::uint32_t;
|
||||
using int64 = std::int64_t;
|
||||
using uint64 = std::uint64_t;
|
||||
|
||||
typedef std::string string;
|
||||
using string = std::string;
|
||||
|
||||
#if !${HAVE_SYS_UIO_H_01} // !HAVE_SYS_UIO_H
|
||||
// Windows does not have an iovec type, yet the concept is universally useful.
|
||||
// It is simple to define it ourselves, so we put it inside our own namespace.
|
||||
struct iovec {
|
||||
void* iov_base;
|
||||
size_t iov_len;
|
||||
void* iov_base;
|
||||
size_t iov_len;
|
||||
};
|
||||
#endif // !HAVE_SYS_UIO_H
|
||||
|
||||
|
|
|
@ -55,8 +55,6 @@
|
|||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef HAVE_GTEST
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
|
|
@ -509,7 +509,7 @@ char* CompressFragment(const char* input,
|
|||
// "ip" is the input pointer, and "op" is the output pointer.
|
||||
const char* ip = input;
|
||||
assert(input_size <= kBlockSize);
|
||||
assert((table_size & (table_size - 1)) == 0); // table must be power of two
|
||||
assert((table_size & (table_size - 1)) == 0); // table must be power of two
|
||||
const int shift = 32 - Bits::Log2Floor(table_size);
|
||||
assert(static_cast<int>(kuint32max >> shift) == table_size - 1);
|
||||
const char* ip_end = input + input_size;
|
||||
|
@ -721,7 +721,7 @@ class SnappyDecompressor {
|
|||
}
|
||||
|
||||
// Read the uncompressed length stored at the start of the compressed data.
|
||||
// On succcess, stores the length in *result and returns true.
|
||||
// On success, stores the length in *result and returns true.
|
||||
// On failure, returns false.
|
||||
bool ReadUncompressedLength(uint32* result) {
|
||||
assert(ip_ == NULL); // Must not have read anything yet
|
||||
|
@ -1624,4 +1624,4 @@ bool Uncompress(Source* compressed, Sink* uncompressed) {
|
|||
}
|
||||
}
|
||||
|
||||
} // end namespace snappy
|
||||
} // namespace snappy
|
||||
|
|
Loading…
Reference in New Issue