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