Chromium Code Reviews| 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/time.h" | 5 #include "base/time/time.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <sys/time.h> | 8 #include <sys/time.h> |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 #if defined(OS_ANDROID) && !defined(__LP64__) | 10 #if defined(OS_ANDROID) && !defined(__LP64__) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 uint64_t absolute_micro; | 91 uint64_t absolute_micro; |
| 92 | 92 |
| 93 struct timespec ts; | 93 struct timespec ts; |
| 94 if (clock_gettime(clk_id, &ts) != 0) { | 94 if (clock_gettime(clk_id, &ts) != 0) { |
| 95 NOTREACHED() << "clock_gettime(" << clk_id << ") failed."; | 95 NOTREACHED() << "clock_gettime(" << clk_id << ") failed."; |
| 96 return base::TimeTicks(); | 96 return base::TimeTicks(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 absolute_micro = | 99 absolute_micro = |
| 100 (static_cast<int64>(ts.tv_sec) * base::Time::kMicrosecondsPerSecond) + | 100 (static_cast<int64>(ts.tv_sec) * base::Time::kMicrosecondsPerSecond) + |
| 101 (static_cast<int64>(ts.tv_nsec) / base::Time::kNanosecondsPerMicrosecond); | 101 (static_cast<int64>(ts.tv_nsec / base::Time::kNanosecondsPerMicrosecond)); |
|
jamesr
2014/09/29 23:37:31
i'm pretty sure this doesn't actually help, since
Peter Kasting
2014/09/30 00:22:15
This. I'm in the process of cleaning up our 64-bi
| |
| 102 | 102 |
| 103 return base::TimeTicks::FromInternalValue(absolute_micro); | 103 return base::TimeTicks::FromInternalValue(absolute_micro); |
| 104 } | 104 } |
| 105 #else // _POSIX_MONOTONIC_CLOCK | 105 #else // _POSIX_MONOTONIC_CLOCK |
| 106 #error No usable tick clock function on this platform. | 106 #error No usable tick clock function on this platform. |
| 107 #endif // _POSIX_MONOTONIC_CLOCK | 107 #endif // _POSIX_MONOTONIC_CLOCK |
| 108 #endif // !defined(OS_MACOSX) | 108 #endif // !defined(OS_MACOSX) |
| 109 | 109 |
| 110 } // namespace | 110 } // namespace |
| 111 | 111 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; | 391 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; |
| 392 return result; | 392 return result; |
| 393 } | 393 } |
| 394 int64 us = us_ - kTimeTToMicrosecondsOffset; | 394 int64 us = us_ - kTimeTToMicrosecondsOffset; |
| 395 result.tv_sec = us / Time::kMicrosecondsPerSecond; | 395 result.tv_sec = us / Time::kMicrosecondsPerSecond; |
| 396 result.tv_usec = us % Time::kMicrosecondsPerSecond; | 396 result.tv_usec = us % Time::kMicrosecondsPerSecond; |
| 397 return result; | 397 return result; |
| 398 } | 398 } |
| 399 | 399 |
| 400 } // namespace base | 400 } // namespace base |
| OLD | NEW |