ftmemsim-valgrind/memcheck/tests/linux/check_preadv2_pwritev2.c
Philippe Waroquiers 4b39d33437 Fix compilation problem when __NR_preadv2 __NR_pwritev2 are undefined
check_preadv2_pwritev2.c: In function ‘main’:
check_preadv2_pwritev2.c:12:12: error: ‘__NR_preadv2’ undeclared (first use in this function)
    syscall(__NR_preadv2, 0, NULL, 0, 0, 0);
            ^
check_preadv2_pwritev2.c:12:12: note: each undeclared identifier is reported only once for each function it appears in
check_preadv2_pwritev2.c:15:12: error: ‘__NR_pwritev2’ undeclared (first use in this function)
    syscall(__NR_pwritev2, 0, NULL, 0, 0, 0);
2019-08-17 18:27:22 +02:00

28 lines
520 B
C

#include <sys/syscall.h>
#include <errno.h>
#include <unistd.h>
#include <stddef.h>
int main(int argc, char **argv)
{
int has_preadv2 = 0;
int has_pwritev2 = 0;
#if defined(__NR_preadv2)
errno = 0;
syscall(__NR_preadv2, 0, NULL, 0, 0, 0);
has_preadv2 = errno != ENOSYS;
#else
has_preadv2 = 0;
#endif
#if defined(__NR_pwritev2)
errno = 0;
syscall(__NR_pwritev2, 0, NULL, 0, 0, 0);
has_pwritev2 = errno != ENOSYS;
#else
has_pwritev2 = 0;
#endif
return !(has_preadv2 && has_pwritev2);
}