From 77c12adc192ac6620a0f0d340c99149ec56a97a3 Mon Sep 17 00:00:00 2001 From: costan Date: Wed, 2 Aug 2017 09:43:03 -0700 Subject: [PATCH] Add unistd.h checks back to the CMake build. getpagesize(), as well as its POSIX.2001 replacement sysconf(_SC_PAGESIZE), is defined in . On Linux and OS X, including is sufficient to get a definition for getpagesize(). However, this is not true for the Android NDK. This CL brings back the HAVE_UNISTD_H definition and its associated header check. This also adds a HAVE_FUNC_SYSCONF definition, which checks for the presence of sysconf(). The definition can be used later to replace getpagesize() with sysconf(). --- CMakeLists.txt | 2 ++ cmake/config.h.in | 6 ++++++ snappy-stubs-internal.h | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 11c7b00..e9e70c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ check_include_file("sys/mman.h" HAVE_SYS_MMAN_H) check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H) check_include_file("sys/time.h" HAVE_SYS_TIME_H) check_include_file("sys/uio.h" HAVE_SYS_UIO_H) +check_include_file("unistd.h" HAVE_UNISTD_H) check_include_file("windows.h" HAVE_WINDOWS_H) include(CheckLibraryExists) @@ -37,6 +38,7 @@ check_cxx_source_compiles( include(CheckSymbolExists) check_symbol_exists("mmap" "sys/mman.h" HAVE_FUNC_MMAP) +check_symbol_exists("sysconf" "unistd.h" HAVE_FUNC_SYSCONF) find_package(GTest QUIET) if(GTEST_FOUND) diff --git a/cmake/config.h.in b/cmake/config.h.in index a14c7ad..64f2648 100644 --- a/cmake/config.h.in +++ b/cmake/config.h.in @@ -13,6 +13,9 @@ /* Define to 1 if you have a definition for mmap() in . */ #cmakedefine HAVE_FUNC_MMAP 1 +/* Define to 1 if you have a definition for sysconf() in . */ +#cmakedefine HAVE_FUNC_SYSCONF 1 + /* Define to 1 to use the gflags package for command-line parsing. */ #cmakedefine HAVE_GFLAGS 1 @@ -46,6 +49,9 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYS_UIO_H 1 +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H 1 + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_WINDOWS_H 1 diff --git a/snappy-stubs-internal.h b/snappy-stubs-internal.h index 841e4a0..9898f18 100644 --- a/snappy-stubs-internal.h +++ b/snappy-stubs-internal.h @@ -45,6 +45,10 @@ #include #endif +#ifdef HAVE_UNISTD_H +#include +#endif + #if defined(_MSC_VER) #include #endif // defined(_MSC_VER)