Revision: 17644
Author: [email protected]
Date: Tue Nov 12 12:30:59 2013 UTC
Log: CLOCK_REALTIME is 0 on Linux, use -1 for invalid clock id.
[email protected]
Review URL: https://codereview.chromium.org/70133003
http://code.google.com/p/v8/source/detail?r=17644
Modified:
/branches/bleeding_edge/src/platform/time.cc
=======================================
--- /branches/bleeding_edge/src/platform/time.cc Tue Nov 12 12:18:35 2013
UTC
+++ /branches/bleeding_edge/src/platform/time.cc Tue Nov 12 12:30:59 2013
UTC
@@ -295,8 +295,10 @@
struct timespec ts;
// Use CLOCK_REALTIME_COARSE if it's available and has a precision of 1ms
// or higher. It's serviced from the vDSO with no system call overhead.
- static clock_t clock_id = static_cast<clock_t>(0);
- if (!clock_id) {
+ static clock_t clock_id = static_cast<clock_t>(-1);
+ STATIC_ASSERT(CLOCK_REALTIME != static_cast<clock_t>(-1));
+ STATIC_ASSERT(CLOCK_REALTIME_COARSE != static_cast<clock_t>(-1));
+ if (clock_id == static_cast<clock_t>(-1)) {
if (clock_getres(CLOCK_REALTIME_COARSE, &ts) == 0
&& ts.tv_nsec <= kNanosecondsPerMillisecond)
clock_id = CLOCK_REALTIME_COARSE;
@@ -611,8 +613,10 @@
#if defined(CLOCK_MONOTONIC_COARSE)
// Use CLOCK_MONOTONIC_COARSE if it's available and has a precision of
1ms
// or higher. It's serviced from the vDSO with no system call overhead.
- static clock_t clock_id = static_cast<clock_t>(0);
- if (!clock_id) {
+ static clock_t clock_id = static_cast<clock_t>(-1);
+ STATIC_ASSERT(CLOCK_MONOTONIC != static_cast<clock_t>(-1));
+ STATIC_ASSERT(CLOCK_MONOTONIC_COARSE != static_cast<clock_t>(-1));
+ if (clock_id == static_cast<clock_t>(-1)) {
if (clock_getres(CLOCK_MONOTONIC_COARSE, &ts) == 0
&& ts.tv_nsec <= Time::kNanosecondsPerMillisecond)
clock_id = CLOCK_MONOTONIC_COARSE;
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.