2 * Copyright (c) 2016 Eugene Syromyatnikov <evgsyr@gmail.com>
3 * Copyright (c) 2016-2017 The strace developers.
6 * SPDX-License-Identifier: GPL-2.0-or-later
10 #include <asm/unistd.h>
13 /* Check for glibc readahead argument passing bugs. */
16 * glibc < 2.8 had an incorrect order of higher and lower parts of offset,
17 * see https://sourceware.org/bugzilla/show_bug.cgi?id=5208
19 # if !(defined __GLIBC_MINOR__ && \
20 (__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 8)
21 # undef HAVE_READAHEAD
22 # endif /* glibc < 2.8 */
24 * glibc < 2.25 had an incorrect implementation on mips n64,
25 * see https://sourceware.org/bugzilla/show_bug.cgi?id=21026
27 # if defined LINUX_MIPSN64 && !(defined __GLIBC_MINOR__ && \
28 (__GLIBC__ << 16) + __GLIBC_MINOR__ >= (2 << 16) + 25)
29 # undef HAVE_READAHEAD
30 # endif /* LINUX_MIPSN64 && glibc < 2.25 */
31 # endif /* __GLIBC__ */
32 #endif /* HAVE_READAHEAD */
39 static const int fds[] = {
49 static const off64_t offsets[] = {
50 -0x8000000000000000LL,
51 -0x5060708090a0b0c0LL,
59 static const unsigned long counts[] = {
62 (unsigned long) 0xface1e55beeff00dULL,
63 (unsigned long) 0xffffffffffffffffULL,
74 for (i = 0; i < ARRAY_SIZE(fds); i++)
75 for (j = 0; j < ARRAY_SIZE(offsets); j++)
76 for (k = 0; k < ARRAY_SIZE(counts); k++) {
77 rc = readahead(fds[i], offsets[j], counts[k]);
79 printf("readahead(%d, %lld, %lu) = %s\n",
80 fds[i], (long long) offsets[j],
81 counts[k], sprintrc(rc));
84 puts("+++ exited with 0 +++");
90 SKIP_MAIN_UNDEFINED("HAVE_READAHEAD")