authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2024-01-26 15:38:22+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-27 13:56:32-08:00
logc085c6ecdd4b9436955ba2bb38f829100ed9b33d
tree16192a1d0503e13d079838deffd5609004e86b3f
parent190ea02e0d0c939c0b558927b63a03e30af4749a

std: remove meta.globalOption


3 files changed, 6 insertions(+), 8 deletions(-)

lib/std/crypto/tlcsprng.zig+1-1
......@@ -35,7 +35,7 @@ const os_has_fork = switch (builtin.os.tag) {
3535};
3636const os_has_arc4random = builtin.link_libc and @hasDecl(std.c, "arc4random_buf");
3737const want_fork_safety = os_has_fork and !os_has_arc4random and
38 (std.meta.globalOption("crypto_fork_safety", bool) orelse true);
38 std.options.crypto_fork_safety;
3939const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{
4040 .major = 4,
4141 .minor = 14,
lib/std/meta.zig-7
......@@ -1099,13 +1099,6 @@ test "ArgsTuple forwarding" {
10991099 }
11001100}
11011101
1102/// TODO: https://github.com/ziglang/zig/issues/425
1103pub fn globalOption(comptime name: []const u8, comptime T: type) ?T {
1104 if (!@hasDecl(root, name))
1105 return null;
1106 return @as(T, @field(root, name));
1107}
1108
11091102/// Returns whether `error_union` contains an error.
11101103pub fn isError(error_union: anytype) bool {
11111104 return if (error_union) |_| false else |_| true;
lib/std/std.zig+5
......@@ -264,6 +264,11 @@ pub const options = struct {
264264 else
265265 false;
266266
267 pub const crypto_fork_safety: bool = if (@hasDecl(options_override, "crypto_fork_safety"))
268 options_override.crypto_fork_safety
269 else
270 true;
271
267272 /// By default Zig disables SIGPIPE by setting a "no-op" handler for it. Set this option
268273 /// to `true` to prevent that.
269274 ///