-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
std: make options a struct instance instead of a namespace #18712
Conversation
e2b58fa
to
62e562c
Compare
`fd_t` is not declared on freestanding so returning a `Dir` causes an error.
Something about the stdlib changes swapped the order?
missed this when it first came through but imo the name of |
The async mode has been removed in ziglang/zig#18712
The async mode has been removed in ziglang/zig#18712
As @nektro said, As a side proposal, maybe it would be better to create a system for generalized and consistent library options. The |
`std.io.is_async` no longer exists since ziglang/zig#18712. Removed all references for compatibility with latest Zig `master`.
`std.io.is_async` no longer exists since ziglang/zig#18712. Removed all references for compatibility with latest Zig `master`.
Release notes draft: Std OptionsPreviously, when one wanted to override defaults, such as the logging function used by pub const std_options = struct {
pub const logFn = myLogFn;
}; Note how This is now how the code above would look like now: pub const std_options: std.Options = .{
.logFn = myLogFn,
}; And this is the definition of TODO: explain that you can still override other stuff like the panic function in a different way because that's not a stdlib override pub const Options = struct {
enable_segfault_handler: bool = debug.default_enable_segfault_handler,
/// Function used to implement `std.fs.cwd` for WASI.
wasiCwd: fn () os.wasi.fd_t = fs.defaultWasiCwd,
/// The current log level.
log_level: log.Level = log.default_level,
log_scope_levels: []const log.ScopeLevel = &.{},
logFn: fn (
comptime message_level: log.Level,
comptime scope: @TypeOf(.enum_literal),
comptime format: []const u8,
args: anytype,
) void = log.defaultLog,
fmt_max_depth: usize = fmt.default_max_depth,
cryptoRandomSeed: fn (buffer: []u8) void = @import("crypto/tlcsprng.zig").defaultRandomSeed,
crypto_always_getrandom: bool = false,
crypto_fork_safety: bool = true,
/// By default Zig disables SIGPIPE by setting a "no-op" handler for it. Set this option
/// to `true` to prevent that.
///
/// Note that we use a "no-op" handler instead of SIG_IGN because it will not be inherited by
/// any child process.
///
/// SIGPIPE is triggered when a process attempts to write to a broken pipe. By default, SIGPIPE
/// will terminate the process instead of exiting. It doesn't trigger the panic handler so in many
/// cases it's unclear why the process was terminated. By capturing SIGPIPE instead, functions that
/// write to broken pipes will return the EPIPE error (error.BrokenPipe) and the program can handle
/// it like any other error.
keep_sigpipe: bool = false,
/// By default, std.http.Client will support HTTPS connections. Set this option to `true` to
/// disable TLS support.
///
/// This will likely reduce the size of the binary, but it will also make it impossible to
/// make a HTTPS connection.
http_disable_tls: bool = false,
side_channels_mitigations: crypto.SideChannelsMitigations = crypto.default_side_channels_mitigations,
}; |
std: make options a struct instance instead of a namespace
As per #18697 (comment)
Closes #14432