ref: 606bce2a5601d6a124da33d007e071ed9d43ff45
dir: /lib/thread/atomic.myr/
use std
pkg thread =
trait atomic @a::(integral,numeric) =
xget : (p : @a# -> @a)
xset : (p : @a#, v : @a -> void)
xadd : (p : @a#, v : @a -> @a)
xcas : (p : @a#, old : @a, new : @a -> @a)
xchg : (p : @a#, new : @a -> @a)
;;
impl atomic int32
impl atomic int64
impl atomic uint32
impl atomic uint64
;;
impl atomic int32 =
xget = {p; -> (xget32((p : uint32#)) : int32)}
xset = {p, v; xset32((p : uint32#), (v : uint32))}
xadd = {p, v; -> (xadd32((p : uint32#), (v : uint32)) : int32)}
xcas = {p, old, new; -> (xcas32((p : uint32#), (old : uint32), (new : uint32)) : int32)}
xchg = {p, v; -> (xchg32((p : uint32#), (v : uint32)) : int32)}
;;
impl atomic int64 =
xget = {p; -> (xget64((p : uint64#)) : int64)}
xset = {p, v; xset64((p : uint64#), (v : uint64))}
xadd = {p, v; -> (xadd64((p : uint64#), (v : uint64)) : int64)}
xcas = {p, old, new; -> (xcas64((p : uint64#), (old : uint64), (new : uint64)) : int64)}
xchg = {p, v; -> (xchg64((p : uint64#), (v : uint64)) : int64)}
;;
impl atomic uint32 =
xget = {p; -> xget32(p)}
xset = {p, v; xset32(p, v)}
xadd = {p, v; -> xadd32(p, v)}
xcas = {p, old, new; -> xcas32(p, old, new)}
xchg = {p, v; -> xchg32(p, v)}
;;
impl atomic uint64 =
xget = {p; -> xget64(p)}
xset = {p, v; xset64(p, v)}
xadd = {p, v; -> xadd64(p, v)}
xcas = {p, old, new; -> xcas64(p, old, new)}
xchg = {p, v; -> xchg64(p, v)}
;;
impl atomic std.intptr =
xget = {p; -> xgetp(p)}
xset = {p, v; xsetp(p, v)}
xadd = {p, v; -> xaddp(p, v)}
xcas = {p, old, new; -> xcasp(p, old, new)}
xchg = {p, v; -> xchgp(p, v)}
;;
extern const xget32 : (p : uint32# -> uint32)
extern const xget64 : (p : uint64# -> uint64)
extern const xgetp : (p : std.intptr# -> std.intptr)
extern const xset32 : (p : uint32#, v : uint32 -> void)
extern const xset64 : (p : uint64#, v : uint64 -> void)
extern const xsetp : (p : std.intptr#, v : std.intptr -> void)
extern const xadd32 : (p : uint32#, v : uint32 -> uint32)
extern const xadd64 : (p : uint64#, v : uint64 -> uint64)
extern const xaddp : (p : std.intptr#, v : std.intptr -> std.intptr)
extern const xcas32 : (p : uint32#, old: uint32, new : uint32 -> uint32)
extern const xcas64 : (p : uint64#, old: uint64, new : uint64 -> uint64)
extern const xcasp : (p : std.intptr#, old: std.intptr, new : std.intptr -> std.intptr)
extern const xchg32 : (p : uint32#, v : uint32 -> uint32)
extern const xchg64 : (p : uint64#, v : uint64 -> uint64)
extern const xchgp : (p : std.intptr#, v : std.intptr -> std.intptr)