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