| author | |
| committer | |
| log | c085c6ecdd4b9436955ba2bb38f829100ed9b33d |
| tree | 16192a1d0503e13d079838deffd5609004e86b3f |
| parent | 190ea02e0d0c939c0b558927b63a03e30af4749a |
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 | }; |
| 36 | const os_has_arc4random = builtin.link_libc and @hasDecl(std.c, "arc4random_buf"); | 36 | const os_has_arc4random = builtin.link_libc and @hasDecl(std.c, "arc4random_buf"); |
| 37 | const want_fork_safety = os_has_fork and !os_has_arc4random and | 37 | const 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; |
| 39 | const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{ | 39 | const 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 | } |
| 1101 | 1101 | ||
| 1102 | /// TODO: https://github.com/ziglang/zig/issues/425 | ||
| 1103 | pub 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. |
| 1110 | pub fn isError(error_union: anytype) bool { | 1103 | pub 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 | else | 264 | else |
| 265 | false; | 265 | false; |
| 266 | 266 | ||
| 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 option | 272 | /// 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 | /// |