From 707de922fab70af1b4238c33359b77d1ebd1ee34 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Wed, 28 Sep 2016 20:43:57 -0400 Subject: [PATCH] Build fix: macOS Sierra provides clock_gettime MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- configure.ac | 2 ++ src/common/compat/time.h | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 5cfe97315..810e1f19d 100644 --- a/configure.ac +++ b/configure.ac @@ -369,6 +369,8 @@ PKG_CHECK_MODULES([UUID], [uuid], AM_CONDITIONAL([LTTNG_BUILD_WITH_LIBUUID], [test "x$link_with_libuuid" = "xyes"]) AM_CONDITIONAL([LTTNG_BUILD_WITH_LIBC_UUID], [test "x$link_with_libc_uuid" = "xyes"]) +AC_CHECK_FUNC([clock_gettime], [AC_DEFINE_UNQUOTED([LTTNG_HAVE_CLOCK_GETTIME], 1, [Has clock_gettime() support.])]) + # URCU library version needed or newer m4_define([WRONG_LIBURCU_MSG], [Userspace RCU (liburcu) >= 0.8.0 is needed]) diff --git a/src/common/compat/time.h b/src/common/compat/time.h index c8d5859ff..17447b372 100644 --- a/src/common/compat/time.h +++ b/src/common/compat/time.h @@ -26,8 +26,8 @@ #include #ifdef __APPLE__ + typedef uint64_t timer_t; -typedef int clockid_t; #include #include @@ -36,6 +36,12 @@ typedef int clockid_t; #undef NSEC_PER_MSEC #undef NSEC_PER_USEC +#endif /* __APPLE__ */ + +/* macOS/OS X 10.12 (Sierra) and up provide clock_gettime() */ +#if defined(__APPLE__) && !defined(LTTNG_HAVE_CLOCK_GETTIME) + +typedef int clockid_t; #define CLOCK_REALTIME CALENDAR_CLOCK #define CLOCK_MONOTONIC SYSTEM_CLOCK @@ -69,7 +75,7 @@ end: return ret; } -#else /* __APPLE__ */ +#else /* __APPLE__ && !LTTNG_HAVE_CLOCK_GETTIME */ static inline int lttng_clock_gettime(clockid_t clk_id, struct timespec *tp) @@ -77,6 +83,6 @@ int lttng_clock_gettime(clockid_t clk_id, struct timespec *tp) return clock_gettime(clk_id, tp); } -#endif /* __APPLE__ */ +#endif /* __APPLE__ && !LTTNG_HAVE_CLOCK_GETTIME */ #endif /* _COMPAT_TIME_H */ -- 2.34.1