diff options
author | mmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-11 18:15:10 +0000 |
---|---|---|
committer | mmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-11 18:15:10 +0000 |
commit | dc9a22ac2628693842ee88a3eadae83c470f398d (patch) | |
tree | fdc2f6902640efaa80fe0cb355ca207873011527 /base/condition_variable_posix.cc | |
parent | 4b92c4260c6634b2b3e14960965c15fa45860148 (diff) | |
download | chromium_src-dc9a22ac2628693842ee88a3eadae83c470f398d.zip chromium_src-dc9a22ac2628693842ee88a3eadae83c470f398d.tar.gz chromium_src-dc9a22ac2628693842ee88a3eadae83c470f398d.tar.bz2 |
Make POSIX time routines work on Linux by providing a POSIX-conformant version of TimeTicks::Now() to replace the Mach-specific one used on the Mac.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@664 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/condition_variable_posix.cc')
-rw-r--r-- | base/condition_variable_posix.cc | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/base/condition_variable_posix.cc b/base/condition_variable_posix.cc index e234ece..5f9af5f 100644 --- a/base/condition_variable_posix.cc +++ b/base/condition_variable_posix.cc @@ -59,15 +59,12 @@ void ConditionVariable::TimedWait(const TimeDelta& max_time) { struct timeval now; gettimeofday(&now, NULL); - const int kMicrosPerUnit = 1000000; - const int kNanosPerMicro = 1000; - const int kNanosPerUnit = kMicrosPerUnit * kNanosPerMicro; - struct timespec abstime; - abstime.tv_sec = now.tv_sec + (usecs / kMicrosPerUnit); - abstime.tv_nsec = (now.tv_usec + (usecs % kMicrosPerUnit)) * kNanosPerMicro; - abstime.tv_sec += abstime.tv_nsec / kNanosPerUnit; - abstime.tv_nsec %= kNanosPerUnit; + abstime.tv_sec = now.tv_sec + (usecs / Time::kMicrosecondsPerSecond); + abstime.tv_nsec = (now.tv_usec + (usecs % Time::kMicrosecondsPerSecond)) * + Time::kNanosecondsPerMicrosecond; + abstime.tv_sec += abstime.tv_nsec / Time::kNanosecondsPerSecond; + abstime.tv_nsec %= Time::kNanosecondsPerSecond; DCHECK(abstime.tv_sec >= now.tv_sec); // Overflow paranoia int rv = pthread_cond_timedwait(&condition_, user_mutex_, &abstime); |