From b866e72826fdd4b7b6a697b10dfd825b3ba10a79 Mon Sep 17 00:00:00 2001 From: Przemyslaw Skibinski Date: Fri, 16 Dec 2016 14:24:01 +0100 Subject: [PATCH] tools use platform.h --- programs/bench.c | 3 ++- programs/dibio.c | 3 ++- programs/fileio.c | 3 ++- programs/platform.h | 13 ++++++++++++- programs/zstdcli.c | 3 ++- tests/datagencli.c | 2 +- tests/fullbench.c | 3 ++- tests/paramgrill.c | 3 ++- zlibWrapper/examples/zwrapbench.c | 3 ++- 9 files changed, 27 insertions(+), 9 deletions(-) diff --git a/programs/bench.c b/programs/bench.c index 9104ea89c..f58f3e5c5 100644 --- a/programs/bench.c +++ b/programs/bench.c @@ -11,7 +11,8 @@ /* ************************************* * Includes ***************************************/ -#include "util.h" /* Compiler options, UTIL_GetFileSize, UTIL_sleep */ +#include "platform.h" /* Compiler options */ +#include "util.h" /* UTIL_GetFileSize, UTIL_sleep */ #include /* malloc, free */ #include /* memset */ #include /* fprintf, fopen, ftello64 */ diff --git a/programs/dibio.c b/programs/dibio.c index a793669cb..74dc54055 100644 --- a/programs/dibio.c +++ b/programs/dibio.c @@ -12,7 +12,8 @@ /*-************************************* * Includes ***************************************/ -#include "util.h" /* Compiler options, UTIL_GetFileSize, UTIL_getTotalFileSize */ +#include "platform.h" /* Compiler options */ +#include "util.h" /* UTIL_GetFileSize, UTIL_getTotalFileSize */ #include /* malloc, free */ #include /* memset */ #include /* fprintf, fopen, ftello64 */ diff --git a/programs/fileio.c b/programs/fileio.c index a493e97c5..2ff5947f4 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -22,7 +22,8 @@ /*-************************************* * Includes ***************************************/ -#include "util.h" /* Compiler options, UTIL_GetFileSize, _LARGEFILE64_SOURCE */ +#include "platform.h" /* Compiler options */ +#include "util.h" /* UTIL_GetFileSize, _LARGEFILE64_SOURCE */ #include /* fprintf, fopen, fread, _fileno, stdin, stdout */ #include /* malloc, free */ #include /* strcmp, strlen */ diff --git a/programs/platform.h b/programs/platform.h index 978db1db4..095e52b84 100644 --- a/programs/platform.h +++ b/programs/platform.h @@ -30,7 +30,9 @@ extern "C" { #endif -/* Unix Large Files support (>4GB) */ +/* ************************************** +* Unix Large Files support (>4GB) +****************************************/ #if !defined(__LP64__) /* No point defining Large file for 64 bit */ # define _FILE_OFFSET_BITS 64 /* turn off_t into a 64-bit type for ftello, fseeko */ # if defined(__sun__) && !defined(_LARGEFILE_SOURCE) /* Sun Solaris 32-bits requires specific definitions */ @@ -41,6 +43,12 @@ extern "C" { #endif +/* *********************************************************** +* Detect POSIX version +* PLATFORM_POSIX_VERSION = 0 for non-Unix e.g. Windows +* PLATFORM_POSIX_VERSION = 1 for Unix-like +* PLATFORM_POSIX_VERSION > 1 is equal to found _POSIX_VERSION +**************************************************************/ #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)) || defined(__midipix__)) /* UNIX-style OS. ------------------------------------------- */ # if (defined(__APPLE__) && defined(__MACH__) || defined(__SVR4) || defined(_AIX) || defined(__hpux) \ @@ -53,6 +61,8 @@ extern "C" { # include /* declares _POSIX_VERSION */ # if defined(_POSIX_VERSION) /* POSIX compliant */ # define PLATFORM_POSIX_VERSION _POSIX_VERSION +# else +# define PLATFORM_POSIX_VERSION 1 # endif # endif #endif @@ -62,6 +72,7 @@ extern "C" { #endif + #if defined (__cplusplus) } #endif diff --git a/programs/zstdcli.c b/programs/zstdcli.c index 561730a5f..fa2956ca4 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -23,7 +23,8 @@ /*-************************************ * Dependencies **************************************/ -#include "util.h" /* Compiler options, UTIL_HAS_CREATEFILELIST */ +#include "platform.h" /* Compiler options, PLATFORM_POSIX_VERSION */ +#include "util.h" /* UTIL_HAS_CREATEFILELIST, UTIL_createFileList */ #include /* strcmp, strlen */ #include /* errno */ #include "fileio.h" diff --git a/tests/datagencli.c b/tests/datagencli.c index 2f3ebc4d6..0729cdd0c 100644 --- a/tests/datagencli.c +++ b/tests/datagencli.c @@ -11,7 +11,7 @@ /*-************************************ * Dependencies **************************************/ -#include "util.h" /* Compiler options */ +#include "platform.h" /* Compiler options */ #include /* fprintf, stderr */ #include "datagen.h" /* RDG_generate */ diff --git a/tests/fullbench.c b/tests/fullbench.c index 233b4e931..e5547d089 100644 --- a/tests/fullbench.c +++ b/tests/fullbench.c @@ -11,7 +11,8 @@ /*_************************************ * Includes **************************************/ -#include "util.h" /* Compiler options, UTIL_GetFileSize */ +#include "platform.h" /* Compiler options */ +#include "util.h" /* UTIL_GetFileSize */ #include /* malloc */ #include /* fprintf, fopen, ftello64 */ #include /* clock_t, clock, CLOCKS_PER_SEC */ diff --git a/tests/paramgrill.c b/tests/paramgrill.c index 5eabcba2b..19658fddb 100644 --- a/tests/paramgrill.c +++ b/tests/paramgrill.c @@ -11,7 +11,8 @@ /*-************************************ * Dependencies **************************************/ -#include "util.h" /* Compiler options, UTIL_GetFileSize */ +#include "platform.h" /* Compiler options */ +#include "util.h" /* UTIL_GetFileSize */ #include /* malloc */ #include /* fprintf, fopen, ftello64 */ #include /* strcmp */ diff --git a/zlibWrapper/examples/zwrapbench.c b/zlibWrapper/examples/zwrapbench.c index e0aca0015..c3968dba3 100644 --- a/zlibWrapper/examples/zwrapbench.c +++ b/zlibWrapper/examples/zwrapbench.c @@ -11,7 +11,8 @@ /* ************************************* * Includes ***************************************/ -#include "util.h" /* Compiler options, UTIL_GetFileSize, UTIL_sleep */ +#include "platform.h" /* Compiler options */ +#include "util.h" /* UTIL_GetFileSize, UTIL_sleep */ #include /* malloc, free */ #include /* memset */ #include /* fprintf, fopen, ftello64 */