Zig 0.17.0-dev (Split by item)

Shortcut keys
?
Show these tips
S
Focus search field
Esc
Clear focus & close tips
U
Jump to source code
↑
Move up in search results
↓
Move down in search results
↵
Go to active search result
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
pub fn maybeAttachSignalStack() void

Configures the per-thread alternative signal stack requested by std.options.signal_stack_size.

File

Thread.zig:1744
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
pub fn maybeAttachSignalStack() void {
    const size = std.options.signal_stack_size orelse return;
    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 => {},
    }
    const global = struct {
        threadlocal var signal_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 target
        error.PermissionDenied => unreachable, // called `maybeAttachSignalStack` from a signal handler
        error.Unexpected => unreachable,
    };
}