[C++20] [Modules] Fix may-be incorrect ADL for module local entities (#123931)
[llvm-project.git] / compiler-rt / test / sanitizer_common / TestCases / Linux / preadv2.cpp
blob4ec6f9f69078acfbd301cc56a6cae6d79f220bd1
1 // RUN: %clangxx -O0 %s -o %t
3 // REQUIRES: glibc
5 #include <assert.h>
6 #include <fcntl.h>
7 #include <sys/uio.h>
8 #include <unistd.h>
10 #if !defined(__GLIBC_PREREQ)
11 #define __GLIBC_PREREQ(a, b) 0
12 #endif
14 #if !__GLIBC_PREREQ(2, 26)
15 #define preadv2(a, b, c, d, e) preadv(a, b, c, d)
16 #endif
18 int main(void) {
19 int fd = open("/proc/self/stat", O_RDONLY);
20 char bufa[7];
21 char bufb[7];
22 struct iovec vec[2];
23 vec[0].iov_base = bufa + 4;
24 vec[0].iov_len = 1;
25 vec[1].iov_base = bufb;
26 vec[1].iov_len = sizeof(bufb);
27 ssize_t rd = preadv2(fd, vec, 2, 0, 0);
28 assert(rd > 0);
29 vec[0].iov_base = bufa;
30 rd = preadv2(fd, vec, 2, 0, 0);
31 assert(rd > 0);
32 rd = preadv2(fd, vec, 5, -25, 0);
33 assert(rd < 0);
34 close(fd);
35 return 0;