C++11 guarantees <cstddef> and <cstdint>.

The build configuration can be cleaned up a bit.
This commit is contained in:
costan 2018-08-16 10:44:34 -07:00 committed by Victor Costan
parent db082d2cd6
commit 7fefd231a1
6 changed files with 18 additions and 53 deletions

View File

@ -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)

View File

@ -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

View File

@ -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,31 +50,18 @@
#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.

View File

@ -55,8 +55,6 @@
#include <windows.h>
#endif
#include <string>
#ifdef HAVE_GTEST
#include <gtest/gtest.h>

View File

@ -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

View File

@ -39,7 +39,7 @@
#ifndef THIRD_PARTY_SNAPPY_SNAPPY_H__
#define THIRD_PARTY_SNAPPY_SNAPPY_H__
#include <stddef.h>
#include <cstddef>
#include <string>
#include "snappy-stubs-public.h"