ref: 6121d28dc28103cb85b22fe404daaa8c441790b4
parent: 4aafe28c24ab5d1439631278a122251c6afc77d4
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Aug 26 20:53:49 EDT 2016
nanosleep should use std.time. Make it so.
--- a/lib/std/syswrap+plan9.myr
+++ b/lib/std/syswrap+plan9.myr
@@ -66,7 +66,6 @@
const fork : (-> pid)
const execv : (cmd : byte[:], args : byte[:][:] -> errno)
const execve : (cmd : byte[:], args : byte[:][:], env : byte[:][:] -> errno)
- const nanosleep : (nsecs : uint64 -> errno)
pkglocal const Canunmap : bool = true
pkglocal const getmem : (sz : size -> byte#)
@@ -204,13 +203,6 @@
const execve = {cmd, args, env;
sys.exec(cmd, args)
-> lasterr()
-}
-
-const nanosleep = {nsecs
- if sys.sleep((nsecs/1_000_000 : uint32)) < 0
- -> lasterr()
- ;;
- -> 0
}
/* memory stuff */
--- a/lib/std/syswrap-ss+freebsd.myr
+++ b/lib/std/syswrap-ss+freebsd.myr
@@ -1,4 +1,5 @@
use sys
+use "types"
use "errno"
use "cstrconv"
use "slcp"
@@ -5,7 +6,7 @@
use "die"
pkg std =
- const nanosleep : (nsecs : uint64 -> errno)
+ const nanosleep : (nsecs : time -> errno)
$noret const exit : (status:int -> void)
pkglocal const bgetcwd : (buf : byte[:] -> errno)
@@ -15,8 +16,8 @@
var req, rem
var s, ns
- s = nsecs / 1_000_000_000
- ns = nsecs % 1_000_000_000
+ s = (nsecs : uint64) / 1_000_000_000
+ ns = (nsecs : uint64) % 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
@@ -1,8 +1,9 @@
use sys
+use "types"
use "errno"
pkg std =
- const nanosleep : (nsecs : uint64 -> errno)
+ const nanosleep : (nsecs : time -> errno)
$noret const exit : (status:int -> void)
pkglocal const bgetcwd : (buf : byte[:] -> errno)
@@ -12,8 +13,8 @@
var req, rem
var s, ns
- s = nsecs / 1_000_000_000
- ns = nsecs % 1_000_000_000
+ s = (nsecs : uint64) / 1_000_000_000
+ ns = (nsecs : uint64) % 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
@@ -1,11 +1,12 @@
use sys
-use "errno.use"
-use "cstrconv.use"
-use "slcp.use"
-use "die.use"
+use "types"
+use "errno"
+use "cstrconv"
+use "slcp"
+use "die"
pkg std =
- const nanosleep : (nsecs : uint64 -> errno)
+ const nanosleep : (nsecs : time -> errno)
$noret const exit : (status:int -> void)
pkglocal const bgetcwd : (buf : byte[:] -> errno)
@@ -21,8 +22,8 @@
var req, rem
var s, ns
- s = nsecs / 1_000_000_000
- ns = nsecs % 1_000_000_000
+ s = (nsecs : uint64) / 1_000_000_000
+ ns = (nsecs : uint64) % 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
@@ -1,12 +1,21 @@
use sys
+use "types"
use "errno"
use "cstrconv"
pkg std =
+ const nanosleep : (nsecs : time -> errno)
$noret const exit : (status : int -> void)
pkglocal const bgetcwd : (buf : byte[:] -> errno)
;;
+
+const nanosleep = {nsecs
+ if sys.sleep((nsecs/1_000_000 : uint32)) < 0
+ -> lasterr()
+ ;;
+ -> 0
+}
const bgetcwd = {buf
var fd