From aa405ccd29b7317dfe499fa63cc9fdaef2f049fb Mon Sep 17 00:00:00 2001 From: Jiakai Zhang Date: Wed, 12 Mar 2025 22:14:23 +0000 Subject: 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 --- libartbase/base/time_utils.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'libartbase/base/time_utils.h') 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 #include +#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(ts.tv_sec) * INT64_C(1000000000) + ts.tv_nsec; +} + } // namespace art #endif // ART_LIBARTBASE_BASE_TIME_UTILS_H_ -- cgit v1.2.3-59-g8ed1b