diff options
author | Felix Fietkau <nbd@openwrt.org> | 2012-10-04 15:43:01 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2012-10-04 15:43:37 +0200 |
commit | b857ca156ff665ca5d02bda3d5c4ecc512694f71 (patch) | |
tree | fded392454b4f33a92bb4c3976da2b18a031a584 | |
parent | 6b7593ceac4434f9729ccc0318a5c7b0cf550a2c (diff) | |
download | uhttpd-b857ca156ff665ca5d02bda3d5c4ecc512694f71.tar.gz |
ubus: add clock_gettime fallback for mac os x (untested)
-rw-r--r-- | uhttpd-ubus.c | 24 |
1 files changed, 24 insertions, 0 deletions
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 <mach/mach_time.h> + +#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) |