diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-02 20:50:24 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2026-11-02 21:14:02 +0100 |
| commit | ad541c67761b8aa6da1566802c347cac4018d0c2 (patch) | |
| tree | a9166fa9d349911d69a6948e53b05344dcc348a0 /src/ot_event.h | |
| parent | c679ff8a3b1418a5960cc49ba6458a0007df54fa (diff) | |
Move the build sources into src/
Diffstat (limited to 'src/ot_event.h')
| -rw-r--r-- | src/ot_event.h | 47 |
1 files changed, 47 insertions, 0 deletions
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 @@ | |||
| 1 | /* This software was written by Dirk Engling <erdgeist@erdgeist.org> | ||
| 2 | It is considered beerware. Prost. Skol. Cheers or whatever. */ | ||
| 3 | |||
| 4 | #ifndef OT_EVENT_H__ | ||
| 5 | #define OT_EVENT_H__ | ||
| 6 | |||
| 7 | #include <stdint.h> | ||
| 8 | |||
| 9 | /* Which descriptors have become readable or writable, asked of whichever | ||
| 10 | mechanism the kernel offers. The generation a descriptor was registered | ||
| 11 | with is handed back with every event, so a caller can tell an event for | ||
| 12 | the connection it is holding from one for a connection that has since been | ||
| 13 | closed and had its number reused. */ | ||
| 14 | |||
| 15 | enum { EVENT_IN = 1, EVENT_OUT = 2 }; | ||
| 16 | |||
| 17 | typedef struct { | ||
| 18 | int fd; | ||
| 19 | uint32_t generation; | ||
| 20 | int what; | ||
| 21 | } ot_event; | ||
| 22 | |||
| 23 | int event_init(void); | ||
| 24 | void event_deinit(void); | ||
| 25 | |||
| 26 | int event_add(int fd, int what, uint32_t generation); | ||
| 27 | int event_modify(int fd, int what, uint32_t generation); | ||
| 28 | int event_del(int fd); | ||
| 29 | |||
| 30 | /* Stop watching a descriptor and close it. Where the kernel drops a closed | ||
| 31 | descriptor from its set by itself, this is one system call where doing the | ||
| 32 | two separately would be two. */ | ||
| 33 | int event_close(int fd); | ||
| 34 | |||
| 35 | /* Waits at most timeout_ms, or indefinitely when that is negative, and fills | ||
| 36 | out with up to max ready descriptors. Returns how many, or -1. */ | ||
| 37 | int event_wait(ot_event *out, int max, int timeout_ms); | ||
| 38 | |||
| 39 | /* Whether the registered set may be changed from another thread while this | ||
| 40 | one is waiting on it. True where the kernel keeps the set, false where | ||
| 41 | this module keeps it in memory of its own. */ | ||
| 42 | int event_can_share(void); | ||
| 43 | |||
| 44 | /* Which mechanism was compiled in, for the version string */ | ||
| 45 | const char *event_mechanism(void); | ||
| 46 | |||
| 47 | #endif | ||
