Skip to content

Commit e67a43a

Browse files
authored
Merge pull request #12410 from ifreund/sig-err-dfl-ign-fix
std: fix definition of SIG_IGN, SIG_DFL, etc.
2 parents bbcc26a + b78f3bf commit e67a43a

File tree

10 files changed

+36
-37
lines changed

10 files changed

+36
-37
lines changed

lib/std/c/darwin.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -814,10 +814,10 @@ pub const sigset_t = u32;
814814
pub const empty_sigset: sigset_t = 0;
815815

816816
pub const SIG = struct {
817-
pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
818-
pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
819-
pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
820-
pub const HOLD = @intToPtr(?Sigaction.sigaction_fn, 5);
817+
pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
818+
pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
819+
pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
820+
pub const HOLD = @intToPtr(?Sigaction.handler_fn, 5);
821821

822822
/// block specified signal set
823823
pub const _BLOCK = 1;

lib/std/c/dragonfly.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,9 @@ pub const S = struct {
609609
pub const BADSIG = SIG.ERR;
610610

611611
pub const SIG = struct {
612-
pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
613-
pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
614-
pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
612+
pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
613+
pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
614+
pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
615615

616616
pub const BLOCK = 1;
617617
pub const UNBLOCK = 2;

lib/std/c/freebsd.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -670,9 +670,9 @@ pub const SIG = struct {
670670
pub const UNBLOCK = 2;
671671
pub const SETMASK = 3;
672672

673-
pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
674-
pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
675-
pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
673+
pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
674+
pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
675+
pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
676676

677677
pub const WORDS = 4;
678678
pub const MAXSIG = 128;

lib/std/c/netbsd.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -910,9 +910,9 @@ pub const winsize = extern struct {
910910
const NSIG = 32;
911911

912912
pub const SIG = struct {
913-
pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
914-
pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
915-
pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
913+
pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
914+
pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
915+
pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
916916

917917
pub const WORDS = 4;
918918
pub const MAXSIG = 128;

lib/std/c/openbsd.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -982,11 +982,11 @@ pub const winsize = extern struct {
982982
const NSIG = 33;
983983

984984
pub const SIG = struct {
985-
pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
986-
pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
987-
pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
988-
pub const CATCH = @intToPtr(?Sigaction.sigaction_fn, 2);
989-
pub const HOLD = @intToPtr(?Sigaction.sigaction_fn, 3);
985+
pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
986+
pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
987+
pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
988+
pub const CATCH = @intToPtr(?Sigaction.handler_fn, 2);
989+
pub const HOLD = @intToPtr(?Sigaction.handler_fn, 3);
990990

991991
pub const HUP = 1;
992992
pub const INT = 2;

lib/std/c/solaris.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -879,10 +879,10 @@ pub const winsize = extern struct {
879879
const NSIG = 75;
880880

881881
pub const SIG = struct {
882-
pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
883-
pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
884-
pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
885-
pub const HOLD = @intToPtr(?Sigaction.sigaction_fn, 2);
882+
pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
883+
pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
884+
pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
885+
pub const HOLD = @intToPtr(?Sigaction.handler_fn, 2);
886886

887887
pub const WORDS = 4;
888888
pub const MAXSIG = 75;

lib/std/debug.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1787,7 +1787,7 @@ fn resetSegfaultHandler() void {
17871787
return;
17881788
}
17891789
var act = os.Sigaction{
1790-
.handler = .{ .sigaction = os.SIG.DFL },
1790+
.handler = .{ .handler = os.SIG.DFL },
17911791
.mask = os.empty_sigset,
17921792
.flags = 0,
17931793
};

lib/std/os.zig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,9 @@ pub fn abort() noreturn {
475475

476476
// Install default handler so that the tkill below will terminate.
477477
const sigact = Sigaction{
478-
.handler = .{ .sigaction = SIG.DFL },
479-
.mask = undefined,
480-
.flags = undefined,
481-
.restorer = undefined,
478+
.handler = .{ .handler = SIG.DFL },
479+
.mask = empty_sigset,
480+
.flags = 0,
482481
};
483482
sigaction(SIG.ABRT, &sigact, null) catch |err| switch (err) {
484483
error.OperationNotSupported => unreachable,

lib/std/os/linux.zig

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,9 +1945,9 @@ pub const SIG = if (is_mips) struct {
19451945
pub const SYS = 31;
19461946
pub const UNUSED = SIG.SYS;
19471947

1948-
pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
1949-
pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
1950-
pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
1948+
pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
1949+
pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
1950+
pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
19511951
} else if (is_sparc) struct {
19521952
pub const BLOCK = 1;
19531953
pub const UNBLOCK = 2;
@@ -1989,9 +1989,9 @@ pub const SIG = if (is_mips) struct {
19891989
pub const PWR = LOST;
19901990
pub const IO = SIG.POLL;
19911991

1992-
pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
1993-
pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
1994-
pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
1992+
pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
1993+
pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
1994+
pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
19951995
} else struct {
19961996
pub const BLOCK = 0;
19971997
pub const UNBLOCK = 1;
@@ -2032,9 +2032,9 @@ pub const SIG = if (is_mips) struct {
20322032
pub const SYS = 31;
20332033
pub const UNUSED = SIG.SYS;
20342034

2035-
pub const ERR = @intToPtr(?Sigaction.sigaction_fn, maxInt(usize));
2036-
pub const DFL = @intToPtr(?Sigaction.sigaction_fn, 0);
2037-
pub const IGN = @intToPtr(?Sigaction.sigaction_fn, 1);
2035+
pub const ERR = @intToPtr(?Sigaction.handler_fn, maxInt(usize));
2036+
pub const DFL = @intToPtr(?Sigaction.handler_fn, 0);
2037+
pub const IGN = @intToPtr(?Sigaction.handler_fn, 1);
20382038
};
20392039

20402040
pub const kernel_rwf = u32;

lib/std/os/test.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ test "sigaction" {
785785
try testing.expect(signal_test_failed == false);
786786
// Check if the handler has been correctly reset to SIG_DFL
787787
try os.sigaction(os.SIG.USR1, null, &old_sa);
788-
try testing.expectEqual(os.SIG.DFL, old_sa.handler.sigaction);
788+
try testing.expectEqual(os.SIG.DFL, old_sa.handler.handler);
789789
}
790790

791791
test "dup & dup2" {

0 commit comments

Comments
 (0)