summaryrefslogtreecommitdiff
path: root/libhw_generic/include/libhw/generic/io.h
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-02-23 09:24:31 -0700
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-03-25 19:03:06 -0600
commit467c9e2bdbe1192635c786b4ae2120e2ffc7fb63 (patch)
tree19150835e332d47133c7e372bcb8513c6e9f76a6 /libhw_generic/include/libhw/generic/io.h
parent654b1940705197f22ffeebd73e62cea2282bdbda (diff)
libhw/generic/net.h: Tidy up the interfaces
Diffstat (limited to 'libhw_generic/include/libhw/generic/io.h')
-rw-r--r--libhw_generic/include/libhw/generic/io.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/libhw_generic/include/libhw/generic/io.h b/libhw_generic/include/libhw/generic/io.h
index 681c5ef..9128bd3 100644
--- a/libhw_generic/include/libhw/generic/io.h
+++ b/libhw_generic/include/libhw/generic/io.h
@@ -9,6 +9,8 @@
#include <stddef.h> /* for size_t */
+#include <libobj/obj.h>
+
/* structs ********************************************************************/
#if __unix__
@@ -26,4 +28,25 @@ struct duplex_iovec {
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_ */