@@ -3115,6 +3115,21 @@ pub const SYS = switch (native_os) {
31153115 .linux = > linux .SYS ,
31163116 else = > void ,
31173117};
3118+
3119+ /// A common format for the Sigaction struct across a variety of Linux flavors.
3120+ const common_linux_Sigaction = extern struct {
3121+ pub const handler_fn = * align (1 ) const fn (i32 ) callconv (.c ) void ;
3122+ pub const sigaction_fn = * const fn (i32 , * const siginfo_t , ? * anyopaque ) callconv (.c ) void ;
3123+
3124+ handler : extern union {
3125+ handler : ? handler_fn ,
3126+ sigaction : ? sigaction_fn ,
3127+ },
3128+ mask : sigset_t ,
3129+ flags : c_uint ,
3130+ restorer : ? * const fn () callconv (.c ) void = null , // C library will fill this in
3131+ };
3132+
31183133/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
31193134pub const Sigaction = switch (native_os ) {
31203135 .linux = > switch (native_arch ) {
@@ -3123,7 +3138,7 @@ pub const Sigaction = switch (native_os) {
31233138 .mips64 ,
31243139 .mips64el ,
31253140 = > if (builtin .target .abi .isMusl ())
3126- linux . Sigaction
3141+ common_linux_Sigaction
31273142 else if (builtin .target .ptrBitWidth () == 64 ) extern struct {
31283143 pub const handler_fn = * align (1 ) const fn (i32 ) callconv (.c ) void ;
31293144 pub const sigaction_fn = * const fn (i32 , * const siginfo_t , ? * anyopaque ) callconv (.c ) void ;
@@ -3160,8 +3175,8 @@ pub const Sigaction = switch (native_os) {
31603175 flags : c_uint ,
31613176 restorer : ? * const fn () callconv (.c ) void = null ,
31623177 mask : sigset_t ,
3163- } else linux . Sigaction ,
3164- else = > linux . Sigaction ,
3178+ } else common_linux_Sigaction ,
3179+ else = > common_linux_Sigaction ,
31653180 },
31663181 .emscripten = > emscripten .Sigaction ,
31673182 .netbsd , .macos , .ios , .tvos , .watchos , .visionos = > extern struct {
@@ -4518,27 +4533,18 @@ pub const siginfo_t = switch (native_os) {
45184533 else = > void ,
45194534};
45204535pub const sigset_t = switch (native_os ) {
4521- .linux = > linux . sigset_t ,
4536+ .linux = > [ 1024 / @bitSizeOf ( c_ulong )] c_ulong , // glibc and musl present a 1024-bit sigset_t, while kernel's is 128-bit or less.
45224537 .emscripten = > emscripten .sigset_t ,
45234538 // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L19
4524- .openbsd , .macos , .ios , .tvos , .watchos , .visionos , .serenity = > u32 ,
4539+ .openbsd , .serenity = > u32 ,
4540+ .macos , .ios , .tvos , .watchos , .visionos = > darwin .sigset_t ,
45254541 .dragonfly , .netbsd , .solaris , .illumos , .freebsd = > extern struct {
45264542 __bits : [SIG .WORDS ]u32 ,
45274543 },
45284544 .haiku = > u64 ,
45294545 else = > u0 ,
45304546};
4531- pub const empty_sigset : sigset_t = switch (native_os ) {
4532- .linux = > linux .empty_sigset ,
4533- .emscripten = > emscripten .empty_sigset ,
4534- .dragonfly , .netbsd , .solaris , .illumos , .freebsd = > .{ .__bits = [_ ]u32 {0 } ** SIG .WORDS },
4535- else = > 0 ,
4536- };
4537- pub const filled_sigset = switch (native_os ) {
4538- .linux = > linux .filled_sigset ,
4539- .haiku = > ~ @as (sigset_t , 0 ),
4540- else = > 0 ,
4541- };
4547+
45424548pub const sigval = switch (native_os ) {
45434549 .linux = > linux .sigval ,
45444550 // https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L22-L25
@@ -6665,7 +6671,7 @@ pub const timezone = switch (native_os) {
66656671};
66666672
66676673pub const ucontext_t = switch (native_os ) {
6668- .linux = > linux .ucontext_t ,
6674+ .linux = > linux .ucontext_t , // std.os.linux.ucontext_t is currently glibc-compatible, but it should probably not be.
66696675 .emscripten = > emscripten .ucontext_t ,
66706676 .macos , .ios , .tvos , .watchos , .visionos = > extern struct {
66716677 onstack : c_int ,
@@ -9596,6 +9602,7 @@ pub const NSIG = switch (native_os) {
95969602 .windows = > 23 ,
95979603 .haiku = > 65 ,
95989604 .netbsd , .freebsd = > 32 ,
9605+ .macos = > darwin .NSIG ,
95999606 .solaris , .illumos = > 75 ,
96009607 // https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal_numbers.h#L42
96019608 .openbsd , .serenity = > 33 ,
@@ -10345,6 +10352,11 @@ pub const sigfillset = switch (native_os) {
1034510352 else = > private .sigfillset ,
1034610353};
1034710354
10355+ pub const sigaddset = private .sigaddset ;
10356+ pub const sigemptyset = private .sigemptyset ;
10357+ pub const sigdelset = private .sigdelset ;
10358+ pub const sigismember = private .sigismember ;
10359+
1034810360pub const sigprocmask = switch (native_os ) {
1034910361 .netbsd = > private .__sigprocmask14 ,
1035010362 else = > private .sigprocmask ,
@@ -11025,7 +11037,6 @@ pub const pthread_attr_set_qos_class_np = darwin.pthread_attr_set_qos_class_np;
1102511037pub const pthread_get_qos_class_np = darwin .pthread_get_qos_class_np ;
1102611038pub const pthread_set_qos_class_self_np = darwin .pthread_set_qos_class_self_np ;
1102711039pub const ptrace = darwin .ptrace ;
11028- pub const sigaddset = darwin .sigaddset ;
1102911040pub const task_for_pid = darwin .task_for_pid ;
1103011041pub const task_get_exception_ports = darwin .task_get_exception_ports ;
1103111042pub const task_info = darwin .task_info ;
@@ -11148,7 +11159,11 @@ const private = struct {
1114811159 extern "c" fn sched_yield () c_int ;
1114911160 extern "c" fn sendfile (out_fd : fd_t , in_fd : fd_t , offset : ? * off_t , count : usize ) isize ;
1115011161 extern "c" fn sigaction (sig : c_int , noalias act : ? * const Sigaction , noalias oact : ? * Sigaction ) c_int ;
11151- extern "c" fn sigfillset (set : ? * sigset_t ) void ;
11162+ extern "c" fn sigdelset (set : ? * sigset_t , signo : c_int ) c_int ;
11163+ extern "c" fn sigaddset (set : ? * sigset_t , signo : c_int ) c_int ;
11164+ extern "c" fn sigfillset (set : ? * sigset_t ) c_int ;
11165+ extern "c" fn sigemptyset (set : ? * sigset_t ) c_int ;
11166+ extern "c" fn sigismember (set : ? * const sigset_t , signo : c_int ) c_int ;
1115211167 extern "c" fn sigprocmask (how : c_int , noalias set : ? * const sigset_t , noalias oset : ? * sigset_t ) c_int ;
1115311168 extern "c" fn socket (domain : c_uint , sock_type : c_uint , protocol : c_uint ) c_int ;
1115411169 extern "c" fn stat (noalias path : [* :0 ]const u8 , noalias buf : * Stat ) c_int ;
0 commit comments