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

Side by Side Diff: base/time/time_posix.cc

Issue 313053004: Revert "Non-SFI NaCl: Allow CLOCK_SYSTEM_TRACE on Chrome OS" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | « base/time/time.h ('k') | components/nacl/loader/nonsfi/nonsfi_sandbox.cc » ('j') | 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/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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 TimeTicks TimeTicks::ThreadNow() { 313 TimeTicks TimeTicks::ThreadNow() {
314 #if (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ 314 #if (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \
315 defined(OS_ANDROID) 315 defined(OS_ANDROID)
316 return ClockNow(CLOCK_THREAD_CPUTIME_ID); 316 return ClockNow(CLOCK_THREAD_CPUTIME_ID);
317 #else 317 #else
318 NOTREACHED(); 318 NOTREACHED();
319 return TimeTicks(); 319 return TimeTicks();
320 #endif 320 #endif
321 } 321 }
322 322
323 // NaCl IRT does not support the Chrome OS specific clock 323 #if defined(OS_CHROMEOS)
324 // ID. build/common.gypi sets OS_CHROMEOS without any other OS_* 324 // Force definition of the system trace clock; it is a chromeos-only api
325 // macros for untrusted NaCl build so we need to check 325 // at the moment and surfacing it in the right place requires mucking
326 // __native_client__ explicitly. 326 // with glibc et al.
327 // TODO(hamaji): Do not specify OS_CHROMEOS for untrusted NaCl build 327 #define CLOCK_SYSTEM_TRACE 11
328 // and remove !defined(__native_client__). 328
329 #if defined(OS_CHROMEOS) && !defined(__native_client__)
330 // static 329 // static
331 TimeTicks TimeTicks::NowFromSystemTraceTime() { 330 TimeTicks TimeTicks::NowFromSystemTraceTime() {
332 uint64_t absolute_micro; 331 uint64_t absolute_micro;
333 332
334 struct timespec ts; 333 struct timespec ts;
335 if (clock_gettime(kClockSystemTrace, &ts) != 0) { 334 if (clock_gettime(CLOCK_SYSTEM_TRACE, &ts) != 0) {
336 // NB: fall-back for a chrome os build running on linux 335 // NB: fall-back for a chrome os build running on linux
337 return HighResNow(); 336 return HighResNow();
338 } 337 }
339 338
340 absolute_micro = 339 absolute_micro =
341 (static_cast<int64>(ts.tv_sec) * Time::kMicrosecondsPerSecond) + 340 (static_cast<int64>(ts.tv_sec) * Time::kMicrosecondsPerSecond) +
342 (static_cast<int64>(ts.tv_nsec) / Time::kNanosecondsPerMicrosecond); 341 (static_cast<int64>(ts.tv_nsec) / Time::kNanosecondsPerMicrosecond);
343 342
344 return TimeTicks(absolute_micro); 343 return TimeTicks(absolute_micro);
345 } 344 }
346 345
347 #else // !(defined(OS_CHROMEOS) && !defined(__native_client__)) 346 #else // !defined(OS_CHROMEOS)
348 347
349 // static 348 // static
350 TimeTicks TimeTicks::NowFromSystemTraceTime() { 349 TimeTicks TimeTicks::NowFromSystemTraceTime() {
351 return HighResNow(); 350 return HighResNow();
352 } 351 }
353 352
354 #endif // defined(OS_CHROMEOS) && !defined(__native_client__) 353 #endif // defined(OS_CHROMEOS)
355 354
356 #endif // !OS_MACOSX 355 #endif // !OS_MACOSX
357 356
358 // static 357 // static
359 Time Time::FromTimeVal(struct timeval t) { 358 Time Time::FromTimeVal(struct timeval t) {
360 DCHECK_LT(t.tv_usec, static_cast<int>(Time::kMicrosecondsPerSecond)); 359 DCHECK_LT(t.tv_usec, static_cast<int>(Time::kMicrosecondsPerSecond));
361 DCHECK_GE(t.tv_usec, 0); 360 DCHECK_GE(t.tv_usec, 0);
362 if (t.tv_usec == 0 && t.tv_sec == 0) 361 if (t.tv_usec == 0 && t.tv_sec == 0)
363 return Time(); 362 return Time();
364 if (t.tv_usec == static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1 && 363 if (t.tv_usec == static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1 &&
(...skipping 17 matching lines...) Expand all
382 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1; 381 result.tv_usec = static_cast<suseconds_t>(Time::kMicrosecondsPerSecond) - 1;
383 return result; 382 return result;
384 } 383 }
385 int64 us = us_ - kTimeTToMicrosecondsOffset; 384 int64 us = us_ - kTimeTToMicrosecondsOffset;
386 result.tv_sec = us / Time::kMicrosecondsPerSecond; 385 result.tv_sec = us / Time::kMicrosecondsPerSecond;
387 result.tv_usec = us % Time::kMicrosecondsPerSecond; 386 result.tv_usec = us % Time::kMicrosecondsPerSecond;
388 return result; 387 return result;
389 } 388 }
390 389
391 } // namespace base 390 } // namespace base
OLDNEW
« no previous file with comments | « base/time/time.h ('k') | components/nacl/loader/nonsfi/nonsfi_sandbox.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698