2 * Copyright (C) 2016 Michael Jeanson <mjeanson@efficios.com>
4 * SPDX-License-Identifier: MIT
15 typedef uint64_t timer_t
;
17 #include <mach/mach.h>
18 #include <mach/clock.h>
19 #include <common/compat/errno.h>
26 #endif /* __APPLE__ */
28 /* macOS/OS X 10.12 (Sierra) and up provide clock_gettime() */
29 #if defined(__APPLE__) && !defined(LTTNG_HAVE_CLOCK_GETTIME)
31 typedef int clockid_t
;
32 #define CLOCK_REALTIME CALENDAR_CLOCK
33 #define CLOCK_MONOTONIC SYSTEM_CLOCK
36 int lttng_clock_gettime(clockid_t clk_id
, struct timespec
*tp
)
42 if (clk_id
!= CLOCK_REALTIME
&& clk_id
!= CLOCK_MONOTONIC
) {
48 host_get_clock_service(mach_host_self(), clk_id
, &clock
);
50 ret
= clock_get_time(clock
, &now
);
51 if (ret
!= KERN_SUCCESS
) {
56 tp
->tv_sec
= now
.tv_sec
;
57 tp
->tv_nsec
= now
.tv_nsec
;
60 mach_port_deallocate(mach_task_self(), clock
);
65 #else /* __APPLE__ && !LTTNG_HAVE_CLOCK_GETTIME */
68 int lttng_clock_gettime(clockid_t clk_id
, struct timespec
*tp
)
70 return clock_gettime(clk_id
, tp
);
73 #endif /* __APPLE__ && !LTTNG_HAVE_CLOCK_GETTIME */
75 #endif /* _COMPAT_TIME_H */
This page took 0.030528 seconds and 4 git commands to generate.