shithub: mc

ref: 4a8f78d53d61423fdeb6c59881661d6cd5cbd430
dir: /libstd/waitstatus-linux.myr/

View raw version
use "die.use"
pkg std =
	type waitstatus = union
		`Waitexit int32
		`Waitsig  int32
		`Waitstop int32
	;;

	const waitstatus	: (st : int32 -> waitstatus)
;;

const waitstatus = {st
	if st & 0x7f == 0 /* if exited */
		-> `Waitexit ((st & 0xff00) >> 8)
	elif ((st & 0xffff)-1) < 0xff /* if signaled */
		-> `Waitsig ((st) & 0x7f)
	elif (((st & 0xffff)*0x10001)>>8) > 0x7f00
		-> `Waitstop ((st & 0xff00) >> 8)
	;;
	die("unreachable")
}