@@ -3115,6 +3115,21 @@ pub const SYS = switch (native_os) {
3115
3115
.linux = > linux .SYS ,
3116
3116
else = > void ,
3117
3117
};
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
+
3118
3133
/// Renamed from `sigaction` to `Sigaction` to avoid conflict with function name.
3119
3134
pub const Sigaction = switch (native_os ) {
3120
3135
.linux = > switch (native_arch ) {
@@ -3123,7 +3138,7 @@ pub const Sigaction = switch (native_os) {
3123
3138
.mips64 ,
3124
3139
.mips64el ,
3125
3140
= > if (builtin .target .abi .isMusl ())
3126
- linux . Sigaction
3141
+ common_linux_Sigaction
3127
3142
else if (builtin .target .ptrBitWidth () == 64 ) extern struct {
3128
3143
pub const handler_fn = * align (1 ) const fn (i32 ) callconv (.c ) void ;
3129
3144
pub const sigaction_fn = * const fn (i32 , * const siginfo_t , ? * anyopaque ) callconv (.c ) void ;
@@ -3160,8 +3175,8 @@ pub const Sigaction = switch (native_os) {
3160
3175
flags : c_uint ,
3161
3176
restorer : ? * const fn () callconv (.c ) void = null ,
3162
3177
mask : sigset_t ,
3163
- } else linux . Sigaction ,
3164
- else = > linux . Sigaction ,
3178
+ } else common_linux_Sigaction ,
3179
+ else = > common_linux_Sigaction ,
3165
3180
},
3166
3181
.emscripten = > emscripten .Sigaction ,
3167
3182
.netbsd , .macos , .ios , .tvos , .watchos , .visionos = > extern struct {
@@ -4518,27 +4533,18 @@ pub const siginfo_t = switch (native_os) {
4518
4533
else = > void ,
4519
4534
};
4520
4535
pub 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.
4522
4537
.emscripten = > emscripten .sigset_t ,
4523
4538
// 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 ,
4525
4541
.dragonfly , .netbsd , .solaris , .illumos , .freebsd = > extern struct {
4526
4542
__bits : [SIG .WORDS ]u32 ,
4527
4543
},
4528
4544
.haiku = > u64 ,
4529
4545
else = > u0 ,
4530
4546
};
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
+
4542
4548
pub const sigval = switch (native_os ) {
4543
4549
.linux = > linux .sigval ,
4544
4550
// https://github.com/SerenityOS/serenity/blob/ec492a1a0819e6239ea44156825c4ee7234ca3db/Kernel/API/POSIX/signal.h#L22-L25
@@ -6665,7 +6671,7 @@ pub const timezone = switch (native_os) {
6665
6671
};
6666
6672
6667
6673
pub 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.
6669
6675
.emscripten = > emscripten .ucontext_t ,
6670
6676
.macos , .ios , .tvos , .watchos , .visionos = > extern struct {
6671
6677
onstack : c_int ,
@@ -9596,6 +9602,7 @@ pub const NSIG = switch (native_os) {
9596
9602
.windows = > 23 ,
9597
9603
.haiku = > 65 ,
9598
9604
.netbsd , .freebsd = > 32 ,
9605
+ .macos = > darwin .NSIG ,
9599
9606
.solaris , .illumos = > 75 ,
9600
9607
// https://github.com/SerenityOS/serenity/blob/046c23f567a17758d762a33bdf04bacbfd088f9f/Kernel/API/POSIX/signal_numbers.h#L42
9601
9608
.openbsd , .serenity = > 33 ,
@@ -10345,6 +10352,11 @@ pub const sigfillset = switch (native_os) {
10345
10352
else = > private .sigfillset ,
10346
10353
};
10347
10354
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
+
10348
10360
pub const sigprocmask = switch (native_os ) {
10349
10361
.netbsd = > private .__sigprocmask14 ,
10350
10362
else = > private .sigprocmask ,
@@ -11025,7 +11037,6 @@ pub const pthread_attr_set_qos_class_np = darwin.pthread_attr_set_qos_class_np;
11025
11037
pub const pthread_get_qos_class_np = darwin .pthread_get_qos_class_np ;
11026
11038
pub const pthread_set_qos_class_self_np = darwin .pthread_set_qos_class_self_np ;
11027
11039
pub const ptrace = darwin .ptrace ;
11028
- pub const sigaddset = darwin .sigaddset ;
11029
11040
pub const task_for_pid = darwin .task_for_pid ;
11030
11041
pub const task_get_exception_ports = darwin .task_get_exception_ports ;
11031
11042
pub const task_info = darwin .task_info ;
@@ -11148,7 +11159,11 @@ const private = struct {
11148
11159
extern "c" fn sched_yield () c_int ;
11149
11160
extern "c" fn sendfile (out_fd : fd_t , in_fd : fd_t , offset : ? * off_t , count : usize ) isize ;
11150
11161
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 ;
11152
11167
extern "c" fn sigprocmask (how : c_int , noalias set : ? * const sigset_t , noalias oset : ? * sigset_t ) c_int ;
11153
11168
extern "c" fn socket (domain : c_uint , sock_type : c_uint , protocol : c_uint ) c_int ;
11154
11169
extern "c" fn stat (noalias path : [* :0 ]const u8 , noalias buf : * Stat ) c_int ;
0 commit comments