From e46194bbf95aa11b81f3cc1be83f13d3f888421d Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 4 Dec 2017 15:57:01 -0800 Subject: [PATCH 1/3] fix #911 : changed detection macro for clock_gettime() The new macro might be a bit too restrictive. Systems which do not support new test will simply default to 's `clock_t clock()`, suffering lesser benchmark accuracy. Should it matter, the detection macro will have to be upgraded. --- programs/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/util.h b/programs/util.h index 37098f2f7..f510bc5e0 100644 --- a/programs/util.h +++ b/programs/util.h @@ -168,7 +168,7 @@ static int g_utilDisplayLevel; } return ((clockEnd - clockStart) * (U64)rate.numer) / ((U64)rate.denom); } -#elif (PLATFORM_POSIX_VERSION >= 200112L) +#elif defined __UCLIBC__ || ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17) || __GLIBC__ > 2) #include #define UTIL_TIME_INITIALIZER { 0, 0 } typedef struct timespec UTIL_freq_t; From 00974692380e79ea702e99214c6e7acf672c058e Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 4 Dec 2017 16:02:42 -0800 Subject: [PATCH 2/3] removed a few redundant #include --- programs/util.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/programs/util.h b/programs/util.h index f510bc5e0..38dad2ab4 100644 --- a/programs/util.h +++ b/programs/util.h @@ -34,7 +34,7 @@ extern "C" { # include /* chown, stat */ # include /* utime */ #endif -#include /* time */ +#include /* clock_t, clock, CLOCKS_PER_SEC, nanosleep */ #include #include "mem.h" /* U32, U64 */ @@ -64,7 +64,6 @@ extern "C" { #elif PLATFORM_POSIX_VERSION >= 0 /* Unix-like operating system */ # include # include /* setpriority */ -# include /* clock_t, nanosleep, clock, CLOCKS_PER_SEC */ # if defined(PRIO_PROCESS) # define SET_REALTIME_PRIORITY setpriority(PRIO_PROCESS, 0, -20) # else @@ -169,7 +168,6 @@ static int g_utilDisplayLevel; return ((clockEnd - clockStart) * (U64)rate.numer) / ((U64)rate.denom); } #elif defined __UCLIBC__ || ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17) || __GLIBC__ > 2) - #include #define UTIL_TIME_INITIALIZER { 0, 0 } typedef struct timespec UTIL_freq_t; typedef struct timespec UTIL_time_t; From 31293330d0cd3295646b208f5fa05cfa1ad8914c Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Mon, 4 Dec 2017 16:31:59 -0800 Subject: [PATCH 3/3] It's still necessary to check PLATFORM_POSIX_VERSION for clock_gettime() glibc/uclibc is not enough --- programs/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/util.h b/programs/util.h index 38dad2ab4..af1fa7fca 100644 --- a/programs/util.h +++ b/programs/util.h @@ -167,7 +167,7 @@ static int g_utilDisplayLevel; } return ((clockEnd - clockStart) * (U64)rate.numer) / ((U64)rate.denom); } -#elif defined __UCLIBC__ || ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17) || __GLIBC__ > 2) +#elif (PLATFORM_POSIX_VERSION >= 200112L) && (defined __UCLIBC__ || ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 17) || __GLIBC__ > 2)) #define UTIL_TIME_INITIALIZER { 0, 0 } typedef struct timespec UTIL_freq_t; typedef struct timespec UTIL_time_t;