From ad541c67761b8aa6da1566802c347cac4018d0c2 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Mon, 2 Nov 2026 20:50:24 +0100 Subject: Move the build sources into src/ --- src/ot_event.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/ot_event.h (limited to 'src/ot_event.h') diff --git a/src/ot_event.h b/src/ot_event.h new file mode 100644 index 0000000..cb84ca8 --- /dev/null +++ b/src/ot_event.h @@ -0,0 +1,47 @@ +/* This software was written by Dirk Engling + It is considered beerware. Prost. Skol. Cheers or whatever. */ + +#ifndef OT_EVENT_H__ +#define OT_EVENT_H__ + +#include + +/* Which descriptors have become readable or writable, asked of whichever + mechanism the kernel offers. The generation a descriptor was registered + with is handed back with every event, so a caller can tell an event for + the connection it is holding from one for a connection that has since been + closed and had its number reused. */ + +enum { EVENT_IN = 1, EVENT_OUT = 2 }; + +typedef struct { + int fd; + uint32_t generation; + int what; +} ot_event; + +int event_init(void); +void event_deinit(void); + +int event_add(int fd, int what, uint32_t generation); +int event_modify(int fd, int what, uint32_t generation); +int event_del(int fd); + +/* Stop watching a descriptor and close it. Where the kernel drops a closed + descriptor from its set by itself, this is one system call where doing the + two separately would be two. */ +int event_close(int fd); + +/* Waits at most timeout_ms, or indefinitely when that is negative, and fills + out with up to max ready descriptors. Returns how many, or -1. */ +int event_wait(ot_event *out, int max, int timeout_ms); + +/* Whether the registered set may be changed from another thread while this + one is waiting on it. True where the kernel keeps the set, false where + this module keeps it in memory of its own. */ +int event_can_share(void); + +/* Which mechanism was compiled in, for the version string */ +const char *event_mechanism(void); + +#endif -- cgit v1.3