summaryrefslogtreecommitdiff
path: root/lib/std/syswrap+plan9.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-06-17 11:21:08 -0700
committerOri Bernstein <ori@eigenstate.org>2017-06-17 11:21:08 -0700
commit8ccd239d70ff98001c857e8ebf8fb509b64477d4 (patch)
treef0cd8a2ee448520bcbfecc027aee6aaba1ad1587 /lib/std/syswrap+plan9.myr
parente12f1d5c28797ee73fba56e4adf86a40491fc779 (diff)
downloadmc-8ccd239d70ff98001c857e8ebf8fb509b64477d4.tar.gz
Misc 9front fixes.
Diffstat (limited to 'lib/std/syswrap+plan9.myr')
-rw-r--r--lib/std/syswrap+plan9.myr37
1 files changed, 31 insertions, 6 deletions
diff --git a/lib/std/syswrap+plan9.myr b/lib/std/syswrap+plan9.myr
index 1730c53..17b1f39 100644
--- a/lib/std/syswrap+plan9.myr
+++ b/lib/std/syswrap+plan9.myr
@@ -6,7 +6,6 @@ use "errno"
use "result"
use "cstrconv"
use "strfind"
-use "getint"
use "syswrap-ss"
pkg std =
@@ -136,7 +135,7 @@ const fmtime = {path
if sys.stat(path, buf[:]) < Stringsoff
-> `Err Emisc
;;
- -> `Ok (getle32(buf[Mtimeoff:Mtimeoff + 8]) : time)
+ -> `Ok (_getle32(buf[Mtimeoff:Mtimeoff + 8]) : time)
}
const fsize = {path
@@ -145,7 +144,7 @@ const fsize = {path
if sys.stat(path, buf[:]) < Stringsoff
-> `Err Emisc
;;
- -> `Ok (getle64(buf[Lengthoff:Lengthoff + 8]) : off)
+ -> `Ok (_getle64(buf[Lengthoff:Lengthoff + 8]) : off)
}
extern const put : (fmt : byte[:], args : ... -> int64)
@@ -155,7 +154,7 @@ const fisdir = {path
if sys.stat(path, buf[:]) < Stringsoff
-> false
;;
- -> (getle32(buf[Modeoff:Modeoff + 4]) & sys.Dmdir) != 0
+ -> (_getle32(buf[Modeoff:Modeoff + 4]) & sys.Dmdir) != 0
}
const fisreg = {path
@@ -166,8 +165,8 @@ const fisreg = {path
-> false
;;
- ty = getle16(buf[Typeoff:Typeoff + 2])
- if (getle32(buf[Modeoff:Modeoff + 4]) & sys.Dmdir) != 0
+ ty = _getle16(buf[Typeoff:Typeoff + 2])
+ if (_getle32(buf[Modeoff:Modeoff + 4]) & sys.Dmdir) != 0
-> false
/* ugh. maybe this call should just be '!fisdir()' */
elif ty == '|' || ty == 's' || ty == 'm'
@@ -221,6 +220,8 @@ const execve = {cmd, args, env;
-> lasterr()
}
+
+
/* memory stuff */
const getmem = {sz
var endp, oldp
@@ -267,3 +268,27 @@ generic check = {e : @a::(integral, numeric) -> result(@b, errno)
-> `Ok (e : @b)
;;
}
+
+/* duplicated code to break dependency cycle */
+generic _getle16 = {buf
+ -> ((buf[0] : @a::(numeric,integral)) << 0) | \
+ ((buf[1] : @a::(numeric,integral)) << 8)
+}
+
+generic _getle32 = {buf
+ -> ((buf[0] : @a::(numeric,integral)) << 0) | \
+ ((buf[1] : @a::(numeric,integral)) << 8) | \
+ ((buf[2] : @a::(numeric,integral)) << 16) | \
+ ((buf[3] : @a::(numeric,integral)) << 24)
+}
+
+generic _getle64 = {buf
+ -> ((buf[0] : @a::(numeric,integral)) << 0) | \
+ ((buf[1] : @a::(numeric,integral)) << 8) | \
+ ((buf[2] : @a::(numeric,integral)) << 16) | \
+ ((buf[3] : @a::(numeric,integral)) << 24) | \
+ ((buf[4] : @a::(numeric,integral)) << 32) | \
+ ((buf[5] : @a::(numeric,integral)) << 40) | \
+ ((buf[6] : @a::(numeric,integral)) << 48) | \
+ ((buf[7] : @a::(numeric,integral)) << 56)
+}