ref: c2cead0d7e100e3c6f808af1bfaea25e151c53c0
dir: /lib/thread/futex+linux.myr/
use sys use "atomic" use "common" pkg thread = type ftxtag = uint32 impl atomic ftxtag const ftxwait : (uaddr : ftxtag#, val : ftxtag, timeout : sys.timespec# -> int) const ftxwake : (uaddr : ftxtag# -> int) ;; const ftxwait = {uaddr, val, timeout -> (sys.futex((uaddr : int32#), sys.Futexwait | sys.Futexpriv, (val : int32), timeout, Zptr, 0) : int) } const ftxwake = {uaddr -> (sys.futex((uaddr : int32#), sys.Futexwake | sys.Futexpriv, 1, Zptr, Zptr, 0) : int) } impl atomic ftxtag = xget = {p; -> (xget32((p : uint32#)) : ftxtag)} xset = {p, v; xset32((p : uint32#), (v : uint32))} xadd = {p, v; -> (xadd32((p : uint32#), (v : uint32)) : ftxtag)} xcas = {p, old, new; -> (xcas32((p : uint32#), (old : uint32), (new : uint32)) : ftxtag)} xchg = {p, v; -> (xchg32((p : uint32#), (v : uint32)) : ftxtag)} ;;