OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/time.h" |
6 | 6 |
7 #include <sys/time.h> | 7 #include <sys/time.h> |
8 #include <time.h> | 8 #include <time.h> |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 | 10 |
11 #include <limits> | 11 #include <limits> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 | 15 |
16 #if defined(OS_ANDROID) | 16 #if defined(OS_ANDROID) |
17 #include "base/os_compat_android.h" | 17 #include "base/os_compat_android.h" |
18 #elif defined(OS_NACL) | 18 #elif defined(OS_NACL) |
19 #include "base/os_compat_nacl.h" | 19 #include "base/os_compat_nacl.h" |
20 #endif | 20 #endif |
21 | 21 |
22 namespace base { | 22 namespace base { |
23 | 23 |
24 #if defined(OS_ANDROID) | 24 #if defined(OS_ANDROID) |
25 #define _POSIX_MONOTONIC_CLOCK 1 | 25 #define _POSIX_MONOTONIC_CLOCK 1 |
26 #endif | 26 #endif |
| 27 #if defined(OS_CHROMEOS) |
| 28 // Force definition of the system trace clock; it is a chromeos-only api |
| 29 // at the moment and surfacing it in the right place requires mucking |
| 30 // with glibc et al. |
| 31 #define CLOCK_SYSTEM_TRACE 11 |
| 32 #endif |
27 | 33 |
28 struct timespec TimeDelta::ToTimeSpec() const { | 34 struct timespec TimeDelta::ToTimeSpec() const { |
29 int64 microseconds = InMicroseconds(); | 35 int64 microseconds = InMicroseconds(); |
30 time_t seconds = 0; | 36 time_t seconds = 0; |
31 if (microseconds >= Time::kMicrosecondsPerSecond) { | 37 if (microseconds >= Time::kMicrosecondsPerSecond) { |
32 seconds = InSeconds(); | 38 seconds = InSeconds(); |
33 microseconds -= seconds * Time::kMicrosecondsPerSecond; | 39 microseconds -= seconds * Time::kMicrosecondsPerSecond; |
34 } | 40 } |
35 struct timespec result = | 41 struct timespec result = |
36 {seconds, | 42 {seconds, |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 | 266 |
261 struct timeval Time::ToTimeVal() const { | 267 struct timeval Time::ToTimeVal() const { |
262 struct timeval result; | 268 struct timeval result; |
263 int64 us = us_ - kTimeTToMicrosecondsOffset; | 269 int64 us = us_ - kTimeTToMicrosecondsOffset; |
264 result.tv_sec = us / Time::kMicrosecondsPerSecond; | 270 result.tv_sec = us / Time::kMicrosecondsPerSecond; |
265 result.tv_usec = us % Time::kMicrosecondsPerSecond; | 271 result.tv_usec = us % Time::kMicrosecondsPerSecond; |
266 return result; | 272 return result; |
267 } | 273 } |
268 | 274 |
269 } // namespace base | 275 } // namespace base |
OLD | NEW |