Debian Codegraph @

testsuite/systemtap.syscall/sigmask.c

raw
1 /* COVERAGE: sgetmask ssetmask */
2 #define _BSD_SOURCE
3 #define _DEFAULT_SOURCE
4 #define _GNU_SOURCE
5 #include <sys/types.h>
6 #include <unistd.h>
7 #include <signal.h>
8 #include <string.h>
9 #include <sys/syscall.h>
10
11 // For these obsolete syscalls, there are no glibc wrappers, so create
12 // our own.
13
14 #ifdef SYS_sgetmask
15 static inline long __sgetmask(void)
16 {
17 return syscall(SYS_sgetmask);
18 }
19 #endif
20
21 #ifdef SYS_ssetmask
22 static inline long __ssetmask(long newmask)
23 {
24 return syscall(SYS_ssetmask, newmask);
25 }
26 #endif
27
28 int main()
29 {
30 #if defined(SYS_sgetmask) && defined(SYS_ssetmask)
31 long orig_mask;
32
33 orig_mask = __sgetmask();
34 //staptest// sgetmask () = NNNN
35
36 __ssetmask(sigmask(SIGUSR1));
37 //staptest// ssetmask (\[SIGUSR1\]) = NNNN
38
39 /* Limit testing */
40 __ssetmask(-1);
41 //staptest// ssetmask (\[SIGHUP|SIG[^ ]+\]) = NNNN
42
43 /* Restore original signal mask. */
44 __ssetmask(orig_mask);
45 //staptest// ssetmask (\[.*\]) = NNNN
46 #endif
47
48 return 0;
49 }