|
|
@@ -132,26 +132,11 @@ mg_static_assert(sizeof(void *) >= sizeof(int), "data type size check");
|
|
|
#include <mach/mach_time.h>
|
|
|
#include <assert.h>
|
|
|
|
|
|
-// ATOMIC BEGIN
|
|
|
-/* Determine if the current OSX version supports clock_gettime */
|
|
|
-#ifdef __APPLE__
|
|
|
-#include <AvailabilityMacros.h>
|
|
|
-#ifndef MAC_OS_X_VERSION_10_12
|
|
|
-#define MAC_OS_X_VERSION_10_12 101200
|
|
|
-#endif
|
|
|
-#endif
|
|
|
-
|
|
|
-// TODO: Once we get to the point 10.12 is required, make sure civetweb itself has been updated!
|
|
|
-// Instead of using MAC_OS_X_VERSION_MIN_REQUIRED, which it doesn't appear time.h is guarded by, use MAC_OS_X_VERSION_MAX_ALLOWED
|
|
|
-#define CIVETWEB_APPLE_HAVE_CLOCK_GETTIME defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12
|
|
|
-#if !(CIVETWEB_APPLE_HAVE_CLOCK_GETTIME)
|
|
|
-// ATOMIC END
|
|
|
-
|
|
|
/* clock_gettime is not implemented on OSX prior to 10.12 */
|
|
|
-int clock_gettime(int clk_id, struct timespec *t);
|
|
|
+int _civet_clock_gettime(int clk_id, struct timespec *t);
|
|
|
|
|
|
int
|
|
|
-clock_gettime(int clk_id, struct timespec *t)
|
|
|
+_civet_clock_gettime(int clk_id, struct timespec *t)
|
|
|
{
|
|
|
memset(t, 0, sizeof(*t));
|
|
|
if (clk_id == CLOCK_REALTIME) {
|
|
|
@@ -191,6 +176,23 @@ clock_gettime(int clk_id, struct timespec *t)
|
|
|
}
|
|
|
return -1; /* EINVAL - Clock ID is unknown */
|
|
|
}
|
|
|
+
|
|
|
+/* if clock_gettime is declared, then __CLOCK_AVAILABILITY will be defined */
|
|
|
+#ifdef __CLOCK_AVAILABILITY
|
|
|
+/* If we compiled with Mac OSX 10.12 or later, then clock_gettime will be declared
|
|
|
+ * but it may be NULL at runtime. So we need to check before using it. */
|
|
|
+int _civet_safe_clock_gettime(int clk_id, struct timespec *t);
|
|
|
+
|
|
|
+int
|
|
|
+_civet_safe_clock_gettime(int clk_id, struct timespec *t) {
|
|
|
+ if( clock_gettime ) {
|
|
|
+ return clock_gettime(clk_id, t);
|
|
|
+ }
|
|
|
+ return _civet_clock_gettime(clk_id, t);
|
|
|
+}
|
|
|
+#define clock_gettime _civet_safe_clock_gettime
|
|
|
+#else
|
|
|
+#define clock_gettime _civet_clock_gettime
|
|
|
#endif
|
|
|
#endif
|
|
|
|