unix.h (1631B)
1 #pragma once 2 3 #include <sys/uio.h> 4 5 #include "def.h" 6 7 /* On success, read exactly len bytes from fd into buf and return 0. On failure 8 * (i.e., any error except EINTR, or EOF before len bytes are read into buf), 9 * return -1 and set errno in the same manner as read(2), or set errno to 0 in 10 * the case of premature EOF. In either case, if n is not NULL, set *n to the 11 * number of bytes actually read (which is less than len iff an error or 12 * premature EOF occurred). */ 13 int r_read_all(usize *n, int fd, void *buf, usize len); 14 15 /* On success, write exactly len bytes from buf to fd and return 0. On failure 16 * (i.e, any error except EINTR), return -1 and set errno in the same manner as 17 * write(2). In either case, if n is not NULL, set *n to the number of bytes 18 * actually written (which is less than len iff an error occurred). */ 19 int r_write_all(usize *n, int fd, void *buf, usize len); 20 21 /* Copy n bytes from (*iov, *niov) to dst. Increment the base pointer and 22 * decrement the length in each iovec according to the number of bytes copied. 23 * There must be at least n bytes in (*iov, *niov). */ 24 void r_iovec_gather(void *dst, struct iovec **iov, usize *niov, usize n); 25 26 /* TODO */ 27 /* int r_readv_all(int fd, struct iovec **iov, usize *niov); */ 28 29 /* On success, write all bytes from (*iov, *niov) to fd and return 0. On 30 * failure (i.e., any error except EINTR), return -1 and set errno in the same 31 * manner as writev(2). In either case, increment the base pointer and 32 * decrement the length in each iovec according to the number of bytes actually 33 * written. */ 34 int r_writev_all(int fd, struct iovec **iov, usize *niov);