utils: fix build on Mac OS X 10.12
authorFelix Fietkau <nbd@nbd.name>
Fri, 20 Jan 2017 10:29:51 +0000 (11:29 +0100)
committerFelix Fietkau <nbd@nbd.name>
Fri, 20 Jan 2017 10:29:53 +0000 (11:29 +0100)
clock_gettime and CLOCK_MONOTONIC are supported now

Signed-off-by: Felix Fietkau <nbd@nbd.name>
utils.c
utils.h

diff --git a/utils.c b/utils.c
index e59002ed3062da8a210324d9d1baf9aabb81fdfc..5d9d5aa61347b146bf713540cfa935a81fd8cd2b 100644 (file)
--- a/utils.c
+++ b/utils.c
@@ -56,7 +56,7 @@ void *__calloc_a(size_t len, ...)
        return ret;
 }
 
-#ifdef __APPLE__
+#ifdef LIBUBOX_COMPAT_CLOCK_GETTIME
 #include <mach/mach_host.h>            /* host_get_clock_service() */
 #include <mach/mach_port.h>            /* mach_port_deallocate() */
 #include <mach/mach_init.h>            /* mach_host_self(), mach_task_self() */
diff --git a/utils.h b/utils.h
index 803150bfa475b51ad8e7edef5649383e4eb04b0f..cd09cc0e2a3b2a72ff3a691cc36758bfc99f2dcf 100644 (file)
--- a/utils.h
+++ b/utils.h
@@ -57,7 +57,8 @@ extern int __BUILD_BUG_ON_CONDITION_FAILED;
 #define BUILD_BUG_ON __BUILD_BUG_ON
 #endif
 
-#ifdef __APPLE__
+#if defined(__APPLE__) && !defined(CLOCK_MONOTONIC)
+#define LIBUBOX_COMPAT_CLOCK_GETTIME
 
 #include <mach/clock_types.h>
 #define CLOCK_REALTIME CALENDAR_CLOCK