X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libtest%2Ftimer.hpp;h=73de26c6ac2361168cdf7974180cd32d4fa3c5e1;hb=77c9719d429337239b3f5e3d7fc5c17492682a77;hp=eac5194036300a533dfabfbf14f4fd4f9a8adc61;hpb=8e04e2a97ba16fce9ebf7d47a944de2dc40ba453;p=m6w6%2Flibmemcached diff --git a/libtest/timer.hpp b/libtest/timer.hpp index eac51940..73de26c6 100644 --- a/libtest/timer.hpp +++ b/libtest/timer.hpp @@ -44,7 +44,6 @@ # include # include #else -# include # include #endif @@ -115,7 +114,9 @@ public: private: void _time(struct timespec& ts) { -#ifdef __MACH__ // OSX lacks clock_gettime() +#if defined(HAVE_CLOCK_GETTIME) && HAVE_CLOCK_GETTIME + clock_gettime(CLOCK_REALTIME, &ts); +#elif defined(__MACH__) && __MACH__ // OSX lacks clock_gettime() clock_serv_t _clock_serv; mach_timespec_t _mach_timespec; host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &_clock_serv); @@ -123,24 +124,7 @@ private: mach_port_deallocate(mach_task_self(), _clock_serv); ts.tv_sec= _mach_timespec.tv_sec; ts.tv_nsec= _mach_timespec.tv_nsec; -#elif defined(HAVE_CLOCK_GETTIME) && HAVE_CLOCK_GETTIME - int ret; - do - { - ret= clock_gettime(CLOCK_REALTIME, &ts); - } while (ret == -1); -#elif defined(HAVE_GETTIMEOFDAY) && HAVE_GETTIMEOFDAY - struct timeval tv; - int ret; - do - { - ret= gettimeofday(&tv, NULL) - } while (ret == -1); - /* Convert from timeval to timespec */ - ts.tv_sec= tv.tv_sec; - ts.tv_nsec= tv.tv_usec * 1000; #else - memset(&ts, 0, sizeof(struct timespec)); #endif }