From 88648205e3a884e04362a502b1793a2cd3f8ab83 Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Wed, 11 May 2016 17:07:26 +0200 Subject: lib/igt_aux: Polish docs for igt_timeout Add docs, rename parameter and rename the macro to igt_do_timeout to make it clear it works like a loop. v2: Rename instead to igt_until_timeout (Chris). Acked-by: Chris Wilson Signed-off-by: Daniel Vetter --- lib/igt_aux.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib/igt_aux.h') diff --git a/lib/igt_aux.h b/lib/igt_aux.h index faaf56ac..30687423 100644 --- a/lib/igt_aux.h +++ b/lib/igt_aux.h @@ -72,8 +72,18 @@ bool __igt_sigiter_continue(struct __igt_sigiter *iter, bool interrupt); #define igt_while_interruptible(enable) \ for (struct __igt_sigiter iter__={}; __igt_sigiter_continue(&iter__, (enable)); ) -#define igt_timeout(T) \ - for (struct timespec t__={}; igt_seconds_elapsed(&t__) < (T); ) +/** + * igt_until_timeout: + * @timeout: timeout in seconds + * + * Convenience macro loop to run the provided code block in a loop until the + * timeout has expired. Of course when an individual execution takes too long, + * the actual execution time could be a lot longer. + * + * The code block will be executed at least once. + */ +#define igt_until_timeout(timeout) \ + for (struct timespec t__={}; igt_seconds_elapsed(&t__) < (timeout); ) void igt_exchange_int(void *array, unsigned i, unsigned j); void igt_permute_array(void *array, unsigned size, -- cgit v1.2.3