diff options
Diffstat (limited to 'ipc/chromium/src/base/time_posix.cc')
-rw-r--r-- | ipc/chromium/src/base/time_posix.cc | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/ipc/chromium/src/base/time_posix.cc b/ipc/chromium/src/base/time_posix.cc index 2eb76a989..5e0a922d9 100644 --- a/ipc/chromium/src/base/time_posix.cc +++ b/ipc/chromium/src/base/time_posix.cc @@ -67,11 +67,13 @@ Time Time::FromExploded(bool is_local, const Exploded& exploded) { timestruct.tm_wday = exploded.day_of_week; // mktime/timegm ignore this timestruct.tm_yday = 0; // mktime/timegm ignore this timestruct.tm_isdst = -1; // attempt to figure it out +#ifndef OS_SOLARIS timestruct.tm_gmtoff = 0; // not a POSIX field, so mktime/timegm ignore timestruct.tm_zone = NULL; // not a POSIX field, so mktime/timegm ignore +#endif time_t seconds; -#ifdef ANDROID +#if defined(ANDROID) || defined(OS_SOLARIS) seconds = mktime(×truct); #else if (is_local) @@ -175,7 +177,7 @@ TimeTicks TimeTicks::Now() { // With numer and denom = 1 (the expected case), the 64-bit absolute time // reported in nanoseconds is enough to last nearly 585 years. -#elif defined(OS_OPENBSD) || defined(OS_POSIX) && \ +#elif defined(OS_OPENBSD) || defined(OS_SOLARIS) || defined(OS_POSIX) && \ defined(_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 struct timespec ts; @@ -200,4 +202,27 @@ TimeTicks TimeTicks::HighResNow() { return Now(); } +#ifdef OS_SOLARIS +struct timespec TimeDelta::ToTimeSpec() const { + int64_t microseconds = InMicroseconds(); + time_t seconds = 0; + if (microseconds >= Time::kMicrosecondsPerSecond) { + seconds = InSeconds(); + microseconds -= seconds * Time::kMicrosecondsPerSecond; + } + struct timespec result = + {seconds, + microseconds * Time::kNanosecondsPerMicrosecond}; + return result; +} + +struct timeval Time::ToTimeVal() const { + struct timeval result; + int64_t us = us_ - kTimeTToMicrosecondsOffset; + result.tv_sec = us / Time::kMicrosecondsPerSecond; + result.tv_usec = us % Time::kMicrosecondsPerSecond; + return result; +} +#endif + } // namespace base |