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

Unified Diff: src/platform/time.cc

Issue 23548007: Import ConditionVariable class. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rename OperandSize enum names. Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/platform/time.h ('k') | src/x64/disasm-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/time.cc
diff --git a/src/platform/time.cc b/src/platform/time.cc
index 756be9375a82f9feb1e6aa785f909fdba88886ff..ea6dd2c0bae6cfea3fc947b4c6f841c91a58b875 100644
--- a/src/platform/time.cc
+++ b/src/platform/time.cc
@@ -126,7 +126,9 @@ int64_t TimeDelta::InNanoseconds() const {
#if V8_OS_MACOSX
TimeDelta TimeDelta::FromMachTimespec(struct mach_timespec ts) {
- ASSERT(ts.tv_nsec >= 0);
+ ASSERT_GE(ts.tv_nsec, 0);
+ ASSERT_LT(ts.tv_nsec,
+ static_cast<long>(Time::kNanosecondsPerSecond)); // NOLINT
return TimeDelta(ts.tv_sec * Time::kMicrosecondsPerSecond +
ts.tv_nsec / Time::kNanosecondsPerMicrosecond);
}
@@ -144,6 +146,28 @@ struct mach_timespec TimeDelta::ToMachTimespec() const {
#endif // V8_OS_MACOSX
+#if V8_OS_POSIX
+
+TimeDelta TimeDelta::FromTimespec(struct timespec ts) {
+ ASSERT_GE(ts.tv_nsec, 0);
+ ASSERT_LT(ts.tv_nsec,
+ static_cast<long>(Time::kNanosecondsPerSecond)); // NOLINT
+ return TimeDelta(ts.tv_sec * Time::kMicrosecondsPerSecond +
+ ts.tv_nsec / Time::kNanosecondsPerMicrosecond);
+}
+
+
+struct timespec TimeDelta::ToTimespec() const {
+ struct timespec ts;
+ ts.tv_sec = delta_ / Time::kMicrosecondsPerSecond;
+ ts.tv_nsec = (delta_ % Time::kMicrosecondsPerSecond) *
+ Time::kNanosecondsPerMicrosecond;
+ return ts;
+}
+
+#endif // V8_OS_POSIX
+
+
#if V8_OS_WIN
// We implement time using the high-resolution timers so that we can get
« no previous file with comments | « src/platform/time.h ('k') | src/x64/disasm-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698