From b857ca156ff665ca5d02bda3d5c4ecc512694f71 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 4 Oct 2012 15:43:01 +0200 Subject: ubus: add clock_gettime fallback for mac os x (untested) --- uhttpd-ubus.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'uhttpd-ubus.c') diff --git a/uhttpd-ubus.c b/uhttpd-ubus.c index 2078162..fbb4507 100644 --- a/uhttpd-ubus.c +++ b/uhttpd-ubus.c @@ -76,6 +76,30 @@ static const struct blobmsg_policy acl_policy[__UH_UBUS_SA_MAX] = { [UH_UBUS_SA_OBJECTS] = { .name = "objects", .type = BLOBMSG_TYPE_ARRAY }, }; +#ifdef __APPLE__ +#include + +#define CLOCK_MONOTONIC 0 + +static void clock_gettime(int type, struct timespec *tv) +{ + mach_timebase_info_data_t info; + float sec; + uint64_t val; + + mach_timebase_info(&info); + + val = mach_absolute_time(); + tv->tv_nsec = (val * info.numer / info.denom) % 1000000000; + + sec = val; + sec *= info.numer; + sec /= info.denom; + sec /= 1000000000; + tv->tv_sec = sec; +} + +#endif static bool uh_ubus_strmatch(const char *str, const char *pat) -- cgit v1.2.1