| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #define V8_PLATFORM_TIME_H_ | 29 #define V8_PLATFORM_TIME_H_ |
| 30 | 30 |
| 31 #include <ctime> | 31 #include <ctime> |
| 32 #include <limits> | 32 #include <limits> |
| 33 | 33 |
| 34 #include "allocation.h" | 34 #include "allocation.h" |
| 35 | 35 |
| 36 // Forward declarations. | 36 // Forward declarations. |
| 37 extern "C" { | 37 extern "C" { |
| 38 struct _FILETIME; | 38 struct _FILETIME; |
| 39 struct mach_timespec; |
| 40 struct timespec; |
| 39 struct timeval; | 41 struct timeval; |
| 40 } | 42 } |
| 41 | 43 |
| 42 namespace v8 { | 44 namespace v8 { |
| 43 namespace internal { | 45 namespace internal { |
| 44 | 46 |
| 45 class Time; | 47 class Time; |
| 46 class TimeTicks; | 48 class TimeTicks; |
| 47 | 49 |
| 48 // ----------------------------------------------------------------------------- | 50 // ----------------------------------------------------------------------------- |
| (...skipping 26 matching lines...) Expand all Loading... |
| 75 int InHours() const; | 77 int InHours() const; |
| 76 int InMinutes() const; | 78 int InMinutes() const; |
| 77 double InSecondsF() const; | 79 double InSecondsF() const; |
| 78 int64_t InSeconds() const; | 80 int64_t InSeconds() const; |
| 79 double InMillisecondsF() const; | 81 double InMillisecondsF() const; |
| 80 int64_t InMilliseconds() const; | 82 int64_t InMilliseconds() const; |
| 81 int64_t InMillisecondsRoundedUp() const; | 83 int64_t InMillisecondsRoundedUp() const; |
| 82 int64_t InMicroseconds() const { return delta_; } | 84 int64_t InMicroseconds() const { return delta_; } |
| 83 int64_t InNanoseconds() const; | 85 int64_t InNanoseconds() const; |
| 84 | 86 |
| 87 // Converts to/from Mach time specs. |
| 88 static TimeDelta FromMachTimespec(struct mach_timespec ts); |
| 89 struct mach_timespec ToMachTimespec() const; |
| 90 |
| 85 TimeDelta& operator=(const TimeDelta& other) { | 91 TimeDelta& operator=(const TimeDelta& other) { |
| 86 delta_ = other.delta_; | 92 delta_ = other.delta_; |
| 87 return *this; | 93 return *this; |
| 88 } | 94 } |
| 89 | 95 |
| 90 // Computations with other deltas. | 96 // Computations with other deltas. |
| 91 TimeDelta operator+(const TimeDelta& other) const { | 97 TimeDelta operator+(const TimeDelta& other) const { |
| 92 return TimeDelta(delta_ + other.delta_); | 98 return TimeDelta(delta_ + other.delta_); |
| 93 } | 99 } |
| 94 TimeDelta operator-(const TimeDelta& other) const { | 100 TimeDelta operator-(const TimeDelta& other) const { |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 // For timing sensitive unittests, this function should be used. | 211 // For timing sensitive unittests, this function should be used. |
| 206 static Time NowFromSystemTime(); | 212 static Time NowFromSystemTime(); |
| 207 | 213 |
| 208 // Returns the time for epoch in Unix-like system (Jan 1, 1970). | 214 // Returns the time for epoch in Unix-like system (Jan 1, 1970). |
| 209 static Time UnixEpoch() { return Time(0); } | 215 static Time UnixEpoch() { return Time(0); } |
| 210 | 216 |
| 211 // Returns the maximum time, which should be greater than any reasonable time | 217 // Returns the maximum time, which should be greater than any reasonable time |
| 212 // with which we might compare it. | 218 // with which we might compare it. |
| 213 static Time Max() { return Time(std::numeric_limits<int64_t>::max()); } | 219 static Time Max() { return Time(std::numeric_limits<int64_t>::max()); } |
| 214 | 220 |
| 221 // Converts to/from POSIX time specs. |
| 222 static Time FromTimespec(struct timespec ts); |
| 223 struct timespec ToTimespec() const; |
| 224 |
| 215 // Converts to/from POSIX time values. | 225 // Converts to/from POSIX time values. |
| 216 static Time FromTimeval(struct timeval tv); | 226 static Time FromTimeval(struct timeval tv); |
| 217 struct timeval ToTimeval() const; | 227 struct timeval ToTimeval() const; |
| 218 | 228 |
| 219 // Converts to/from Windows file times. | 229 // Converts to/from Windows file times. |
| 220 static Time FromFiletime(struct _FILETIME ft); | 230 static Time FromFiletime(struct _FILETIME ft); |
| 221 struct _FILETIME ToFiletime() const; | 231 struct _FILETIME ToFiletime() const; |
| 222 | 232 |
| 223 // Converts to/from the Javascript convention for times, a number of | 233 // Converts to/from the Javascript convention for times, a number of |
| 224 // milliseconds since the epoch: | 234 // milliseconds since the epoch: |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 int64_t ticks_; | 382 int64_t ticks_; |
| 373 }; | 383 }; |
| 374 | 384 |
| 375 inline TimeTicks operator+(const TimeDelta& delta, const TimeTicks& ticks) { | 385 inline TimeTicks operator+(const TimeDelta& delta, const TimeTicks& ticks) { |
| 376 return ticks + delta; | 386 return ticks + delta; |
| 377 } | 387 } |
| 378 | 388 |
| 379 } } // namespace v8::internal | 389 } } // namespace v8::internal |
| 380 | 390 |
| 381 #endif // V8_PLATFORM_TIME_H_ | 391 #endif // V8_PLATFORM_TIME_H_ |
| OLD | NEW |