OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/time.h" | 5 #include <sys/_structs.h> |
6 | |
7 #include <sys/time.h> | |
8 #include <time.h> | 6 #include <time.h> |
9 | 7 |
10 #include <limits> | |
11 | |
12 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
13 #include "base/logging.h" | 9 #include "base/time.h" |
| 10 #include "build/build_config.h" |
14 | 11 |
15 namespace base { | 12 namespace base { |
16 | 13 |
17 struct timespec TimeDelta::ToTimeSpec() const { | 14 struct timespec TimeDelta::ToTimeSpec() const { |
18 int64 microseconds = InMicroseconds(); | 15 int64 microseconds = InMicroseconds(); |
19 time_t seconds = 0; | 16 time_t seconds = 0; |
20 if (microseconds >= Time::kMicrosecondsPerSecond) { | 17 if (microseconds >= Time::kMicrosecondsPerSecond) { |
21 seconds = InSeconds(); | 18 seconds = InSeconds(); |
22 microseconds -= seconds * Time::kMicrosecondsPerSecond; | 19 microseconds -= seconds * Time::kMicrosecondsPerSecond; |
23 } | 20 } |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 189 |
193 struct timeval Time::ToTimeVal() const { | 190 struct timeval Time::ToTimeVal() const { |
194 struct timeval result; | 191 struct timeval result; |
195 int64 us = us_ - kTimeTToMicrosecondsOffset; | 192 int64 us = us_ - kTimeTToMicrosecondsOffset; |
196 result.tv_sec = us / Time::kMicrosecondsPerSecond; | 193 result.tv_sec = us / Time::kMicrosecondsPerSecond; |
197 result.tv_usec = us % Time::kMicrosecondsPerSecond; | 194 result.tv_usec = us % Time::kMicrosecondsPerSecond; |
198 return result; | 195 return result; |
199 } | 196 } |
200 | 197 |
201 } // namespace base | 198 } // namespace base |
OLD | NEW |