1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-29 11:21:22 +03:00

imporved support for POSIX-type OSes

This commit is contained in:
Przemyslaw Skibinski
2016-12-16 15:41:18 +01:00
parent 3cdfe266cf
commit b0f3663edc
3 changed files with 16 additions and 10 deletions

View File

@ -49,10 +49,10 @@ extern "C" {
* PLATFORM_POSIX_VERSION = 0 for Unix-like non-POSIX * PLATFORM_POSIX_VERSION = 0 for Unix-like non-POSIX
* PLATFORM_POSIX_VERSION >= 1 is equal to found _POSIX_VERSION * PLATFORM_POSIX_VERSION >= 1 is equal to found _POSIX_VERSION
***************************************************************/ ***************************************************************/
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)) || defined(__midipix__)) #if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)) || defined(__midipix__) || defined(__VMS))
/* UNIX-style OS. ------------------------------------------- */ /* UNIX-style OS. ------------------------------------------- */
# if (defined(__APPLE__) && defined(__MACH__) || defined(__SVR4) || defined(_AIX) || defined(__hpux) \ # if (defined(__APPLE__) && defined(__MACH__)) || defined(__SVR4) || defined(_AIX) || defined(__hpux) \
|| defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) \ /* POSIX.12001 (SUSv3) conformant */ || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) /* POSIX.12001 (SUSv3) conformant */
# define PLATFORM_POSIX_VERSION 200112L # define PLATFORM_POSIX_VERSION 200112L
# else # else
# if defined(__linux__) || defined(__linux) # if defined(__linux__) || defined(__linux)

View File

@ -63,7 +63,7 @@ extern "C" {
# define SET_HIGH_PRIORITY SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS) # define SET_HIGH_PRIORITY SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS)
# define UTIL_sleep(s) Sleep(1000*s) # define UTIL_sleep(s) Sleep(1000*s)
# define UTIL_sleepMilli(milli) Sleep(milli) # define UTIL_sleepMilli(milli) Sleep(milli)
#elif (defined(__unix__) || defined(__unix) || defined(__VMS) || defined(__midipix__) || (defined(__APPLE__) && defined(__MACH__))) #elif PLATFORM_POSIX_VERSION >= 0 /* Unix-like operating system */
# include <unistd.h> # include <unistd.h>
# include <sys/resource.h> /* setpriority */ # include <sys/resource.h> /* setpriority */
# include <time.h> /* clock_t, nanosleep, clock, CLOCKS_PER_SEC */ # include <time.h> /* clock_t, nanosleep, clock, CLOCKS_PER_SEC */
@ -73,7 +73,7 @@ extern "C" {
# define SET_HIGH_PRIORITY /* disabled */ # define SET_HIGH_PRIORITY /* disabled */
# endif # endif
# define UTIL_sleep(s) sleep(s) # define UTIL_sleep(s) sleep(s)
# if PLATFORM_POSIX_VERSION >= 200112L /* nanosleep requires POSIX.1-2001 */ # if (defined(__linux__) && (PLATFORM_POSIX_VERSION >= 199309L)) || (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); } # define UTIL_sleepMilli(milli) { struct timespec t; t.tv_sec=0; t.tv_nsec=milli*1000000ULL; nanosleep(&t, NULL); }
# else # else
# define UTIL_sleepMilli(milli) /* disabled */ # define UTIL_sleepMilli(milli) /* disabled */
@ -300,10 +300,7 @@ UTIL_STATIC int UTIL_prepareFileList(const char *dirName, char** bufStart, size_
return nbFiles; return nbFiles;
} }
#elif (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L)) || \ #elif (defined(__linux__) && (PLATFORM_POSIX_VERSION >= 1)) || (PLATFORM_POSIX_VERSION >= 200112L) /* opendir, readdir require POSIX.1-2001 */
(defined(__APPLE__) && defined(__MACH__)) || defined(__SVR4) || defined(_AIX) || defined(__hpux) || \
defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
(defined(__linux__) && defined(_POSIX_C_SOURCE)) /* opendir */
# define UTIL_HAS_CREATEFILELIST # define UTIL_HAS_CREATEFILELIST
# include <dirent.h> /* opendir, readdir */ # include <dirent.h> /* opendir, readdir */

View File

@ -44,7 +44,7 @@
#if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
# include <io.h> /* _isatty */ # include <io.h> /* _isatty */
# define IS_CONSOLE(stdStream) _isatty(_fileno(stdStream)) # define IS_CONSOLE(stdStream) _isatty(_fileno(stdStream))
#elif PLATFORM_POSIX_VERSION >= 200112L /* isatty requires POSIX.1-2001 */ #elif (defined(__linux__) && (PLATFORM_POSIX_VERSION >= 1)) || PLATFORM_POSIX_VERSION >= 200112L /* isatty requires POSIX.1-2001 */
# include <unistd.h> /* isatty */ # include <unistd.h> /* isatty */
# define IS_CONSOLE(stdStream) isatty(fileno(stdStream)) # define IS_CONSOLE(stdStream) isatty(fileno(stdStream))
#else #else
@ -470,6 +470,15 @@ int main(int argCount, const char* argv[])
/* Welcome message (if verbose) */ /* Welcome message (if verbose) */
DISPLAYLEVEL(3, WELCOME_MESSAGE); DISPLAYLEVEL(3, WELCOME_MESSAGE);
#ifdef _POSIX_C_SOURCE
DISPLAYLEVEL(4, "_POSIX_C_SOURCE defined: %ldL\n", (long) _POSIX_C_SOURCE);
#endif
#ifdef _POSIX_VERSION
DISPLAYLEVEL(4, "_POSIX_VERSION defined: %ldL\n", (long) _POSIX_VERSION);
#endif
#ifdef PLATFORM_POSIX_VERSION
DISPLAYLEVEL(4, "PLATFORM_POSIX_VERSION defined: %ldL\n", (long) PLATFORM_POSIX_VERSION);
#endif
#ifdef UTIL_HAS_CREATEFILELIST #ifdef UTIL_HAS_CREATEFILELIST
if (recursive) { /* at this stage, filenameTable is a list of paths, which can contain both files and directories */ if (recursive) { /* at this stage, filenameTable is a list of paths, which can contain both files and directories */