Home | History | Annotate | Download | only in include
      1 // SPDX-License-Identifier: GPL-2.0 or later
      2 /*
      3  *  Copyright (c) Zilogic Systems Pvt. Ltd., 2018
      4  *  Email : code (at) zilogic.com
      5  */
      6 
      7 #include <time.h>
      8 #include "tst_test.h"
      9 
     10 static inline void safe_clock_getres(const char *file, const int lineno,
     11 	clockid_t clk_id, struct timespec *res)
     12 {
     13 	int rval;
     14 
     15 	rval = clock_getres(clk_id, res);
     16 	if (rval != 0)
     17 		tst_brk(TBROK | TERRNO,
     18 			"%s:%d clock_getres() failed", file, lineno);
     19 
     20 }
     21 
     22 static inline void safe_clock_gettime(const char *file, const int lineno,
     23 	clockid_t clk_id, struct timespec *tp)
     24 {
     25 	int rval;
     26 
     27 	rval = clock_gettime(clk_id, tp);
     28 	if (rval != 0)
     29 		tst_brk(TBROK | TERRNO,
     30 			"%s:%d clock_gettime() failed", file, lineno);
     31 }
     32 
     33 #define SAFE_CLOCK_GETRES(clk_id, res)\
     34 	safe_clock_getres(__FILE__, __LINE__, (clk_id), (res))
     35 
     36 #define SAFE_CLOCK_GETTIME(clk_id, tp)\
     37 	safe_clock_gettime(__FILE__, __LINE__, (clk_id), (tp))
     38 
     39