Mike Frysinger | 97ca027 | 2014-08-11 02:52:08 -0400 | [diff] [blame] | 1 | #ifdef HAVE_CONFIG_H |
| 2 | # include "config.h" |
| 3 | #endif |
Dmitry V. Levin | cc3d591 | 2014-04-16 23:28:29 +0000 | [diff] [blame] | 4 | #include <fcntl.h> |
| 5 | #include <unistd.h> |
| 6 | #include <sys/uio.h> |
| 7 | #include <assert.h> |
| 8 | |
| 9 | int |
| 10 | main(void) |
| 11 | { |
Mike Frysinger | 97ca027 | 2014-08-11 02:52:08 -0400 | [diff] [blame] | 12 | #if defined(HAVE_PREADV) && defined(HAVE_PWRITEV) |
Dmitry V. Levin | cc3d591 | 2014-04-16 23:28:29 +0000 | [diff] [blame] | 13 | const off_t offset = 0xdefaceddeadbeefLL; |
| 14 | int fd; |
| 15 | char buf[4]; |
| 16 | struct iovec iov = { buf, sizeof buf }; |
| 17 | |
| 18 | assert((fd = open("/dev/zero", O_RDONLY)) >= 0); |
| 19 | assert(pread(fd, buf, sizeof buf, offset) == 4); |
| 20 | assert(preadv(fd, &iov, 1, offset) == 4); |
| 21 | assert(!close(fd)); |
| 22 | |
| 23 | assert((fd = open("/dev/null", O_WRONLY)) >= 0); |
| 24 | assert(pwrite(fd, buf, sizeof buf, offset) == 4); |
| 25 | assert(pwritev(fd, &iov, 1, offset) == 4); |
| 26 | assert(!close(fd)); |
| 27 | |
| 28 | return 0; |
Mike Frysinger | 97ca027 | 2014-08-11 02:52:08 -0400 | [diff] [blame] | 29 | #else |
| 30 | return 77; |
| 31 | #endif |
Dmitry V. Levin | cc3d591 | 2014-04-16 23:28:29 +0000 | [diff] [blame] | 32 | } |