@@ -3658,46 +3658,85 @@ pub const R_OK = 4;
36583658
36593659pub const W = packed struct (u32 ) {
36603660 nohang : bool = false ,
3661- untraced_or_stopped : packed union {
3662- untraced : bool ,
3663- stopped : bool ,
3664- } = @bitCast (false ),
3661+ stopped : bool = false ,
36653662 exited : bool = false ,
36663663 continued : bool = false ,
36673664 _5 : u20 = 0 ,
36683665 nowait : bool = false ,
36693666 _26 : u7 = 0 ,
3667+ /// alias to stopped
3668+ pub const untraced : W = .{ .stopped = true };
36703669
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
36723705 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 );
36753708 pub const EXITED : u32 = @bitCast (W { .exited = true });
36763709 pub const CONTINUED : u32 = @bitCast (W { .continued = true });
36773710 pub const NOWAIT : u32 = @bitCast (W { .nowait = true });
36783711
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 ));
36813715 }
36823716
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 ));
36853720 }
36863721
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 ));
36893725 }
36903726
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 ));
36933730 }
36943731
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 ));
36973735 }
36983736
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 ));
37013740 }
37023741};
37033742
0 commit comments