| ... | ... | @@ -15,8 +15,10 @@ const dl = @import("../dynamic_library.zig"); |
| 15 | 15 | const native_arch = builtin.cpu.arch; |
| 16 | 16 | const native_abi = builtin.abi; |
| 17 | 17 | const native_endian = native_arch.endian(); |
| 18 | const is_loongarch = native_arch.isLoongArch(); |
| 18 | 19 | const is_mips = native_arch.isMIPS(); |
| 19 | 20 | const is_ppc = native_arch.isPowerPC(); |
| 21 | const is_riscv = native_arch.isRISCV(); |
| 20 | 22 | const is_sparc = native_arch.isSPARC(); |
| 21 | 23 | const iovec = std.posix.iovec; |
| 22 | 24 | const iovec_const = std.posix.iovec_const; |
| ... | ... | @@ -1868,15 +1870,23 @@ pub fn sigaction(sig: u8, noalias act: ?*const Sigaction, noalias oact: ?*Sigact |
| 1868 | 1870 | const mask_size = @sizeOf(@TypeOf(ksa.mask)); |
| 1869 | 1871 | |
| 1870 | 1872 | if (act) |new| { |
| 1871 | | // Zig needs to install our arch restorer function with any signal handler, so |
| 1872 | | // must copy the Sigaction struct |
| 1873 | | const restorer_fn = if ((new.flags & SA.SIGINFO) != 0) &restore_rt else &restore; |
| 1874 | | ksa = k_sigaction{ |
| 1875 | | .handler = new.handler.handler, |
| 1876 | | .flags = new.flags | SA.RESTORER, |
| 1877 | | .mask = new.mask, |
| 1878 | | .restorer = @ptrCast(restorer_fn), |
| 1879 | | }; |
| 1873 | if (native_arch == .hexagon or is_loongarch or is_mips or is_riscv) { |
| 1874 | ksa = .{ |
| 1875 | .handler = new.handler.handler, |
| 1876 | .flags = new.flags, |
| 1877 | .mask = new.mask, |
| 1878 | }; |
| 1879 | } else { |
| 1880 | // Zig needs to install our arch restorer function with any signal handler, so |
| 1881 | // must copy the Sigaction struct |
| 1882 | const restorer_fn = if ((new.flags & SA.SIGINFO) != 0) &restore_rt else &restore; |
| 1883 | ksa = .{ |
| 1884 | .handler = new.handler.handler, |
| 1885 | .flags = new.flags | SA.RESTORER, |
| 1886 | .mask = new.mask, |
| 1887 | .restorer = @ptrCast(restorer_fn), |
| 1888 | }; |
| 1889 | } |
| 1880 | 1890 | } |
| 1881 | 1891 | |
| 1882 | 1892 | const ksa_arg = if (act != null) @intFromPtr(&ksa) else 0; |
| ... | ... | @@ -3668,7 +3678,6 @@ pub const SA = if (is_mips) struct { |
| 3668 | 3678 | pub const RESETHAND = 0x80000000; |
| 3669 | 3679 | pub const ONSTACK = 0x08000000; |
| 3670 | 3680 | pub const NODEFER = 0x40000000; |
| 3671 | | pub const RESTORER = 0x04000000; |
| 3672 | 3681 | } else if (is_sparc) struct { |
| 3673 | 3682 | pub const NOCLDSTOP = 0x8; |
| 3674 | 3683 | pub const NOCLDWAIT = 0x100; |
| ... | ... | @@ -3678,6 +3687,14 @@ pub const SA = if (is_mips) struct { |
| 3678 | 3687 | pub const ONSTACK = 0x1; |
| 3679 | 3688 | pub const NODEFER = 0x20; |
| 3680 | 3689 | pub const RESTORER = 0x04000000; |
| 3690 | } else if (native_arch == .hexagon or is_loongarch or is_riscv) struct { |
| 3691 | pub const NOCLDSTOP = 1; |
| 3692 | pub const NOCLDWAIT = 2; |
| 3693 | pub const SIGINFO = 4; |
| 3694 | pub const RESTART = 0x10000000; |
| 3695 | pub const RESETHAND = 0x80000000; |
| 3696 | pub const ONSTACK = 0x08000000; |
| 3697 | pub const NODEFER = 0x40000000; |
| 3681 | 3698 | } else struct { |
| 3682 | 3699 | pub const NOCLDSTOP = 1; |
| 3683 | 3700 | pub const NOCLDWAIT = 2; |
| ... | ... | @@ -5743,13 +5760,18 @@ const k_sigaction_funcs = struct { |
| 5743 | 5760 | const restorer = *const fn () callconv(.c) void; |
| 5744 | 5761 | }; |
| 5745 | 5762 | |
| 5746 | | /// Kernel sigaction struct, as expected by the `rt_sigaction` syscall. Includes restorer. |
| 5763 | /// Kernel sigaction struct, as expected by the `rt_sigaction` syscall. Includes `restorer` on |
| 5764 | /// targets where userspace is responsible for hooking up `rt_sigreturn`. |
| 5747 | 5765 | pub const k_sigaction = switch (native_arch) { |
| 5748 | 5766 | .mips, .mipsel, .mips64, .mips64el => extern struct { |
| 5749 | 5767 | flags: c_uint, |
| 5750 | 5768 | handler: k_sigaction_funcs.handler, |
| 5751 | 5769 | mask: sigset_t, |
| 5752 | | restorer: k_sigaction_funcs.restorer, |
| 5770 | }, |
| 5771 | .hexagon, .loongarch32, .loongarch64, .riscv32, .riscv64 => extern struct { |
| 5772 | handler: k_sigaction_funcs.handler, |
| 5773 | flags: c_ulong, |
| 5774 | mask: sigset_t, |
| 5753 | 5775 | }, |
| 5754 | 5776 | else => extern struct { |
| 5755 | 5777 | handler: k_sigaction_funcs.handler, |