X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Ftimer.c;fp=src%2Ftimer.c;h=65df9edcb8df06b189338723bb8b9974c9328c90;hb=08258f28ea0a289c0993823a42d214a7d87cfd01;hp=b354fd67df9d5c9338d351bed6631165533c6e9b;hpb=9685e692ba2c2cf0056755f811bf0bdd3e005b2f;p=umurmur.git diff --git a/src/timer.c b/src/timer.c index b354fd6..65df9ed 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(), CALENDAR_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; }