From c085c6ecdd4b9436955ba2bb38f829100ed9b33d Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Fri, 26 Jan 2024 15:38:22 +0200 Subject: [PATCH] std: remove meta.globalOption --- lib/std/crypto/tlcsprng.zig | 2 +- lib/std/meta.zig | 7 ------- lib/std/std.zig | 5 +++++ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/std/crypto/tlcsprng.zig b/lib/std/crypto/tlcsprng.zig index e6c6b56f13..cdb3494fc6 100644 --- a/lib/std/crypto/tlcsprng.zig +++ b/lib/std/crypto/tlcsprng.zig @@ -35,7 +35,7 @@ const os_has_fork = switch (builtin.os.tag) { }; const os_has_arc4random = builtin.link_libc and @hasDecl(std.c, "arc4random_buf"); const want_fork_safety = os_has_fork and !os_has_arc4random and - (std.meta.globalOption("crypto_fork_safety", bool) orelse true); + std.options.crypto_fork_safety; const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{ .major = 4, .minor = 14, diff --git a/lib/std/meta.zig b/lib/std/meta.zig index f77ed6d344..922324c8c3 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -1099,13 +1099,6 @@ test "ArgsTuple forwarding" { } } -/// TODO: https://github.com/ziglang/zig/issues/425 -pub fn globalOption(comptime name: []const u8, comptime T: type) ?T { - if (!@hasDecl(root, name)) - return null; - return @as(T, @field(root, name)); -} - /// Returns whether `error_union` contains an error. pub fn isError(error_union: anytype) bool { return if (error_union) |_| false else |_| true; diff --git a/lib/std/std.zig b/lib/std/std.zig index 66e30c4b4e..4500a281b7 100644 --- a/lib/std/std.zig +++ b/lib/std/std.zig @@ -264,6 +264,11 @@ pub const options = struct { else false; + pub const crypto_fork_safety: bool = if (@hasDecl(options_override, "crypto_fork_safety")) + options_override.crypto_fork_safety + else + true; + /// By default Zig disables SIGPIPE by setting a "no-op" handler for it. Set this option /// to `true` to prevent that. ///