shithub: mc

ref: 06f83c93631d8af9eb25199a8229183c48b89ce8
dir: /lib/std/syswrap-ss+freebsd.myr/

View raw version
use sys
use "types"
use "errno"
use "cstrconv"
use "slcp"
use "die"

pkg std =
	const nanosleep	: (nsecs : uint64 -> errno)
	$noret const exit	: (status:int -> void)

	pkglocal const bgetcwd	: (buf : byte[:] -> errno)
;;

const nanosleep	= {nsecs
	var req, rem
	var s, ns

	s = (nsecs / 1_000_000_000 : int64)
	ns = (nsecs % 1_000_000_000 : int64)
	req = [.sec = s, .nsec = ns]

	-> (sys.nanosleep(&req, &rem) : errno)
}

const exit = {status
	sys.exit(status)
}

const bgetcwd = {buf
	var res

	res = (sys.__getcwd(buf) : errno)
	if res == 0
		-> (cstrlen(buf) : errno)
	elif res == Enomem
		-> Erange
	else
		-> res
	;;
}