chrono.cpp: suppress clock_gettime()

This commit is contained in:
NAKAMURA Takumi
2011-04-20 11:32:39 +09:00
parent 8082261d2c
commit 591952787f

View File

@@ -116,10 +116,16 @@ steady_clock::now()
steady_clock::time_point
steady_clock::now()
{
#ifdef __MINGW32__
timeval tv;
gettimeofday(&tv, 0);
return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
#else
struct timespec tp;
if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
__throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
#endif
}
#endif // __APPLE__