diff options
author | 2025-03-12 22:14:23 +0000 | |
---|---|---|
committer | 2025-03-21 10:04:43 +0000 | |
commit | aa405ccd29b7317dfe499fa63cc9fdaef2f049fb (patch) | |
tree | b9121ab6ec1e3483dedfa36f19ef338397a16541 /libartbase/base/time_utils.h | |
parent | 5045a8060a75ccccea94eac7363744ed63580ff9 (diff) |
Add an artd method to create an SDC file.
See https://r.android.com/3539979 as well as
go/art-cloud-compilation-platform-design "Overview",
"Detailed design -> SDC file", and
"Detailed design -> Incremental considerations" for details.
Bug: 377474232
Test: atest art_standalone_artd_tests
Change-Id: I870016723d77e75540894ac0c29bf1b32bf835e7
Diffstat (limited to 'libartbase/base/time_utils.h')
-rw-r--r-- | libartbase/base/time_utils.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libartbase/base/time_utils.h b/libartbase/base/time_utils.h index dd73b1c951..ddabb1289f 100644 --- a/libartbase/base/time_utils.h +++ b/libartbase/base/time_utils.h @@ -26,6 +26,8 @@ #include <cstdint> #include <string> +#include "android-base/logging.h" + namespace art { enum TimeUnit { @@ -123,6 +125,13 @@ void NanoSleep(uint64_t ns); // time corresponding to the indicated clock value plus the supplied offset. void InitTimeSpec(bool absolute, int clock, int64_t ms, int32_t ns, timespec* ts); +// Converts `timespec` to nanoseconds. The return value can be negative, which should be interpreted +// as a time before the epoch. +static constexpr int64_t TimeSpecToNs(timespec ts) { + DCHECK_GE(ts.tv_nsec, 0); // According to POSIX. + return static_cast<int64_t>(ts.tv_sec) * INT64_C(1000000000) + ts.tv_nsec; +} + } // namespace art #endif // ART_LIBARTBASE_BASE_TIME_UTILS_H_ |