diff options
author | Michael Wright <michaelwr@google.com> | 2015-04-20 15:06:01 +0100 |
---|---|---|
committer | Michael Wright <michaelwr@google.com> | 2015-04-20 15:06:01 +0100 |
commit | 65e93c3b6f4f87e067a4866946501cc0f3cfd7d8 (patch) | |
tree | ac7819132bd8e4439416cca463bfbeca2fc068bf | |
parent | a4802ca08bfcbf0124f5e9b959ed4e3a198d5f46 (diff) | |
download | system_core-65e93c3b6f4f87e067a4866946501cc0f3cfd7d8.zip system_core-65e93c3b6f4f87e067a4866946501cc0f3cfd7d8.tar.gz system_core-65e93c3b6f4f87e067a4866946501cc0f3cfd7d8.tar.bz2 |
Mark time conversion functions as constexpr
Change-Id: I753c6975a8e1d78978c31175b2e1868eb374c442
-rw-r--r-- | include/utils/Timers.h | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/include/utils/Timers.h b/include/utils/Timers.h index d015421..54ec474 100644 --- a/include/utils/Timers.h +++ b/include/utils/Timers.h @@ -24,6 +24,8 @@ #include <sys/types.h> #include <sys/time.h> +#include <utils/Compat.h> + // ------------------------------------------------------------------ // C API @@ -33,46 +35,46 @@ extern "C" { typedef int64_t nsecs_t; // nano-seconds -static inline nsecs_t seconds_to_nanoseconds(nsecs_t secs) +static CONSTEXPR inline nsecs_t seconds_to_nanoseconds(nsecs_t secs) { return secs*1000000000; } -static inline nsecs_t milliseconds_to_nanoseconds(nsecs_t secs) +static CONSTEXPR inline nsecs_t milliseconds_to_nanoseconds(nsecs_t secs) { return secs*1000000; } -static inline nsecs_t microseconds_to_nanoseconds(nsecs_t secs) +static CONSTEXPR inline nsecs_t microseconds_to_nanoseconds(nsecs_t secs) { return secs*1000; } -static inline nsecs_t nanoseconds_to_seconds(nsecs_t secs) +static CONSTEXPR inline nsecs_t nanoseconds_to_seconds(nsecs_t secs) { return secs/1000000000; } -static inline nsecs_t nanoseconds_to_milliseconds(nsecs_t secs) +static CONSTEXPR inline nsecs_t nanoseconds_to_milliseconds(nsecs_t secs) { return secs/1000000; } -static inline nsecs_t nanoseconds_to_microseconds(nsecs_t secs) +static CONSTEXPR inline nsecs_t nanoseconds_to_microseconds(nsecs_t secs) { return secs/1000; } -static inline nsecs_t s2ns(nsecs_t v) {return seconds_to_nanoseconds(v);} -static inline nsecs_t ms2ns(nsecs_t v) {return milliseconds_to_nanoseconds(v);} -static inline nsecs_t us2ns(nsecs_t v) {return microseconds_to_nanoseconds(v);} -static inline nsecs_t ns2s(nsecs_t v) {return nanoseconds_to_seconds(v);} -static inline nsecs_t ns2ms(nsecs_t v) {return nanoseconds_to_milliseconds(v);} -static inline nsecs_t ns2us(nsecs_t v) {return nanoseconds_to_microseconds(v);} +static CONSTEXPR inline nsecs_t s2ns(nsecs_t v) {return seconds_to_nanoseconds(v);} +static CONSTEXPR inline nsecs_t ms2ns(nsecs_t v) {return milliseconds_to_nanoseconds(v);} +static CONSTEXPR inline nsecs_t us2ns(nsecs_t v) {return microseconds_to_nanoseconds(v);} +static CONSTEXPR inline nsecs_t ns2s(nsecs_t v) {return nanoseconds_to_seconds(v);} +static CONSTEXPR inline nsecs_t ns2ms(nsecs_t v) {return nanoseconds_to_milliseconds(v);} +static CONSTEXPR inline nsecs_t ns2us(nsecs_t v) {return nanoseconds_to_microseconds(v);} -static inline nsecs_t seconds(nsecs_t v) { return s2ns(v); } -static inline nsecs_t milliseconds(nsecs_t v) { return ms2ns(v); } -static inline nsecs_t microseconds(nsecs_t v) { return us2ns(v); } +static CONSTEXPR inline nsecs_t seconds(nsecs_t v) { return s2ns(v); } +static CONSTEXPR inline nsecs_t milliseconds(nsecs_t v) { return ms2ns(v); } +static CONSTEXPR inline nsecs_t microseconds(nsecs_t v) { return us2ns(v); } enum { SYSTEM_TIME_REALTIME = 0, // system-wide realtime clock |