ref: b194f947b512b1791e614a5941ebc785cdd28730
parent: 4a22a055638ba409f6232d4ac6967c0fa20eade4
author: Ori Bernstein <[email protected]>
date: Fri Jan 3 09:52:06 EST 2014
Add sleep and nanosleep syscalls on Linux.
--- a/libstd/sys-linux.myr
+++ b/libstd/sys-linux.myr
@@ -468,6 +468,8 @@
const clock_getres : (clk : clock, ts : timespec# -> int32)
const clock_gettime : (clk : clock, ts : timespec# -> int32)
const clock_settime : (clk : clock, ts : timespec# -> int32)
+ const sleep : (time : uint64 -> int32)
+ const nanosleep : (req : timespec#, rem : timespec# -> int32)
/* system information */
const uname : (buf : utsname# -> int)
@@ -503,6 +505,16 @@
const clock_getres = {clk, ts; -> syscall(Sysclock_getres, clockid(clk), ts) castto(int32)}
const clock_gettime = {clk, ts; -> syscall(Sysclock_gettime, clockid(clk), ts) castto(int32)}
const clock_settime = {clk, ts; -> syscall(Sysclock_settime, clockid(clk), ts) castto(int32)}
+
+const sleep = {time
+ var req, rem
+ req = [.sec = time, .nsec = 0]
+ -> nanosleep(&req, &rem)
+}
+
+const nanosleep = {req, rem;
+ -> syscall(Sysnanosleep, req, rem) castto(int32)
+}
/* system information */
const uname = {buf; -> syscall(Sysuname, buf) castto(int)}