From e2e5c1ef3bb2df95fdf0e33cb2d975a990d07a4a Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 9 Aug 2013 00:48:06 -0700 Subject: [PATCH] timer: Add functions to initialize absolute timer structures. Otherwise there's no good way to create an absolute timer structure without fiddling with its internal structure or assuming a zero initialized structure has a value of zero. BUG=chrome-os-partner:19420 TEST=Used in a new monotonic implementation on pit. BRANCH=None Change-Id: Iffe3b6b25ed7963fcfb66f749c531ea445ea4aeb Signed-off-by: Gabe Black Reviewed-on: https://gerrit.chromium.org/gerrit/65301 Reviewed-by: Aaron Durbin Commit-Queue: Stefan Reinauer Reviewed-by: Stefan Reinauer Tested-by: Stefan Reinauer --- src/include/timer.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/include/timer.h b/src/include/timer.h index c32effe0a2..ec6dac5dd6 100644 --- a/src/include/timer.h +++ b/src/include/timer.h @@ -67,6 +67,18 @@ int timers_run(void); * 0 returned on success, < 0 on error. */ int timer_sched_callback(struct timeout_callback *tocb, unsigned long us); +/* Set an absolute time to a number of microseconds. */ +static inline void mono_time_set_usecs(struct mono_time *mt, long us) +{ + mt->microseconds = us; +} + +/* Set an absolute time to a number of milliseconds. */ +static inline void mono_time_set_msecs(struct mono_time *mt, long ms) +{ + mt->microseconds = ms * USECS_PER_MSEC; +} + /* Add microseconds to an absoute time. */ static inline void mono_time_add_usecs(struct mono_time *mt, long us) {