summaryrefslogtreecommitdiff
path: root/lib/thread/futex+freebsd.myr
blob: c6e5aaadb4ebd86f2b091cdf450969160f6294fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use sys

use "common"

pkg thread =
	const ftxwait : (uaddr : uint64#, val : uint64, timeout : sys.timespec# -> int)
	const ftxwake : (uaddr : uint64# -> int)
;;

const ftxwait = {uaddr, val, timeout
	if timeout == Zptr
		-> sys.umtx_op((uaddr : void#), sys.Umtxwaituintpriv, (val : uint64), Zptr, Zptr)
	;;

	var ut : sys._umtx_time = [
		._timeout = timeout#,
		._flags = (sys.Umtxabstime : uint32),
		._clockid = 1 /* CLOCK_MONOTONIC. Not exported from sys. */
	]
	-> sys.umtx_op((uaddr : void#),
	    sys.Umtxwaituintpriv,
	    (val : uint64),
	    (sizeof(sys._umtx_time) : void#),
	    (&ut : void#))
}

const ftxwake = {uaddr
	-> sys.umtx_op((uaddr : void#), sys.Umtxwakepriv, 1, Zptr, Zptr)
}