summaryrefslogtreecommitdiff
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
parente12f1d5c28797ee73fba56e4adf86a40491fc779 (diff)
downloadmc-8ccd239d70ff98001c857e8ebf8fb509b64477d4.tar.gz
Misc 9front fixes.
-rw-r--r--lib/std/syswrap+plan9.myr37
-rw-r--r--lib/sys/sys+plan9-x64.myr20
-rw-r--r--parse/infer.c2
3 files changed, 51 insertions, 8 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)
+}
diff --git a/lib/sys/sys+plan9-x64.myr b/lib/sys/sys+plan9-x64.myr
index 808ca21..a42a0a2 100644
--- a/lib/sys/sys+plan9-x64.myr
+++ b/lib/sys/sys+plan9-x64.myr
@@ -146,6 +146,7 @@ pkg sys =
const segflush : (va : void#, len : uint32 -> int64)
const unmount : (name : byte[:], old : byte[:] -> int64)
const errstr : (buf : byte[:] -> int64)
+ const _errstr : (buf : byte[:] -> int64)
const stat : (name : byte[:], edir : byte[:] -> int64)
const fstat : (fd : fd, edir : byte[:] -> int64)
const wstat : (name : byte[:], edir : byte[:] -> int64)
@@ -207,7 +208,7 @@ const segdetach = {va; -> syscall(Syssegdetach, a(va))}
const segfree = {va, len; -> syscall(Syssegfree, a(va), a(len))}
const segflush = {va, len; -> syscall(Syssegfree, a(va), a(len))}
const unmount = {name, old; -> syscall(Sysunmount, cstring(name), cstring(old))}
-const errstr = {buf; -> syscall(Syserrstr, p(buf), a(buf.len))}
+const _errstr = {buf; -> syscall(Syserrstr, p(buf), a(buf.len))}
const stat = {name, edir; -> syscall(Sysstat, cstring(name), p(edir), a(edir.len))}
const fstat = {fd, edir; -> syscall(Sysstat, a(fd), p(edir), a(edir.len))}
const wstat = {name, edir; -> syscall(Syswstat, cstring(name), p(edir), a(edir.len))}
@@ -237,6 +238,23 @@ const exec = {bin, args
-> syscall(Sysexec, cstring(bin), a(cargs))
}
+const errstr = {eb
+ var tmp : byte[128]
+ var n
+
+ n = 128
+ if eb.len < tmp.len
+ n = eb.len
+ ;;
+ _errstr(tmp[:])
+ for var i = 0; i < n; i++
+ eb[i] = tmp[i]
+ ;;
+ _errstr(tmp[:])
+ -> 0
+}
+
+
/*const fversion = {fd, bufsz, vers, nvers; -> syscall(Sysfversion, fd, bufsz, }*/
const semacquire = {addr, block; -> (syscall(Syssemacquire, a(addr), a(block)) : int)}
const tsemacquire = {addr, ms; -> (syscall(Systsemacquire, a(addr), a(ms)) : int)}
diff --git a/parse/infer.c b/parse/infer.c
index 1818e37..8a0bd03 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -109,7 +109,7 @@ static char *nodetystr(Inferstate *st, Node *n)
if (n->type == Nexpr && exprtype(n) != NULL)
t = tyfix(st, NULL, exprtype(n), 1);
else if (n->type == Ndecl && decltype(n) != NULL)
- t = tyfix(st, NULL, decltype(n), 1);
+ t = tyfix(st, n, decltype(n), 1);
if (t && tybase(t)->type != Tyvar)
return tystr(t);