Index: src/chrono.cpp =================================================================== --- src/chrono.cpp +++ src/chrono.cpp @@ -8,13 +8,13 @@ //===----------------------------------------------------------------------===// #include "chrono" -#include //for gettimeofday and timeval #ifdef __APPLE__ +#include // for gettimeofday and timeval #include // mach_absolute_time, mach_timebase_info_data_t #else /* !__APPLE__ */ #include // errno #include // __throw_system_error -#include // clock_gettime, CLOCK_MONOTONIC +#include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME #endif // __APPLE__ _LIBCPP_BEGIN_NAMESPACE_STD @@ -29,9 +29,16 @@ system_clock::time_point system_clock::now() _NOEXCEPT { +#ifdef __APPLE__ timeval tv; gettimeofday(&tv, 0); return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec)); +#else // __APPLE__ + struct timespec tp; + if (0 != clock_gettime(CLOCK_REALTIME, &tp)) + __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed"); + return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000)); +#endif // __APPLE__ } time_t