shithub: mc

Download patch

ref: a7d1902c56da54a4bc3891413bd3029c6ea7a7f9
parent: e83d16d5bd500b8e1913a836560f943a757ab86b
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Aug 27 14:58:18 EDT 2016

Add std.usleep() that uses std.time.

--- a/lib/std/bld.sub
+++ b/lib/std/bld.sub
@@ -53,6 +53,7 @@
 	sjlj-impl+posixy-x64.s
 	slcp.myr
 	sldup.myr
+	sleep.myr
 	sleq.myr
 	slfill.myr
 	sljoin.myr
--- /dev/null
+++ b/lib/std/sleep.myr
@@ -1,0 +1,11 @@
+use "syswrap-ss"
+use "types"
+
+pkg std =
+	const usleep	: (tm : time -> void)
+;;
+
+const usleep = {tm
+	nanosleep((tm * 1000 : uint64))
+}
+
--- a/lib/std/syswrap-ss+freebsd.myr
+++ b/lib/std/syswrap-ss+freebsd.myr
@@ -6,7 +6,7 @@
 use "die"
 
 pkg std =
-	const nanosleep	: (nsecs : time -> errno)
+	const nanosleep	: (nsecs : uint64 -> errno)
 	$noret const exit	: (status:int -> void)
 
 	pkglocal const bgetcwd	: (buf : byte[:] -> errno)
@@ -16,8 +16,8 @@
 	var req, rem
 	var s, ns
 
-	s = (nsecs : uint64) / 1_000_000_000
-	ns = (nsecs : uint64) % 1_000_000_000
+	s = nsecs / 1_000_000_000
+	ns = nsecs % 1_000_000_000
 	req = [.sec = s, .nsec = ns]
 
 	-> (sys.nanosleep(&req, &rem) : errno)
--- a/lib/std/syswrap-ss+linux.myr
+++ b/lib/std/syswrap-ss+linux.myr
@@ -3,7 +3,7 @@
 use "errno"
 
 pkg std =
-	const nanosleep	: (nsecs : time -> errno)
+	const nanosleep	: (nsecs : uint64 -> errno)
 	$noret const exit	: (status:int -> void)
 
 	pkglocal const bgetcwd	: (buf : byte[:] -> errno)
@@ -13,8 +13,8 @@
 	var req, rem
 	var s, ns
 
-	s = (nsecs : uint64) / 1_000_000_000
-	ns = (nsecs : uint64) % 1_000_000_000
+	s = nsecs / 1_000_000_000
+	ns = nsecs % 1_000_000_000
 	req = [.sec = s, .nsec = ns]
 
 	-> (sys.nanosleep(&req, &rem) : errno)
--- a/lib/std/syswrap-ss+openbsd.myr
+++ b/lib/std/syswrap-ss+openbsd.myr
@@ -6,7 +6,7 @@
 use "die"
 
 pkg std =
-	const nanosleep	: (nsecs : time -> errno)
+	const nanosleep	: (nsecs : uint64 -> errno)
 	$noret const exit	: (status:int -> void)
 
 	pkglocal const bgetcwd	: (buf : byte[:] -> errno)
@@ -22,8 +22,8 @@
 	var req, rem
 	var s, ns
 
-	s = (nsecs : uint64) / 1_000_000_000
-	ns = (nsecs : uint64) % 1_000_000_000
+	s = nsecs / 1_000_000_000
+	ns = nsecs % 1_000_000_000
 	req = [.sec = s, .nsec = ns]
 
 	-> (sys.nanosleep(&req, &rem) : errno)
--- a/lib/std/syswrap-ss+plan9.myr
+++ b/lib/std/syswrap-ss+plan9.myr
@@ -5,7 +5,7 @@
 use "cstrconv"
 
 pkg std =
-	const nanosleep	: (nsecs : time -> errno)
+	const nanosleep	: (nsecs : uint64 -> errno)
 	$noret const exit	: (status : int -> void)
 	pkglocal const bgetcwd	: (buf : byte[:] -> errno)
 ;;