diff options
author | Rafael David Tinoco <rafael.tinoco@linaro.org> | 2019-01-29 15:36:53 -0200 |
---|---|---|
committer | Cyril Hrubis <chrubis@suse.cz> | 2019-01-30 12:05:25 +0100 |
commit | 0a84e767100926456e70545ea1642875caec5ef7 (patch) | |
tree | 7e4a3cd9d58cbe1b462d24b69b1dbd214192c5bf /include | |
parent | 99ff3b8fa63c9233c2d8576ab8e50f6eb2649219 (diff) |
lib: include SAFE_CLOCK_SETTIME() macro
Adds SAFE_CLOCK_SETTIME() macro to tst_safe_clocks.h.
Signed-off-by: Rafael David Tinoco <rafael.tinoco@linaro.org>
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
Diffstat (limited to 'include')
-rw-r--r-- | include/tst_safe_clocks.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/tst_safe_clocks.h b/include/tst_safe_clocks.h index 1b4d48543..553f8464a 100644 --- a/include/tst_safe_clocks.h +++ b/include/tst_safe_clocks.h @@ -30,9 +30,23 @@ static inline void safe_clock_gettime(const char *file, const int lineno, "%s:%d clock_gettime() failed", file, lineno); } + +static inline void safe_clock_settime(const char *file, const int lineno, + clockid_t clk_id, struct timespec *tp) +{ + int rval; + + rval = clock_settime(clk_id, tp); + if (rval != 0) + tst_brk(TBROK | TERRNO, + "%s:%d clock_gettime() failed", file, lineno); +} + #define SAFE_CLOCK_GETRES(clk_id, res)\ safe_clock_getres(__FILE__, __LINE__, (clk_id), (res)) #define SAFE_CLOCK_GETTIME(clk_id, tp)\ safe_clock_gettime(__FILE__, __LINE__, (clk_id), (tp)) +#define SAFE_CLOCK_SETTIME(clk_id, tp)\ + safe_clock_settime(__FILE__, __LINE__, (clk_id), (tp)) |