1 /*
2 * Copyright (c) 2018 Cyril Hrubis <chrubis@suse.cz>
3 */
4
5 #ifndef SAFE_RT_SIGNAL_H__
6 #define SAFE_RT_SIGNAL_H__
7
8 #include <signal.h>
9 #include "lapi/rt_sigaction.h"
10
safe_rt_sigaction(const char * file,const int lineno,int signum,const struct sigaction * act,struct sigaction * oact,size_t sigsetsize)11 static inline int safe_rt_sigaction(const char *file, const int lineno,
12 int signum, const struct sigaction *act,
13 struct sigaction *oact, size_t sigsetsize)
14 {
15 int ret;
16
17 ret = ltp_rt_sigaction(signum, act, oact, sigsetsize);
18 if (ret < 0) {
19 tst_brk(TBROK | TERRNO,
20 "%s:%d: ltp_rt_sigaction(%i, %p, %p, %zu) failed",
21 file, lineno, signum, act, oact, sigsetsize);
22 }
23
24 return ret;
25 }
26
27 #define SAFE_RT_SIGACTION(signum, act, oldact, sigsetsize) \
28 safe_rt_sigaction(__FILE__, __LINE__, signum, act, oldact, sigsetsize)
29
30
safe_rt_sigprocmask(const char * file,const int lineno,int how,const sigset_t * set,sigset_t * oldset,size_t sigsetsize)31 static inline int safe_rt_sigprocmask(const char *file, const int lineno,
32 int how, const sigset_t *set,
33 sigset_t *oldset, size_t sigsetsize)
34 {
35 int ret;
36
37 ret = tst_syscall(__NR_rt_sigprocmask, how, set, oldset, sigsetsize);
38 if (ret < 0) {
39 tst_brk(TBROK | TERRNO,
40 "%s:%d: rt_sigprocmask(%i, %p, %p, %zu) failed",
41 file, lineno, how, set, oldset, sigsetsize);
42 }
43
44 return ret;
45 }
46
47 #define SAFE_RT_SIGPROCMASK(how, set, oldset, sigsetsize) \
48 safe_rt_sigprocmask(__FILE__, __LINE__, how, set, oldset, sigsetsize)
49
50 #endif /* SAFE_RT_SIGNAL_H__ */
51