zig icon indicating copy to clipboard operation
zig copied to clipboard

stdlib: problem with os.sigprocmask() wrapper when linking libc

Open dee0xeed opened this issue 3 years ago • 0 comments

Zig Version

0.10.0-dev.4212+34835bbbc

Steps to Reproduce

Create a file with this content

// spm.zig
const std = @import("std");
const os = std.os;
const SigSet = os.sigset_t;
const SIG = os.SIG;

pub fn main() void {
    var sset: SigSet = os.empty_sigset;
    os.linux.sigaddset(&sset, SIG.TERM);
    os.sigprocmask(SIG.BLOCK, &sset, null);
//    _ = std.c.sigprocmask(SIG.BLOCK, &sset, null); // workaround
}

Compile with zig build-exe spm.zig -lc

Expected Behavior

Without -lc compilation is successful, so I expected the same behavior with -lc

Actual Behavior

Compilation fails:

$ /opt/zig/zig build-exe spm.zig -lc
/opt/zig/lib/std/os.zig:5503:38: error: expected type 'c_int', found 'u32'
    switch (errno(system.sigprocmask(flags, set, oldset))) {
                                     ^~~~~
/opt/zig/lib/std/os.zig:5503:38: note: signed 32-bit int cannot represent all possible unsigned 32-bit values
referenced by:
    main: spm.zig:10:7
    callMain: /opt/zig/lib/std/start.zig:568:17

dee0xeed avatar Oct 20 '22 07:10 dee0xeed