xref: /haiku/src/system/libroot/posix/sys/uio.c (revision 3cb015b1ee509d69c643506e8ff573808c86dcfc)
1 /*
2 ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 ** Distributed under the terms of the Haiku License.
4 */
5 
6 
7 #include <syscalls.h>
8 
9 #include <sys/uio.h>
10 #include <errno.h>
11 
12 
13 #define RETURN_AND_SET_ERRNO(err) \
14 	if (err < 0) { \
15 		errno = err; \
16 		return -1; \
17 	} \
18 	return err;
19 
20 
21 ssize_t
22 readv(int fd, const struct iovec *vecs, size_t count)
23 {
24 	ssize_t bytes = _kern_readv(fd, -1, vecs, count);
25 
26 	RETURN_AND_SET_ERRNO(bytes);
27 }
28 
29 
30 ssize_t
31 readv_pos(int fd, off_t pos, const struct iovec *vecs, size_t count)
32 {
33 	ssize_t bytes = _kern_readv(fd, pos, vecs, count);
34 
35 	RETURN_AND_SET_ERRNO(bytes);
36 }
37 
38 
39 ssize_t
40 writev(int fd, const struct iovec *vecs, size_t count)
41 {
42 	ssize_t bytes = _kern_writev(fd, -1, vecs, count);
43 
44 	RETURN_AND_SET_ERRNO(bytes);
45 }
46 
47 
48 ssize_t
49 writev_pos(int fd, off_t pos, const struct iovec *vecs, size_t count)
50 {
51 	ssize_t bytes = _kern_writev(fd, pos, vecs, count);
52 
53 	RETURN_AND_SET_ERRNO(bytes);
54 }
55 
56