]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
FreeBSD_11 specific fix
authorYann Collet <cyan@fb.com>
Wed, 10 Apr 2019 22:22:18 +0000 (15:22 -0700)
committerYann Collet <cyan@fb.com>
Wed, 10 Apr 2019 22:22:18 +0000 (15:22 -0700)
C11 mandates the definition of timespec_get() and TIME_UTC.
However, FreeBSD11 announce C11 compliance, but does not provifr timespec_get(),
breaking link stage for benchfn.
Since it does not provide TIME_UTC either, which is also required by C11,
test this macro: this will automatically rule out FreeBSD 11 for this code path
(it will use the backup C90 path instead, based on clock_t).

The issue seeems fixed in FreeBSD 12.

programs/timefn.c
programs/timefn.h

index 8c6010c9035aac60368d0ddfde3fa0d412a6bbaf..21f2a9618b49015feb060b1b62d95e1eeeecc271 100644 (file)
@@ -83,7 +83,8 @@ PTime UTIL_getSpanTimeNano(UTIL_time_t clockStart, UTIL_time_t clockEnd)
 
 
 
-#elif (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */)
+#elif (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */) \
+    && defined(TIME_UTC) /* C11 requires timespec_get, but FreeBSD 11 lacks it, while still claiming C11 compliance */
 
 #include <stdlib.h>   /* abort */
 #include <stdio.h>    /* perror */
index 810d6b2623f681ddf6184eda41479b20e85f4c9e..d1ddd31b1c0003b582b1c28e6dfe0b1ddd239ad9 100644 (file)
@@ -57,9 +57,10 @@ extern "C" {
     typedef PTime UTIL_time_t;
     #define UTIL_TIME_INITIALIZER 0
 
-#elif (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */)
+#elif (defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) /* C11 */) \
+    && defined(TIME_UTC) /* C11 requires timespec_get, but FreeBSD 11 lacks it, while still claiming C11 compliance */
 
-    typedef struct timespec UTIL_time_t;   /* C11 defines struct timespes within time.h */
+    typedef struct timespec UTIL_time_t;
     #define UTIL_TIME_INITIALIZER { 0, 0 }
 
 #else   /* relies on standard C90 (note : clock_t measurements can be wrong when using multi-threading) */