diff options
Diffstat (limited to 'src/ports/SkTime_Unix.cpp')
-rw-r--r-- | src/ports/SkTime_Unix.cpp | 40 |
1 files changed, 9 insertions, 31 deletions
diff --git a/src/ports/SkTime_Unix.cpp b/src/ports/SkTime_Unix.cpp index cdf7f3d947..f519a69d07 100644 --- a/src/ports/SkTime_Unix.cpp +++ b/src/ports/SkTime_Unix.cpp @@ -12,8 +12,10 @@ #include <sys/time.h> #include <time.h> -void SkTime::GetDateTime(DateTime* dt) { - if (dt) { +void SkTime::GetDateTime(DateTime* dt) +{ + if (dt) + { time_t m_time; time(&m_time); struct tm* tstruct; @@ -29,33 +31,9 @@ void SkTime::GetDateTime(DateTime* dt) { } } -#ifdef __MACH__ -# include <mach/mach_time.h> - -namespace { - -struct ConversionFactor { - ConversionFactor() { - mach_timebase_info_data_t timebase; - mach_timebase_info(&timebase); - toNanos = (double) timebase.numer / timebase.denom; - } - double toNanos; -}; - -} // namespace - -SkNSec SkTime::GetNSecs() { - static ConversionFactor convert; // Since already know we're on Mac, this is threadsafe. - return mach_absolute_time() * convert.toNanos; +SkMSec SkTime::GetMSecs() +{ + struct timeval tv; + gettimeofday(&tv, NULL); + return (SkMSec) (tv.tv_sec * 1000 + tv.tv_usec / 1000 ); // microseconds to milliseconds } - -#else // Linux, presumably all others too - -SkNSec SkTime::GetNSecs() { - struct timespec time; - clock_gettime(CLOCK_MONOTONIC, &time); - return (SkNSec)(time.tv_sec * 1000000000 + time.tv_nsec); -} - -#endif |