Debian Codegraph @

testsuite/systemtap.syscall/arch_prctl.c

raw
1 /* COVERAGE: arch_prctl */
2
3 #define _GNU_SOURCE
4 #include <unistd.h>
5 #include <sys/syscall.h>
6
7 #ifdef __NR_arch_prctl
8
9 #include <asm/prctl.h>
10 #include <sys/prctl.h>
11
12 // This decl is missing from glibc; it's a deprecated syscall.
13 #define arch_prctl(x,y) syscall(__NR_arch_prctl,x,y)
14
15 int main()
16 {
17 unsigned long fs;
18 arch_prctl(ARCH_GET_FS, &fs);
19 //staptest// arch_prctl (ARCH_GET_FS, XXXX) = NNNN
20
21 arch_prctl(-1, &fs);
22 //staptest// arch_prctl (-1, XXXX) = NNNN (EINVAL)
23
24 // 2 variants: one for get- and one for set- cmds:
25 // int arch_prctl(int code, unsigned long addr);
26 // int arch_prctl(int code, unsigned long *addr);
27
28 arch_prctl(0, (unsigned long *)-1);
29 #if __WORDSIZE == 64
30 //staptest// arch_prctl (0, 18446744073709551615) = NNNN (EINVAL)
31 #else
32 //staptest// arch_prctl (0, 4294967295) = NNNN (EINVAL)
33 #endif
34
35 arch_prctl(0, (unsigned long)-1);
36 #if __WORDSIZE == 64
37 //staptest// arch_prctl (0, 18446744073709551615) = NNNN (EINVAL)
38 #else
39 //staptest// arch_prctl (0, 4294967295) = NNNN (EINVAL)
40 #endif
41
42 return 0;
43 }
44 #else
45 int main()
46 {
47 return 0;
48 }
49 #endif