This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig standard library. Public Function
maybeAttachSignalStack
Public Function
std.Thread.maybeAttachSignalStack
pubfnmaybeAttachSignalStack() void
Configures the per-thread alternative signal stack requested by std.options.signal_stack_size.
pubfnmaybeAttachSignalStack() void {
constsize = std.options.signal_stack_sizeorelsereturn;
switch (builtin.target.os.tag) {
// TODO: Windows vectored exception handlers always run on the main stack, but we could use// some target-specific inline assembly to swap the stack pointer.
.windows => return,
.wasi => return,
else => {},
}
constglobal = struct {
threadlocalvarsignal_stack: [size]u8 = undefined;
};
std.posix.sigaltstack(&.{
.sp = &global.signal_stack,
.flags = 0,
.size = size,
}, null) catch |err| switch (err) {
error.SizeTooSmall => unreachable, // `std.options.signal_stack_size` must be sufficient for the targeterror.PermissionDenied => unreachable, // called `maybeAttachSignalStack` from a signal handlererror.Unexpected => unreachable,
};
}
Configures the per-thread alternative signal stack requested by
std.options.signal_stack_size.