From 109ba284a155aab71676894f39735f119cd57405 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= Date: Tue, 19 Sep 2017 15:19:53 +0200 Subject: [PATCH] timer: Add helper function stopwatch_wait_until_expired MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ia888907028d687e3d17e5a088657086a3c839ad3 Signed-off-by: Jonathan Neuschäfer Reviewed-on: https://review.coreboot.org/21589 Tested-by: build bot (Jenkins) Reviewed-by: Mario Scheithauer Reviewed-by: Aaron Durbin --- src/include/timer.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/include/timer.h b/src/include/timer.h index 6b7baaf9fd..65ce9b4b79 100644 --- a/src/include/timer.h +++ b/src/include/timer.h @@ -165,6 +165,15 @@ static inline int stopwatch_expired(struct stopwatch *sw) return !mono_time_before(&sw->current, &sw->expires); } +/* + * Tick and check the stopwatch as long as it has not expired. + */ +static inline void stopwatch_wait_until_expired(struct stopwatch *sw) +{ + while (!stopwatch_expired(sw)) + ; +} + /* * Return number of microseconds since starting the stopwatch. */