@@ -3658,46 +3658,85 @@ pub const R_OK = 4;
3658
3658
3659
3659
pub const W = packed struct (u32 ) {
3660
3660
nohang : bool = false ,
3661
- untraced_or_stopped : packed union {
3662
- untraced : bool ,
3663
- stopped : bool ,
3664
- } = @bitCast (false ),
3661
+ stopped : bool = false ,
3665
3662
exited : bool = false ,
3666
3663
continued : bool = false ,
3667
3664
_5 : u20 = 0 ,
3668
3665
nowait : bool = false ,
3669
3666
_26 : u7 = 0 ,
3667
+ /// alias to stopped
3668
+ pub const untraced : W = .{ .stopped = true };
3670
3669
3671
- // Deprecated aliases
3670
+ fn toInt (s : W ) u32 {
3671
+ return @bitCast (s );
3672
+ }
3673
+
3674
+ /// matches EXITSTATUS in C
3675
+ pub fn exitStatus (s : W ) u8 {
3676
+ return @intCast ((s .toInt () & 0xff00 ) >> 8 );
3677
+ }
3678
+
3679
+ /// matches TERMSIG in C
3680
+ pub fn termSig (s : W ) u32 {
3681
+ return s .toInt () & 0x7f ;
3682
+ }
3683
+
3684
+ /// matches STOPSIG in C
3685
+ pub fn stopSig (s : W ) u32 {
3686
+ return exitStatus (s );
3687
+ }
3688
+
3689
+ /// matches IFEXITED in C
3690
+ pub fn ifExited (s : W ) bool {
3691
+ return termSig (s ) == 0 ;
3692
+ }
3693
+
3694
+ /// matches IFSTOPPED in C
3695
+ pub fn ifStopped (s : W ) bool {
3696
+ return @as (u16 , @truncate (((s .toInt () & 0xffff ) *% 0x10001 ) >> 8 )) > 0x7f00 ;
3697
+ }
3698
+
3699
+ /// matches IFSIGNALED in C
3700
+ pub fn ifSignaled (s : W ) bool {
3701
+ return (s .toInt () & 0xffff ) -% 1 < 0xff ;
3702
+ }
3703
+
3704
+ // Deprecated constants
3672
3705
pub const NOHANG : u32 = @bitCast (W { .nohang = true });
3673
- pub const UNTRACED : u32 = @bitCast (W { .untraced_or_stopped = .{ . untraced = true } });
3674
- pub const STOPPED : u32 = @bitCast (W { . untraced_or_stopped = .{ . stopped = true } } );
3706
+ pub const STOPPED : u32 = @bitCast (W { .stopped = true });
3707
+ pub const UNTRACED : u32 = @bitCast (untraced );
3675
3708
pub const EXITED : u32 = @bitCast (W { .exited = true });
3676
3709
pub const CONTINUED : u32 = @bitCast (W { .continued = true });
3677
3710
pub const NOWAIT : u32 = @bitCast (W { .nowait = true });
3678
3711
3679
- pub fn EXITSTATUS (s : W ) u8 {
3680
- return @intCast ((@as (u32 , @bitCast (s )) & 0xff00 ) >> 8 );
3712
+ /// DEPRECATED alias to exitStatus
3713
+ pub fn EXITSTATUS (s : u32 ) u8 {
3714
+ return exitStatus (@bitCast (s ));
3681
3715
}
3682
3716
3683
- pub fn TERMSIG (s : W ) u32 {
3684
- return @as (u32 , @bitCast (s )) & 0x7f ;
3717
+ /// DEPRECATED alias to termSig
3718
+ pub fn TERMSIG (s : u32 ) u32 {
3719
+ return termSig (@bitCast (s ));
3685
3720
}
3686
3721
3687
- pub fn STOPSIG (s : W ) u32 {
3688
- return EXITSTATUS (s );
3722
+ /// DEPRECATED alias to stopSig
3723
+ pub fn STOPSIG (s : u32 ) u32 {
3724
+ return stopSig (@bitCast (s ));
3689
3725
}
3690
3726
3691
- pub fn IFEXITED (s : W ) bool {
3692
- return TERMSIG (s ) == 0 ;
3727
+ /// DEPRECATED alias to ifExited
3728
+ pub fn IFEXITED (s : u32 ) bool {
3729
+ return ifExited (@bitCast (s ));
3693
3730
}
3694
3731
3695
- pub fn IFSTOPPED (s : W ) bool {
3696
- return @as (u16 , @truncate (((@as (u32 , @bitCast (s )) & 0xffff ) *% 0x10001 ) >> 8 )) > 0x7f00 ;
3732
+ /// DEPRECATED alias to ifStopped
3733
+ pub fn IFSTOPPED (s : u32 ) bool {
3734
+ return ifStopped (@bitCast (s ));
3697
3735
}
3698
3736
3699
- pub fn IFSIGNALED (s : W ) bool {
3700
- return (s & 0xffff ) -% 1 < 0xff ;
3737
+ /// DEPRECATED alias to ifSignaled
3738
+ pub fn IFSIGNALED (s : u32 ) bool {
3739
+ return ifSignaled (@bitCast (s ));
3701
3740
}
3702
3741
};
3703
3742
0 commit comments