Debian Codegraph @

testsuite/systemtap.syscall/readahead.c

raw
1 /* COVERAGE: readahead */
2
3 #define _GNU_SOURCE
4 #include <stdlib.h>
5 #include <fcntl.h>
6 #include <unistd.h>
7 #include <sys/syscall.h>
8
9 int main() {
10 int fd;
11 char tempname[17] = "readahead_XXXXXX";
12
13 fd = mkstemp(tempname);
14
15 readahead(fd, 0, 0);
16 //staptest// readahead (NNNN, 0, 0) = 0
17
18 readahead(5, 0, 0);
19 //staptest// readahead (5, 0, 0)
20
21 // Before glibc 2.8, ppc (not ppc64) didn't pass the extra
22 // argument to compat_sys_readahead(). So, we'll need to skip
23 // calls with anything other than 0 passed as the offset or
24 // count.
25 #if !(defined(__powerpc__) && !defined(__powerpc64__)) || __GLIBC_PREREQ(2, 8)
26 // Before glibc 2.8, glibc passed 64-bit values backwards on
27 // several systems.
28 #if __GLIBC_PREREQ(2, 8)
29 readahead(0, 0x12345678abcdefabLL, 0);
30 //staptest// readahead (0, 1311768467750121387, 0)
31 #endif
32
33 readahead(0, 0, 5);
34 //staptest// readahead (0, 0, 5)
35
36 readahead(-1, 0, 0);
37 //staptest// readahead (-1, 0, 0) = NNNN
38
39 readahead(fd, -1LL, 0);
40 //staptest// readahead (NNNN, -1, 0) = 0
41
42 readahead(fd, 0, -1);
43 #if __WORDSIZE == 64
44 //staptest// readahead (NNNN, 0, 18446744073709551615) = NNNN
45 #else
46 //staptest// readahead (NNNN, 0, 4294967295) = NNNN
47 #endif
48 #endif
49
50 close(fd);
51 unlink(tempname);
52
53 return 0;
54 }