@@ -3660,46 +3660,85 @@ pub const R_OK = 4;
36603660
36613661pub const W = packed struct (u32 ) {
36623662 nohang : bool = false ,
3663- untraced_or_stopped : packed union {
3664- untraced : bool ,
3665- stopped : bool ,
3666- } = @bitCast (false ),
3663+ stopped : bool = false ,
36673664 exited : bool = false ,
36683665 continued : bool = false ,
36693666 _5 : u20 = 0 ,
36703667 nowait : bool = false ,
36713668 _26 : u7 = 0 ,
3669+ /// alias to stopped
3670+ pub const untraced : W = .{ .stopped = true };
36723671
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
36743707 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 );
36773710 pub const EXITED : u32 = @bitCast (W { .exited = true });
36783711 pub const CONTINUED : u32 = @bitCast (W { .continued = true });
36793712 pub const NOWAIT : u32 = @bitCast (W { .nowait = true });
36803713
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 ));
36833717 }
36843718
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 ));
36873722 }
36883723
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 ));
36913727 }
36923728
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 ));
36953732 }
36963733
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 ));
36993737 }
37003738
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 ));
37033742 }
37043743};
37053744
0 commit comments