]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
use PLATFORM_POSIX_VERSION
authorPrzemyslaw Skibinski <inikep@gmail.com>
Fri, 16 Dec 2016 14:00:50 +0000 (15:00 +0100)
committerPrzemyslaw Skibinski <inikep@gmail.com>
Fri, 16 Dec 2016 14:00:50 +0000 (15:00 +0100)
programs/platform.h
programs/util.h
programs/zstdcli.c
tests/datagencli.c

index 095e52b84230f805d75e7a1ba4ec377a8984d6bd..6135cb582d8b857598d35d5d424bc0f92f78d7b7 100644 (file)
@@ -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
 
 
index 45fdacb1ae12fe0743220bd97b6fa72c03715873..179d5ca980b35bbc69ea4a617684beedbb4dc656 100644 (file)
@@ -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 */
index fa2956ca4cc65c1003ea72710d8d1c44a4db67b1..fad237530b7e3d31a42a18ae25b59744cac020fc 100644 (file)
@@ -44,8 +44,7 @@
 #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
 #  include <io.h>       /* _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 <unistd.h>   /* isatty */
 #  define IS_CONSOLE(stdStream) isatty(fileno(stdStream))
 #else
index 0729cdd0cc20b70fdc22bfb388fa18e274e951f7..2b3d3b5117237abef141e9e73a934af4aa9759aa 100644 (file)
@@ -14,6 +14,7 @@
 #include "platform.h"  /* Compiler options */
 #include <stdio.h>     /* fprintf, stderr */
 #include "datagen.h"   /* RDG_generate */
+#include "mem.h"       /* U32, U64 */
 
 
 /*-************************************