7 #include <sys/syscall.h>
10 #include "../../memcheck.h"
14 int main(int argc
, char **argv
)
16 char str0
[] = "hello ";
17 char str1
[] = "world\n";
21 fd
= open("prwv2_source", O_CREAT
| O_RDWR
, 0644);
23 perror("prwv2_source");
27 iov
[0].iov_base
= str0
;
28 iov
[0].iov_len
= strlen(str0
);
29 iov
[1].iov_base
= str1
;
30 iov
[1].iov_len
= strlen(str1
);
32 /* Check pwritev2 and preadv2 called with the correct arguments works. */
33 if (pwritev2(fd
, iov
, 2, 0, 0) == -1) {
38 if (preadv2(fd
, iov
, 2, 0, 0) == -1) {
40 printf("errno: %d\n", errno
);
44 /* Check valgrind will produce expected warnings for the
45 various wrong arguments. */
47 /* always allocate 16 bytes to not to have different .exps for different reg sizes */
48 char *mem
= malloc(16);
49 void *t
= (void *) &mem
[0];
50 void *z
= (void *) -1;
51 int c
= *((int *) &mem
[4]);
52 int flag
= *((int *) &mem
[8]);
53 pwritev2(fd
, NULL
, 2, 0, 0);
54 pwritev2(fd
, z
, 2, 0, 0);
55 pwritev2(fd
, t
, 2, 0, 0);
56 pwritev2(fd
, iov
, -1, 0, 0);
57 pwritev2(fd
, iov
, c
, 0, 0);
58 pwritev2(fd
, iov
, 2, -5, 0);
59 pwritev2(-1, iov
, 2, -5, 0);
60 pwritev2(fd
, iov
, 2, -5, flag
);
62 preadv2(fd
, NULL
, 2, 0, 0);
63 preadv2(fd
, z
, 2, 0, 0);
64 preadv2(fd
, t
, 2, 0, 0);
65 preadv2(fd
, iov
, -1, 0, 0);
66 preadv2(fd
, iov
, c
, 0, 0);
67 preadv2(fd
, iov
, 2, -5, 0);
68 preadv2(-1, iov
, 2, -5, 0);
70 iov
[1].iov_base
= (void *) -1;
71 pwritev2(fd
, iov
, 2, 0, 0);
72 preadv2(fd
, iov
, 2, 0, 0);
77 unlink("prwv2_source");