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) {...@@ -35,7 +35,7 @@ const os_has_fork = switch (builtin.os.tag) {
35};35};
36const os_has_arc4random = builtin.link_libc and @hasDecl(std.c, "arc4random_buf");36const os_has_arc4random = builtin.link_libc and @hasDecl(std.c, "arc4random_buf");
37const want_fork_safety = os_has_fork and !os_has_arc4random and37const 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;
39const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{39const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{
40 .major = 4,40 .major = 4,
41 .minor = 14,41 .minor = 14,
lib/std/meta.zig-7
...@@ -1099,13 +1099,6 @@ test "ArgsTuple forwarding" {...@@ -1099,13 +1099,6 @@ test "ArgsTuple forwarding" {
1099 }1099 }
1100}1100}
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
1109/// Returns whether `error_union` contains an error.1102/// Returns whether `error_union` contains an error.
1110pub fn isError(error_union: anytype) bool {1103pub fn isError(error_union: anytype) bool {
1111 return if (error_union) |_| false else |_| true;1104 return if (error_union) |_| false else |_| true;
lib/std/std.zig+5
...@@ -264,6 +264,11 @@ pub const options = struct {...@@ -264,6 +264,11 @@ pub const options = struct {
264 else264 else
265 false;265 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
267 /// By default Zig disables SIGPIPE by setting a "no-op" handler for it. Set this option272 /// By default Zig disables SIGPIPE by setting a "no-op" handler for it. Set this option
268 /// to `true` to prevent that.273 /// to `true` to prevent that.
269 ///274 ///