X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Ftime.h;fp=src%2Fcommon%2Fcompat%2Ftime.h;h=0000000000000000000000000000000000000000;hb=c9e313bc594f40a86eed237dce222c0fc99c957f;hp=72a9afff47ef0a4db433bc3f78d995b98ef0d3fd;hpb=4878de5c7deb512bbdac4fdfc498907efa06fb7c;p=lttng-tools.git diff --git a/src/common/compat/time.h b/src/common/compat/time.h deleted file mode 100644 index 72a9afff4..000000000 --- a/src/common/compat/time.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2016 Michael Jeanson - * - * SPDX-License-Identifier: MIT - * - */ - -#ifndef _COMPAT_TIME_H -#define _COMPAT_TIME_H - -#include - -#ifdef __APPLE__ - -typedef uint64_t timer_t; - -#include -#include -#include - -#undef NSEC_PER_SEC -#undef NSEC_PER_MSEC -#undef NSEC_PER_USEC -#undef USEC_PER_SEC - -#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 - -static inline -int lttng_clock_gettime(clockid_t clk_id, struct timespec *tp) -{ - int ret = 0; - clock_serv_t clock; - mach_timespec_t now; - - if (clk_id != CLOCK_REALTIME && clk_id != CLOCK_MONOTONIC) { - ret = -1; - errno = EINVAL; - goto end; - } - - host_get_clock_service(mach_host_self(), clk_id, &clock); - - ret = clock_get_time(clock, &now); - if (ret != KERN_SUCCESS) { - ret = -1; - goto deallocate; - } - - tp->tv_sec = now.tv_sec; - tp->tv_nsec = now.tv_nsec; - -deallocate: - mach_port_deallocate(mach_task_self(), clock); -end: - return ret; -} - -#else /* __APPLE__ && !LTTNG_HAVE_CLOCK_GETTIME */ - -static inline -int lttng_clock_gettime(clockid_t clk_id, struct timespec *tp) -{ - return clock_gettime(clk_id, tp); -} - -#endif /* __APPLE__ && !LTTNG_HAVE_CLOCK_GETTIME */ - -#endif /* _COMPAT_TIME_H */