Debian Codegraph @

testsuite/systemtap.syscall/kcmp.c

raw
1 /* COVERAGE: kcmp */
2
3 #define _GNU_SOURCE
4 #include <sys/types.h>
5 #include <unistd.h>
6 #include <sys/syscall.h>
7 #include <sys/stat.h>
8 #include <fcntl.h>
9
10 #ifdef __NR_kcmp
11 // The kernel-headers-3.13.9-200.fc20 doesn't have linux/kcmp.h,
12 // thus defining needed enum here:
13 enum kcmp_type {
14 KCMP_FILE,
15 KCMP_VM,
16 KCMP_FILES,
17 KCMP_FS,
18 KCMP_SIGHAND,
19 KCMP_IO,
20 KCMP_SYSVSEM,
21 KCMP_TYPES,
22 };
23
24 static inline int __kcmp(pid_t pid1, pid_t pid2, int type,
25 unsigned long idx1, unsigned long idx2)
26 {
27 return syscall(__NR_kcmp, pid1, pid2, type, idx1, idx2);
28 }
29
30 int main()
31 {
32 int mypid = getpid();
33 unsigned long fd = open("kcmp_testfile", O_CREAT);
34
35 __kcmp(mypid, mypid, KCMP_FILE, fd, fd);
36 //staptest// [[[[kcmp (NNNN, NNNN, KCMP_FILE, NNNN, NNNN) = 0!!!!ni_syscall () = -38 (ENOSYS)]]]]
37
38 // Limit testing
39
40 __kcmp(-1, 0, 0, 0, 0);
41 //staptest// [[[[kcmp (-1, 0, KCMP_FILE, 0, 0)!!!!ni_syscall ()]]]] = -NNNN
42
43 __kcmp(0, -1, 0, 0, 0);
44 //staptest// [[[[kcmp (0, -1, KCMP_FILE, 0, 0)!!!!ni_syscall ()]]]] = -NNNN
45
46 __kcmp(0, 0, -1, 0, 0);
47 //staptest// [[[[kcmp (0, 0, 0x[f]+, 0, 0)!!!!ni_syscall ()]]]] = -NNNN
48
49 __kcmp(0, 0, 0, -1, 0);
50 #if __WORDSIZE == 64
51 //staptest// [[[[kcmp (0, 0, KCMP_FILE, 18446744073709551615, 0)!!!!ni_syscall ()]]]] = -NNNN
52 #else
53 //staptest// [[[[kcmp (0, 0, KCMP_FILE, 4294967295, 0)!!!!ni_syscall ()]]]] = -NNNN
54 #endif
55
56 __kcmp(0, 0, 0, 0, -1);
57 #if __WORDSIZE == 64
58 //staptest// [[[[kcmp (0, 0, KCMP_FILE, 0, 18446744073709551615)!!!!ni_syscall ()]]]] = -NNNN
59 #else
60 //staptest// [[[[kcmp (0, 0, KCMP_FILE, 0, 4294967295)!!!!ni_syscall ()]]]] = -NNNN
61 #endif
62
63
64 close(fd);
65 unlink("kcmp_testfile");
66 return 0;
67 }
68 #else
69 int main()
70 {
71 return 0;
72 }
73 #endif /* ifdef __NR_kcmp */