summaryrefslogtreecommitdiff
path: root/libartbase/base/time_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'libartbase/base/time_utils.h')
-rw-r--r--libartbase/base/time_utils.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/libartbase/base/time_utils.h b/libartbase/base/time_utils.h
index 69c867cfaf..cb0ab13ef9 100644
--- a/libartbase/base/time_utils.h
+++ b/libartbase/base/time_utils.h
@@ -69,24 +69,33 @@ uint64_t ThreadCpuNanoTime();
uint64_t ProcessCpuNanoTime();
// Converts the given number of nanoseconds to milliseconds.
-static constexpr inline uint64_t NsToMs(uint64_t ns) {
+static constexpr uint64_t NsToMs(uint64_t ns) {
return ns / 1000 / 1000;
}
// Converts the given number of milliseconds to nanoseconds
-static constexpr inline uint64_t MsToNs(uint64_t ms) {
+static constexpr uint64_t MsToNs(uint64_t ms) {
return ms * 1000 * 1000;
}
// Converts the given number of milliseconds to microseconds
-static constexpr inline uint64_t MsToUs(uint64_t ms) {
+static constexpr uint64_t MsToUs(uint64_t ms) {
return ms * 1000;
}
-static constexpr inline uint64_t UsToNs(uint64_t us) {
+static constexpr uint64_t UsToNs(uint64_t us) {
return us * 1000;
}
+static constexpr time_t SaturatedTimeT(int64_t secs) {
+ if (sizeof(time_t) < sizeof(int64_t)) {
+ return static_cast<time_t>(std::min(secs,
+ static_cast<int64_t>(std::numeric_limits<time_t>::max())));
+ } else {
+ return secs;
+ }
+}
+
#if defined(__APPLE__)
#ifndef CLOCK_REALTIME
// No clocks to specify on OS/X < 10.12, fake value to pass to routines that require a clock.