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("prwv_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 pwritev and preadv called with the correct arguments works. */
33 if (pwritev(fd
, iov
, 2, 0) == -1) {
38 if (preadv(fd
, iov
, 2, 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 pwritev(fd
, NULL
, 2, 0);
55 pwritev(fd
, iov
, -1, 0);
56 pwritev(fd
, iov
, c
, 0);
57 pwritev(fd
, iov
, 2, -5);
58 pwritev(-1, iov
, 2, -5);
60 preadv(fd
, NULL
, 2, 0);
63 preadv(fd
, iov
, -1, 0);
64 preadv(fd
, iov
, c
, 0);
65 preadv(fd
, iov
, 2, -5);
66 preadv(-1, iov
, 2, -5);
68 iov
[1].iov_base
= (void *) -1;
69 pwritev(fd
, iov
, 2, 0);
70 preadv(fd
, iov
, 2, 0);
75 unlink("prwv_source");