/* libhw/generic/io.h - Device-independent I/O definitions * * Copyright (C) 2024-2025 Luke T. Shumaker * SPDX-License-Identifier: AGPL-3.0-or-later */ #ifndef _LIBHW_GENERIC_IO_H_ #define _LIBHW_GENERIC_IO_H_ #include /* for size_t */ #include /* structs ********************************************************************/ #if __unix__ #include #else struct iovec { void *iov_base; size_t iov_len; }; #endif struct duplex_iovec { void *iov_read_dst; void *iov_write_src; size_t iov_len; }; /* basic interfaces ***********************************************************/ /** * Return 0 on success, -errno on error. */ #define io_closer_LO_IFACE \ LO_FUNC(int, close) LO_INTERFACE(io_closer) #define io_close(c) LO_CALL(c, close) /** * All methods return 0 on success, -errno on error. */ #define io_bidi_closer_LO_IFACE \ LO_NEST(io_closer) \ LO_FUNC(int, close_read) \ LO_FUNC(int, close_write) LO_INTERFACE(io_bidi_closer) #define io_close_read(c) LO_CALL(c, close_read) #define io_close_write(c) LO_CALL(c, close_write) #endif /* _LIBHW_GENERIC_IO_H_ */