summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcostan <costan@google.com>2017-07-25 14:45:04 -0700
committerVictor Costan <pwnall@chromium.org>2017-07-25 18:17:35 -0700
commit27671c6aec6886f394a46dda2d345043a9b5f62a (patch)
treee2a2c2e61aaa5995df5dceca4f837bc7f88e7604
parent548501c98860bbe46e0eeda53942be67c7decef1 (diff)
downloadsnappy-27671c6aec6886f394a46dda2d345043a9b5f62a.tar.gz
snappy-27671c6aec6886f394a46dda2d345043a9b5f62a.tar.bz2
snappy-27671c6aec6886f394a46dda2d345043a9b5f62a.zip
Clean up CMake header and type checks.
Unused macros: HAVE_DLFCN_H, HAVE_INTTYPES_H, HAVE_MEMORY_H, HAVE_STDLIB_H, HAVE_STRINGS_H, HAVE_STRING_H, HAVE_SYS_BYTESWAP_H, HAVE_SYS_STAT_H, HAVE_SYS_TYPES_H, HAVE_UNISTD_H. Used but never set macros: HAVE_LIBLZF, HAVE_LIBQUICKLZ. These only gate conditional includes. The code that takes advantage of them was removed. Unused types: ssize_t. The testing code uses HAVE_FUNC_MMAP, which was not wired in the CMake build, causing a whole test to be skipped.
-rw-r--r--CMakeLists.txt21
-rw-r--r--cmake/config.h.in82
-rw-r--r--snappy-test.h10
3 files changed, 27 insertions, 86 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index de52666..e858493 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,6 +6,7 @@ SET(CMAKE_INCLUDE_CURRENT_DIR ON)
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckLibraryExists)
INCLUDE(CheckCXXSourceCompiles)
+INCLUDE(CheckSymbolExists)
INCLUDE(TestBigEndian)
INCLUDE(CMakePackageConfigHelpers)
@@ -16,23 +17,13 @@ IF (WORDS_BIG_ENDIAN)
ENDIF (WORDS_BIG_ENDIAN)
CHECK_INCLUDE_FILES("byteswap.h" HAVE_BYTESWAP_H)
-CHECK_INCLUDE_FILES("dlfcn.h" HAVE_DLFCN_H)
-CHECK_INCLUDE_FILES("inttypes.h" HAVE_INTTYPES_H)
-CHECK_INCLUDE_FILES("memory.h" HAVE_MEMORY_H)
CHECK_INCLUDE_FILES("stddef.h" HAVE_STDDEF_H)
CHECK_INCLUDE_FILES("stdint.h" HAVE_STDINT_H)
-CHECK_INCLUDE_FILES("stdlib.h" HAVE_STDLIB_H)
-CHECK_INCLUDE_FILES("strings.h" HAVE_STRINGS_H)
-CHECK_INCLUDE_FILES("string.h" HAVE_STRING_H)
-CHECK_INCLUDE_FILES("sys/byteswap.h" HAVE_SYS_BYTESWAP_H)
CHECK_INCLUDE_FILES("sys/endian.h" HAVE_SYS_ENDIAN_H)
CHECK_INCLUDE_FILES("sys/mman.h" HAVE_SYS_MMAN_H)
CHECK_INCLUDE_FILES("sys/resource.h" HAVE_SYS_RESOURCE_H)
-CHECK_INCLUDE_FILES("sys/stat.h" HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILES("sys/time.h" HAVE_SYS_TIME_H)
-CHECK_INCLUDE_FILES("sys/types.h" HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES("sys/uio.h" HAVE_SYS_UIO_H)
-CHECK_INCLUDE_FILES("unistd.h" HAVE_UNISTD_H)
CHECK_INCLUDE_FILES("windows.h" HAVE_WINDOWS_H)
IF (NOT HAVE_SYS_UIO_H)
@@ -50,6 +41,8 @@ ENDIF (NOT HAVE_STDDEF_H)
CHECK_LIBRARY_EXISTS(z zlibVersion "" HAVE_LIBZ)
CHECK_LIBRARY_EXISTS(lzo2 lzo1x_1_15_compress "" HAVE_LIBLZO2)
+CHECK_SYMBOL_EXISTS(mmap sys/mman.h HAVE_FUNC_MMAP)
+
CHECK_CXX_SOURCE_COMPILES("int main(void) { return __builtin_expect(0, 1); }"
HAVE_BUILTIN_EXPECT)
@@ -136,14 +129,6 @@ IF (HAVE_LIBLZO2)
LIST(APPEND COMPRESSION_LIBS lzo2)
ENDIF (HAVE_LIBLZO2)
-IF (HAVE_LIBLZF)
- LIST(APPEND COMPRESSION_LIBS lzf)
-ENDIF (HAVE_LIBLZF)
-
-IF (HAVE_LIBQUICKLZ)
- LIST(APPEND COMPRESSION_LIBS quicklz)
-ENDIF (HAVE_LIBQUICKLZ)
-
ADD_EXECUTABLE(snappy-unittest snappy_unittest.cc snappy-test.cc)
TARGET_COMPILE_DEFINITIONS(snappy-unittest PRIVATE -DHAVE_CONFIG_H)
TARGET_LINK_LIBRARIES(snappy-unittest snappy ${COMPRESSION_LIBS}
diff --git a/cmake/config.h.in b/cmake/config.h.in
index c06e3ad..a14c7ad 100644
--- a/cmake/config.h.in
+++ b/cmake/config.h.in
@@ -1,90 +1,56 @@
-#ifndef SNAPPY_CONFIG_H
-#define SNAPPY_CONFIG_H 1
+#ifndef THIRD_PARTY_SNAPPY_OPENSOURCE_CMAKE_CONFIG_H_
+#define THIRD_PARTY_SNAPPY_OPENSOURCE_CMAKE_CONFIG_H_
/* Define to 1 if the compiler supports __builtin_ctz and friends. */
-#cmakedefine HAVE_BUILTIN_CTZ ${HAVE_BUILTIN_CTZ}
+#cmakedefine HAVE_BUILTIN_CTZ 1
/* Define to 1 if the compiler supports __builtin_expect. */
-#cmakedefine HAVE_BUILTIN_EXPECT ${HAVE_BUILTIN_EXPECT}
+#cmakedefine HAVE_BUILTIN_EXPECT 1
/* Define to 1 if you have the <byteswap.h> header file. */
-#cmakedefine HAVE_BYTESWAP_H ${HAVE_BYTESWAP_H}
+#cmakedefine HAVE_BYTESWAP_H 1
-/* Define to 1 if you have the <dlfcn.h> header file. */
-#cmakedefine HAVE_DLFCN_H ${HAVE_DLFCN_H}
+/* Define to 1 if you have a definition for mmap() in <sys/mman.h>. */
+#cmakedefine HAVE_FUNC_MMAP 1
-/* Use the gflags package for command-line parsing. */
-#cmakedefine HAVE_GFLAGS ${HAVE_GFLAGS}
+/* Define to 1 to use the gflags package for command-line parsing. */
+#cmakedefine HAVE_GFLAGS 1
-/* Defined when Google Test is available. */
-#cmakedefine HAVE_GTEST ${HAVE_GTEST}
-
-/* Define to 1 if you have the <inttypes.h> header file. */
-#cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H}
+/* Define to 1 if you have Google Test. */
+#cmakedefine HAVE_GTEST 1
/* Define to 1 if you have the `lzo2' library (-llzo2). */
-#cmakedefine HAVE_LIBLZO2 ${HAVE_LIBLZO2}
+#cmakedefine HAVE_LIBLZO2 1
/* Define to 1 if you have the `z' library (-lz). */
-#cmakedefine HAVE_LIBZ ${HAVE_LIBZ}
-
-/* Define to 1 if you have the <sys/uio.h> header file. */
-#cmakedefine HAVE_SYS_UIO_H ${HAVE_SYS_UIO_H}
-
-/* Define to 1 if you have the <memory.h> header file. */
-#cmakedefine HAVE_MEMORY_H ${HAVE_MEMORY_H}
+#cmakedefine HAVE_LIBZ 1
/* Define to 1 if you have the <stddef.h> header file. */
-#cmakedefine HAVE_STDDEF_H ${HAVE_STDDEF_H}
+#cmakedefine HAVE_STDDEF_H 1
/* Define to 1 if you have the <stdint.h> header file. */
-#cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H}
-
-/* Define to 1 if you have the <stdlib.h> header file. */
-#cmakedefine HAVE_STDLIB_H ${HAVE_STDLIB_H}
-
-/* Define to 1 if you have the <strings.h> header file. */
-#cmakedefine HAVE_STRINGS_H ${HAVE_STRINGS_H}
-
-/* Define to 1 if you have the <string.h> header file. */
-#cmakedefine HAVE_STRING_H ${HAVE_STRING_H}
-
-/* Define to 1 if you have the <sys/byteswap.h> header file. */
-#cmakedefine HAVE_SYS_BYTESWAP_H ${HAVE_SYS_BYTESWAP_H}
+#cmakedefine HAVE_STDINT_H 1
/* Define to 1 if you have the <sys/endian.h> header file. */
-#cmakedefine HAVE_SYS_ENDIAN_H ${HAVE_SYS_ENDIAN_H}
+#cmakedefine HAVE_SYS_ENDIAN_H 1
/* Define to 1 if you have the <sys/mman.h> header file. */
-#cmakedefine HAVE_SYS_MMAN_H ${HAVE_SYS_MMAN_H}
+#cmakedefine HAVE_SYS_MMAN_H 1
/* Define to 1 if you have the <sys/resource.h> header file. */
-#cmakedefine HAVE_SYS_RESOURCE_H ${HAVE_SYS_RESOURCE_H}
-
-/* Define to 1 if you have the <sys/stat.h> header file. */
-#cmakedefine HAVE_SYS_STAT_H ${HAVE_SYS_STAT_H}
+#cmakedefine HAVE_SYS_RESOURCE_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
-#cmakedefine HAVE_SYS_TIME_H ${HAVE_SYS_TIME_H}
-
-/* Define to 1 if you have the <sys/types.h> header file. */
-#cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES}
+#cmakedefine HAVE_SYS_TIME_H 1
-/* Define to 1 if you have the <unistd.h> header file. */
-#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H}
+/* Define to 1 if you have the <sys/uio.h> header file. */
+#cmakedefine HAVE_SYS_UIO_H 1
/* Define to 1 if you have the <windows.h> header file. */
-#cmakedefine HAVE_WINDOWS_H ${HAVE_WINDOWS_H}
-
-/* Define to 1 if you have the ANSI C header files. */
-#define STDC_HEADERS 1
+#cmakedefine HAVE_WINDOWS_H 1
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel and VAX). */
-#cmakedefine WORDS_BIGENDIAN
-
-#if defined(_MSC_VER) && (_MSC_VER <= 1900)
-typedef __int64 ssize_t;
-#endif
+#cmakedefine WORDS_BIGENDIAN 1
-#endif
+#endif // THIRD_PARTY_SNAPPY_OPENSOURCE_CMAKE_CONFIG_H_
diff --git a/snappy-test.h b/snappy-test.h
index cebb4ee..04454df 100644
--- a/snappy-test.h
+++ b/snappy-test.h
@@ -110,16 +110,6 @@
#include "lzo/lzo1x.h"
#endif
-#ifdef HAVE_LIBLZF
-extern "C" {
-#include "lzf.h"
-}
-#endif
-
-#ifdef HAVE_LIBQUICKLZ
-#include "quicklz.h"
-#endif
-
namespace {
namespace file {