From 3cdfe266cfc73333f67d0a63baa8d98ce27232f8 Mon Sep 17 00:00:00 2001 From: Przemyslaw Skibinski Date: Fri, 16 Dec 2016 15:00:50 +0100 Subject: [PATCH] use PLATFORM_POSIX_VERSION --- programs/platform.h | 14 +++++++------- programs/util.h | 2 +- programs/zstdcli.c | 3 +-- tests/datagencli.c | 1 + 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/programs/platform.h b/programs/platform.h index 095e52b84..6135cb582 100644 --- a/programs/platform.h +++ b/programs/platform.h @@ -43,12 +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 -**************************************************************/ +* PLATFORM_POSIX_VERSION = -1 for non-Unix e.g. Windows +* PLATFORM_POSIX_VERSION = 0 for Unix-like non-POSIX +* 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) \ @@ -62,13 +62,13 @@ extern "C" { # if defined(_POSIX_VERSION) /* POSIX compliant */ # define PLATFORM_POSIX_VERSION _POSIX_VERSION # else -# define PLATFORM_POSIX_VERSION 1 +# define PLATFORM_POSIX_VERSION 0 # endif # endif #endif #if !defined(PLATFORM_POSIX_VERSION) -# define PLATFORM_POSIX_VERSION 0 +# define PLATFORM_POSIX_VERSION -1 #endif diff --git a/programs/util.h b/programs/util.h index 45fdacb1a..179d5ca98 100644 --- a/programs/util.h +++ b/programs/util.h @@ -73,7 +73,7 @@ extern "C" { # define SET_HIGH_PRIORITY /* disabled */ # endif # define UTIL_sleep(s) sleep(s) -# if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 199309L)) +# if PLATFORM_POSIX_VERSION >= 200112L /* nanosleep requires POSIX.1-2001 */ # define UTIL_sleepMilli(milli) { struct timespec t; t.tv_sec=0; t.tv_nsec=milli*1000000ULL; nanosleep(&t, NULL); } # else # define UTIL_sleepMilli(milli) /* disabled */ diff --git a/programs/zstdcli.c b/programs/zstdcli.c index fa2956ca4..fad237530 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -44,8 +44,7 @@ #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) # include /* _isatty */ # define IS_CONSOLE(stdStream) _isatty(_fileno(stdStream)) -#elif defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE) || (defined(__APPLE__) && defined(__MACH__)) || \ - defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) /* https://sourceforge.net/p/predef/wiki/OperatingSystems/ */ +#elif PLATFORM_POSIX_VERSION >= 200112L /* isatty requires POSIX.1-2001 */ # include /* isatty */ # define IS_CONSOLE(stdStream) isatty(fileno(stdStream)) #else diff --git a/tests/datagencli.c b/tests/datagencli.c index 0729cdd0c..2b3d3b511 100644 --- a/tests/datagencli.c +++ b/tests/datagencli.c @@ -14,6 +14,7 @@ #include "platform.h" /* Compiler options */ #include /* fprintf, stderr */ #include "datagen.h" /* RDG_generate */ +#include "mem.h" /* U32, U64 */ /*-************************************