diff options
| author | Matthew Lugg <mlugg@mlugg.co.uk> | 2025-10-28 12:42:05 +0000 |
|---|---|---|
| committer | Matthew Lugg <mlugg@mlugg.co.uk> | 2025-10-30 09:31:28 +0000 |
| commit | 74931fe25cdd94e1cd08b5ece9dcce19959bc079 (patch) | |
| tree | 75449b1d594d55a872aeb03f2dd3be16ac396274 /tools/generate_linux_syscalls.zig | |
| parent | 74c23a237ef5245b63eb06b832a511aabeb715c0 (diff) | |
| download | zig-74931fe25cdd94e1cd08b5ece9dcce19959bc079.tar.gz zig-74931fe25cdd94e1cd08b5ece9dcce19959bc079.zip | |
std.debug.lockStderrWriter: also return ttyconf
`std.Io.tty.Config.detect` may be an expensive check (e.g. involving
syscalls), and doing it every time we need to print isn't really
necessary; under normal usage, we can compute the value once and cache
it for the whole program's execution. Since anyone outputting to stderr
may reasonably want this information (in fact they are very likely to),
it makes sense to cache it and return it from `lockStderrWriter`. Call
sites who do not need it will experience no significant overhead, and
can just ignore the TTY config with a `const w, _` destructure.
Diffstat (limited to 'tools/generate_linux_syscalls.zig')
| -rw-r--r-- | tools/generate_linux_syscalls.zig | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/generate_linux_syscalls.zig b/tools/generate_linux_syscalls.zig index 2705618a7d..e009715e2f 100644 --- a/tools/generate_linux_syscalls.zig +++ b/tools/generate_linux_syscalls.zig @@ -177,7 +177,9 @@ pub fn main() !void { const args = try std.process.argsAlloc(gpa); if (args.len < 2 or mem.eql(u8, args[1], "--help")) { - usage(std.debug.lockStderrWriter(&.{}), args[0]) catch std.process.exit(2); + const w, _ = std.debug.lockStderrWriter(&.{}); + defer std.debug.unlockStderrWriter(); + usage(w, args[0]) catch std.process.exit(2); std.process.exit(1); } const linux_path = args[1]; |
