Blame


1 a3fc3b94 2023-12-19 op // This is free and unencumbered software released into the public domain.
2 a3fc3b94 2023-12-19 op //
3 a3fc3b94 2023-12-19 op // Anyone is free to copy, modify, publish, use, compile, sell, or
4 a3fc3b94 2023-12-19 op // distribute this software, either in source code form or as a compiled
5 a3fc3b94 2023-12-19 op // binary, for any purpose, commercial or non-commercial, and by any
6 a3fc3b94 2023-12-19 op // means.
7 a3fc3b94 2023-12-19 op //
8 a3fc3b94 2023-12-19 op // In jurisdictions that recognize copyright laws, the author or authors
9 a3fc3b94 2023-12-19 op // of this software dedicate any and all copyright interest in the
10 a3fc3b94 2023-12-19 op // software to the public domain. We make this dedication for the benefit
11 a3fc3b94 2023-12-19 op // of the public at large and to the detriment of our heirs and
12 a3fc3b94 2023-12-19 op // successors. We intend this dedication to be an overt act of
13 a3fc3b94 2023-12-19 op // relinquishment in perpetuity of all present and future rights to this
14 a3fc3b94 2023-12-19 op // software under copyright law.
15 a3fc3b94 2023-12-19 op //
16 a3fc3b94 2023-12-19 op // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 a3fc3b94 2023-12-19 op // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 a3fc3b94 2023-12-19 op // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 a3fc3b94 2023-12-19 op // IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 a3fc3b94 2023-12-19 op // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 a3fc3b94 2023-12-19 op // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 a3fc3b94 2023-12-19 op // OTHER DEALINGS IN THE SOFTWARE.
23 a3fc3b94 2023-12-19 op
24 a3fc3b94 2023-12-19 op use io;
25 a3fc3b94 2023-12-19 op use unix::poll;
26 a3fc3b94 2023-12-19 op
27 a3fc3b94 2023-12-19 op let _default = base {
28 a3fc3b94 2023-12-19 op add = &evadd,
29 a3fc3b94 2023-12-19 op del = &evdel,
30 a3fc3b94 2023-12-19 op loop = &loop,
31 a3fc3b94 2023-12-19 op loopbreak = &evloopbreak,
32 a3fc3b94 2023-12-19 op sigpipe = void,
33 a3fc3b94 2023-12-19 op sigcb = void,
34 a3fc3b94 2023-12-19 op ...
35 a3fc3b94 2023-12-19 op };
36 a3fc3b94 2023-12-19 op
37 a3fc3b94 2023-12-19 op let global = &_default;
38 a3fc3b94 2023-12-19 op
39 a3fc3b94 2023-12-19 op export fn add(
40 a3fc3b94 2023-12-19 op fd: io::file,
41 a3fc3b94 2023-12-19 op ev: event,
42 a3fc3b94 2023-12-19 op f: *fn(io::file, event, nullable *opaque) void,
43 a3fc3b94 2023-12-19 op data: nullable *opaque
44 a3fc3b94 2023-12-19 op ) void = {
45 a3fc3b94 2023-12-19 op global.add(global, fd, ev, f, data);
46 a3fc3b94 2023-12-19 op };
47 a3fc3b94 2023-12-19 op
48 a3fc3b94 2023-12-19 op export fn del(fd: io::file) void = {
49 a3fc3b94 2023-12-19 op global.del(global, fd);
50 a3fc3b94 2023-12-19 op };
51 a3fc3b94 2023-12-19 op
52 a3fc3b94 2023-12-19 op export fn mainloop() (void | poll::error) = global.loop(global);
53 a3fc3b94 2023-12-19 op
54 a3fc3b94 2023-12-19 op export fn loopbreak() void = {
55 a3fc3b94 2023-12-19 op global.loopbreak(global);
56 a3fc3b94 2023-12-19 op };