Skip to content

Commit

Permalink
std: remove meta.globalOption
Browse files Browse the repository at this point in the history
  • Loading branch information
Vexu authored and andrewrk committed Jan 27, 2024
1 parent 190ea02 commit c085c6e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/std/crypto/tlcsprng.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 0 additions & 7 deletions lib/std/meta.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions lib/std/std.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down

0 comments on commit c085c6e

Please sign in to comment.