Commit cf989374e9

Pat Tullmann <pat.github@tullmann.org>
2025-04-25 07:02:53
linux: update `sigmask` in every arch `ucontext_t`
All the existing code that manipulates `ucontext_t` expects there to be a glibc-compatible sigmask (1024-bit). The `ucontext_t` struct need to be cleaned up so the glibc-dependent format is only used when linking glibc/musl library, but that is a more involved change. In practice, no Zig code looks at the sigset field contents, so it just needs to be the right size.
1 parent 120c478
lib/std/os/linux/aarch64.zig
@@ -289,7 +289,7 @@ pub const ucontext_t = extern struct {
     flags: usize,
     link: ?*ucontext_t,
     stack: stack_t,
-    sigmask: sigset_t,
+    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
     mcontext: mcontext_t,
 };
 
lib/std/os/linux/arm.zig
@@ -337,7 +337,7 @@ pub const ucontext_t = extern struct {
     link: ?*ucontext_t,
     stack: stack_t,
     mcontext: mcontext_t,
-    sigmask: sigset_t,
+    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
     regspace: [64]u64,
 };
 
lib/std/os/linux/loongarch64.zig
@@ -264,8 +264,7 @@ pub const ucontext_t = extern struct {
     flags: c_ulong,
     link: ?*ucontext_t,
     stack: stack_t,
-    sigmask: sigset_t,
-    _pad: [1024 / 8 - @sizeOf(sigset_t)]u8,
+    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
     mcontext: mcontext_t,
 };
 
lib/std/os/linux/powerpc.zig
@@ -341,7 +341,7 @@ pub const ucontext_t = extern struct {
     stack: stack_t,
     pad: [7]i32,
     regs: *mcontext_t,
-    sigmask: sigset_t,
+    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
     pad2: [3]i32,
     mcontext: mcontext_t,
 };
lib/std/os/linux/powerpc64.zig
@@ -337,7 +337,7 @@ pub const ucontext_t = extern struct {
     flags: u32,
     link: ?*ucontext_t,
     stack: stack_t,
-    sigmask: sigset_t,
+    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
     mcontext: mcontext_t,
 };
 
lib/std/os/linux/s390x.zig
@@ -273,7 +273,7 @@ pub const ucontext_t = extern struct {
     link: ?*ucontext_t,
     stack: stack_t,
     mcontext: mcontext_t,
-    sigmask: sigset_t,
+    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
 };
 
 pub const mcontext_t = extern struct {
lib/std/os/linux/sparc64.zig
@@ -454,7 +454,7 @@ pub const ucontext_t = extern struct {
     sigmask: u64,
     mcontext: mcontext_t,
     stack: stack_t,
-    sigset: sigset_t,
+    sigset: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
 };
 
 /// TODO
lib/std/os/linux/x86.zig
@@ -350,7 +350,7 @@ pub const ucontext_t = extern struct {
     link: ?*ucontext_t,
     stack: stack_t,
     mcontext: mcontext_t,
-    sigmask: sigset_t,
+    sigmask: [1024 / @bitSizeOf(c_ulong)]c_ulong, // Currently a libc-compatible (1024-bit) sigmask
     regspace: [64]u64,
 };