Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: base/time_posix.cc

Issue 10356028: Enable system trace clock use on chrome os. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move define to code Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698