|
15 | 15 | #include "lapi/syscalls.h"
|
16 | 16 | #include "lapi/posix_clocks.h"
|
17 | 17 |
|
18 |
| -static inline void safe_clock_getres(const char *file, const int lineno, |
| 18 | +static inline int safe_clock_getres(const char *file, const int lineno, |
19 | 19 | clockid_t clk_id, struct timespec *res)
|
20 | 20 | {
|
21 | 21 | int rval;
|
22 | 22 |
|
23 | 23 | rval = clock_getres(clk_id, res);
|
24 |
| - if (rval != 0) { |
25 |
| - tst_brk(TBROK | TERRNO, |
26 |
| - "%s:%d clock_getres(%s) failed", |
27 |
| - file, lineno, tst_clock_name(clk_id)); |
| 24 | + |
| 25 | + if (rval == -1) { |
| 26 | + tst_brk_(file, lineno, TBROK | TERRNO, |
| 27 | + "clock_getres(%s) failed", tst_clock_name(clk_id)); |
| 28 | + } else if (rval) { |
| 29 | + tst_brk_(file, lineno, TBROK | TERRNO, |
| 30 | + "Invalid clock_getres(%s) return value %d", |
| 31 | + tst_clock_name(clk_id), rval); |
28 | 32 | }
|
| 33 | + |
| 34 | + return rval; |
29 | 35 | }
|
30 | 36 |
|
31 |
| -static inline void safe_clock_gettime(const char *file, const int lineno, |
| 37 | +static inline int safe_clock_gettime(const char *file, const int lineno, |
32 | 38 | clockid_t clk_id, struct timespec *tp)
|
33 | 39 | {
|
34 | 40 | int rval;
|
35 | 41 |
|
36 | 42 | rval = clock_gettime(clk_id, tp);
|
37 |
| - if (rval != 0) { |
38 |
| - tst_brk(TBROK | TERRNO, |
39 |
| - "%s:%d clock_gettime(%s) failed", |
40 |
| - file, lineno, tst_clock_name(clk_id)); |
| 43 | + |
| 44 | + if (rval == -1) { |
| 45 | + tst_brk_(file, lineno, TBROK | TERRNO, |
| 46 | + "clock_gettime(%s) failed", tst_clock_name(clk_id)); |
| 47 | + } else if (rval) { |
| 48 | + tst_brk_(file, lineno, TBROK | TERRNO, |
| 49 | + "Invalid clock_gettime(%s) return value %d", |
| 50 | + tst_clock_name(clk_id), rval); |
41 | 51 | }
|
| 52 | + |
| 53 | + return rval; |
42 | 54 | }
|
43 | 55 |
|
44 | 56 |
|
45 |
| -static inline void safe_clock_settime(const char *file, const int lineno, |
| 57 | +static inline int safe_clock_settime(const char *file, const int lineno, |
46 | 58 | clockid_t clk_id, struct timespec *tp)
|
47 | 59 | {
|
48 | 60 | int rval;
|
49 | 61 |
|
50 | 62 | rval = clock_settime(clk_id, tp);
|
51 |
| - if (rval != 0) { |
52 |
| - tst_brk(TBROK | TERRNO, |
53 |
| - "%s:%d clock_gettime(%s) failed", |
54 |
| - file, lineno, tst_clock_name(clk_id)); |
| 63 | + |
| 64 | + if (rval == -1) { |
| 65 | + tst_brk_(file, lineno, TBROK | TERRNO, |
| 66 | + "clock_gettime(%s) failed", tst_clock_name(clk_id)); |
| 67 | + } else if (rval) { |
| 68 | + tst_brk_(file, lineno, TBROK | TERRNO, |
| 69 | + "Invalid clock_gettime(%s) return value %d", |
| 70 | + tst_clock_name(clk_id), rval); |
55 | 71 | }
|
| 72 | + |
| 73 | + return rval; |
56 | 74 | }
|
57 | 75 |
|
58 | 76 | static inline int safe_timer_create(const char *file, const int lineno,
|
|
0 commit comments