diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-03-29 22:16:43 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-03-29 22:16:43 -0700 |
| commit | 83617eac5902a9e66449e8c409dfa9e560bf9f12 (patch) | |
| tree | fe282b9e52d206f71a0cd32798eebd1ca305962f /lib/std/event/loop.zig | |
| parent | 9821a0c6f0caf3df4cc6000c000d9cc38baf27d8 (diff) | |
| download | zig-83617eac5902a9e66449e8c409dfa9e560bf9f12.tar.gz zig-83617eac5902a9e66449e8c409dfa9e560bf9f12.zip | |
std: avoid referencing event loop when io_mode is blocking
This prevents unwanted symbols from ending up in the output binary.
Diffstat (limited to 'lib/std/event/loop.zig')
| -rw-r--r-- | lib/std/event/loop.zig | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig index 23c89aabc5..1eaa95d249 100644 --- a/lib/std/event/loop.zig +++ b/lib/std/event/loop.zig @@ -103,12 +103,17 @@ pub const Loop = struct { }; }; - var global_instance_state: Loop = undefined; - const default_instance: ?*Loop = switch (std.io.mode) { + const LoopOrVoid = switch (std.io.mode) { + .blocking => void, + .evented => Loop, + }; + + var global_instance_state: LoopOrVoid = undefined; + const default_instance: ?*LoopOrVoid = switch (std.io.mode) { .blocking => null, .evented => &global_instance_state, }; - pub const instance: ?*Loop = if (@hasDecl(root, "event_loop")) root.event_loop else default_instance; + pub const instance: ?*LoopOrVoid = if (@hasDecl(root, "event_loop")) root.event_loop else default_instance; /// TODO copy elision / named return values so that the threads referencing *Loop /// have the correct pointer value. |
