X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Ftimer.c;h=bfc182cb5ba7e8a8167f03bfadf6855bfc43ee9e;hb=d017730cd2eb7eeb219e7fb975cce7c7c377b195;hp=b354fd67df9d5c9338d351bed6631165533c6e9b;hpb=808f6f490d6e93002b5ac8e0ba201aa82b128fc4;p=umurmur.git diff --git a/src/timer.c b/src/timer.c index b354fd6..bfc182c 100644 --- a/src/timer.c +++ b/src/timer.c @@ -32,16 +32,31 @@ #include #include +#ifdef __MACH__ +#include +#include +#endif + #include "timer.h" static uint64_t Timer_now() { struct timespec ts; uint64_t e; - - clock_gettime(CLOCK_MONOTONIC, &ts); - e = ts.tv_sec * 1000000LL; - e += ts.tv_nsec / 1000LL; //convert to microseconds + +#ifdef __MACH__ + clock_serv_t clock; + mach_timespec_t mts; + host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &clock); + clock_get_time(clock, &mts); + mach_port_deallocate(mach_task_self(), clock); + ts.tv_sec = mts.tv_sec; + ts.tv_nsec = mts.tv_nsec; +#else + clock_gettime(CLOCK_MONOTONIC, &ts); +#endif + e = ts.tv_sec * 1000000LL; + e += ts.tv_nsec / 1000LL; //convert to microseconds return e; }