authorgravatar for philip.akesson@gmail.comPhilip Åkesson <philip.akesson@gmail.com> 2021-08-24 21:34:43+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2021-08-31 22:03:54-04:00
log4f0aa7d639e099b18df583cb984412037fbb1dbe
tree1ef3e04948909487d22bce82d65d96d362ec4001
parent3b9ec4e4df634b17268034a6a5527c11cf67e54b

std: Use truncating cast in WIFSTOPPED for Linux, FreeBSD and DragonFly

The intermediate value can be larger than an u16, so @truncate is needed to match the behavior of musl.

3 files changed, 3 insertions(+), 3 deletions(-)

lib/std/os/bits/dragonfly.zig+1-1
......@@ -348,7 +348,7 @@ pub fn WIFEXITED(s: u32) bool {
348348 return WTERMSIG(s) == 0;
349349}
350350pub fn WIFSTOPPED(s: u32) bool {
351 return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
351 return @truncate(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
352352}
353353pub fn WIFSIGNALED(s: u32) bool {
354354 return (s & 0xffff) -% 1 < 0xff;
lib/std/os/bits/freebsd.zig+1-1
......@@ -741,7 +741,7 @@ pub fn WIFEXITED(s: u32) bool {
741741 return WTERMSIG(s) == 0;
742742}
743743pub fn WIFSTOPPED(s: u32) bool {
744 return @intCast(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
744 return @truncate(u16, (((s & 0xffff) *% 0x10001) >> 8)) > 0x7f00;
745745}
746746pub fn WIFSIGNALED(s: u32) bool {
747747 return (s & 0xffff) -% 1 < 0xff;
lib/std/os/bits/linux.zig+1-1
......@@ -1066,7 +1066,7 @@ pub fn WIFEXITED(s: u32) bool {
10661066 return WTERMSIG(s) == 0;
10671067}
10681068pub fn WIFSTOPPED(s: u32) bool {
1069 return @intCast(u16, ((s & 0xffff) *% 0x10001) >> 8) > 0x7f00;
1069 return @truncate(u16, ((s & 0xffff) *% 0x10001) >> 8) > 0x7f00;
10701070}
10711071pub fn WIFSIGNALED(s: u32) bool {
10721072 return (s & 0xffff) -% 1 < 0xff;