ref: 1b3aab8fc6ba53376a2eff03ca08eea379b79734
parent: de0f5a18ec216eea6efb58c84ebcb9cfbb5f782c
author: Ori Bernstein <[email protected]>
date: Thu Apr 23 17:58:54 EDT 2015
Fix bootstrap on plan9. We still don't generate type descriptions, but we at least run and bootstrap.
--- /dev/null
+++ b/bootstrap9.rc
@@ -1,0 +1,214 @@
+#!/bin/rc
+pwd=`{pwd}
+echo cd $pwd/libstd
+ cd $pwd/libstd
+echo ../6/6.out `{ape/psh $pwd/sysselect.sh syserrno}
+ ../6/6.out `{ape/psh $pwd/sysselect.sh syserrno}
+echo ../6/6.out systypes.myr
+ ../6/6.out systypes.myr
+echo ../6/6.out `{ape/psh $pwd/sysselect.sh sys}
+ ../6/6.out `{ape/psh $pwd/sysselect.sh sys}
+echo ../6/6.out `{ape/psh $pwd/sysselect.sh ifreq}
+ ../6/6.out `{ape/psh $pwd/sysselect.sh ifreq}
+echo 6a -g -o util.6 `{ape/psh $pwd/sysselect.sh util}
+ 6a -g -o util.6 `{ape/psh $pwd/sysselect.sh util}
+echo 6a -g -o syscall.6 `{ape/psh $pwd/sysselect.sh syscall}
+ 6a -g -o syscall.6 `{ape/psh $pwd/sysselect.sh syscall}
+echo ../muse/6.out -o sys ifreq.use syserrno.use systypes.use sys.use
+ ../muse/6.out -o sys ifreq.use syserrno.use systypes.use sys.use
+echo ar vu libsys.a ifreq.6 util.6 syserrno.6 syscall.6 systypes.6 sys.6
+ ar vu libsys.a ifreq.6 util.6 syserrno.6 syscall.6 systypes.6 sys.6
+echo ../6/6.out -I . types.myr
+ ../6/6.out -I . types.myr
+echo ../6/6.out -I . cstrconv.myr
+ ../6/6.out -I . cstrconv.myr
+echo ../6/6.out -I . option.myr
+ ../6/6.out -I . option.myr
+echo ../6/6.out -I . `{ape/psh $pwd/sysselect.sh errno}
+ ../6/6.out -I . `{ape/psh $pwd/sysselect.sh errno}
+echo ../6/6.out -I . `{ape/psh $pwd/sysselect.sh syswrap}
+ ../6/6.out -I . `{ape/psh $pwd/sysselect.sh syswrap}
+echo ../6/6.out -I . die.myr
+ ../6/6.out -I . die.myr
+echo ../6/6.out -I . sleq.myr
+ ../6/6.out -I . sleq.myr
+echo ../6/6.out -I . hassuffix.myr
+ ../6/6.out -I . hassuffix.myr
+echo ../6/6.out -I . hashfuncs.myr
+ ../6/6.out -I . hashfuncs.myr
+echo ../6/6.out -I . slfill.myr
+ ../6/6.out -I . slfill.myr
+echo ../6/6.out -I . clear.myr
+ ../6/6.out -I . clear.myr
+echo ../6/6.out -I . extremum.myr
+ ../6/6.out -I . extremum.myr
+echo ../6/6.out -I . units.myr
+ ../6/6.out -I . units.myr
+echo ../6/6.out -I . alloc.myr
+ ../6/6.out -I . alloc.myr
+echo ../6/6.out -I . utf.myr
+ ../6/6.out -I . utf.myr
+echo ../6/6.out -I . `{ape/psh $pwd/sysselect.sh syswrap-ss}
+ ../6/6.out -I . `{ape/psh $pwd/sysselect.sh syswrap-ss}
+echo ../6/6.out -I . varargs.myr
+ ../6/6.out -I . varargs.myr
+echo ../6/6.out -I . chartype.myr
+ ../6/6.out -I . chartype.myr
+echo ../6/6.out -I . cmp.myr
+ ../6/6.out -I . cmp.myr
+echo ../6/6.out -I . hasprefix.myr
+ ../6/6.out -I . hasprefix.myr
+echo ../6/6.out -I . slcp.myr
+ ../6/6.out -I . slcp.myr
+echo ../6/6.out -I . sldup.myr
+ ../6/6.out -I . sldup.myr
+echo ../6/6.out -I . slpush.myr
+ ../6/6.out -I . slpush.myr
+echo ../6/6.out -I . bigint.myr
+ ../6/6.out -I . bigint.myr
+echo ../6/6.out -I . fltbits.myr
+ ../6/6.out -I . fltbits.myr
+echo ../6/6.out -I . fltfmt.myr
+ ../6/6.out -I . fltfmt.myr
+echo ../6/6.out -I . fmt.myr
+ ../6/6.out -I . fmt.myr
+echo ../6/6.out -I . rand.myr
+ ../6/6.out -I . rand.myr
+echo ../6/6.out -I . `{ape/psh $pwd/sysselect.sh wait}
+ ../6/6.out -I . `{ape/psh $pwd/sysselect.sh wait}
+echo ../6/6.out -I . now.myr
+ ../6/6.out -I . now.myr
+echo ../6/6.out -I . strjoin.myr
+ ../6/6.out -I . strjoin.myr
+echo ../6/6.out -I . mk.myr
+ ../6/6.out -I . mk.myr
+echo ../6/6.out -I . sljoin.myr
+ ../6/6.out -I . sljoin.myr
+echo ../6/6.out -I . result.myr
+ ../6/6.out -I . result.myr
+echo ../6/6.out -I . slurp.myr
+ ../6/6.out -I . slurp.myr
+echo ../6/6.out -I . strfind.myr
+ ../6/6.out -I . strfind.myr
+echo ../6/6.out -I . dirname.myr
+ ../6/6.out -I . dirname.myr
+echo ../6/6.out -I . putint.myr
+ ../6/6.out -I . putint.myr
+echo ../6/6.out -I . mkpath.myr
+ ../6/6.out -I . mkpath.myr
+echo ../6/6.out -I . strsplit.myr
+ ../6/6.out -I . strsplit.myr
+echo ../6/6.out -I . `{ape/psh $pwd/sysselect.sh env}
+ ../6/6.out -I . `{ape/psh $pwd/sysselect.sh env}
+echo ../6/6.out -I . endian.myr
+ ../6/6.out -I . endian.myr
+echo ../6/6.out -I . htab.myr
+ ../6/6.out -I . htab.myr
+echo ../6/6.out -I . intparse.myr
+ ../6/6.out -I . intparse.myr
+echo ../6/6.out -I . ipparse.myr
+ ../6/6.out -I . ipparse.myr
+echo ../6/6.out -I . strstrip.myr
+ ../6/6.out -I . strstrip.myr
+echo ../6/6.out -I . `{ape/psh $pwd/sysselect.sh resolve}
+ ../6/6.out -I . `{ape/psh $pwd/sysselect.sh resolve}
+echo ../6/6.out -I . strbuf.myr
+ ../6/6.out -I . strbuf.myr
+echo ../6/6.out -I . pathjoin.myr
+ ../6/6.out -I . pathjoin.myr
+echo ../6/6.out -I . optparse.myr
+ ../6/6.out -I . optparse.myr
+echo ../6/6.out -I . `{ape/psh $pwd/sysselect.sh dir}
+ ../6/6.out -I . `{ape/psh $pwd/sysselect.sh dir}
+echo ../6/6.out -I . execvp.myr
+ ../6/6.out -I . execvp.myr
+echo ../6/6.out -I . slput.myr
+ ../6/6.out -I . slput.myr
+echo ../6/6.out -I . spork.myr
+ ../6/6.out -I . spork.myr
+echo ../6/6.out -I . getint.myr
+ ../6/6.out -I . getint.myr
+echo ../6/6.out -I . blat.myr
+ ../6/6.out -I . blat.myr
+echo ../6/6.out -I . try.myr
+ ../6/6.out -I . try.myr
+echo ../6/6.out -I . sort.myr
+ ../6/6.out -I . sort.myr
+echo ../6/6.out -I . search.myr
+ ../6/6.out -I . search.myr
+echo ../6/6.out -I . getcwd.myr
+ ../6/6.out -I . getcwd.myr
+echo ../6/6.out -I . swap.myr
+ ../6/6.out -I . swap.myr
+echo ../6/6.out -I . bitset.myr
+ ../6/6.out -I . bitset.myr
+echo ../6/6.out -I . `{ape/psh $pwd/sysselect.sh dial}
+ ../6/6.out -I . `{ape/psh $pwd/sysselect.sh dial}
+echo ../muse/6.out -o std slfill.use dial.use putint.use fmt.use syswrap.use try.use sort.use blat.use pathjoin.use strjoin.use dir.use mk.use swap.use hassuffix.use execvp.use types.use ipparse.use strfind.use utf.use cstrconv.use search.use die.use units.use sljoin.use slpush.use result.use htab.use now.use strstrip.use env.use bitset.use getcwd.use rand.use resolve.use slurp.use intparse.use varargs.use strbuf.use clear.use hasprefix.use slput.use mkpath.use getint.use strsplit.use dirname.use sleq.use endian.use alloc.use optparse.use spork.use fltbits.use cmp.use syswrap-ss.use sldup.use chartype.use fltfmt.use bigint.use option.use extremum.use hashfuncs.use wait.use errno.use slcp.use
+ ../muse/6.out -o std slfill.use dial.use putint.use fmt.use syswrap.use try.use sort.use blat.use pathjoin.use strjoin.use dir.use mk.use swap.use hassuffix.use execvp.use types.use ipparse.use strfind.use utf.use cstrconv.use search.use die.use units.use sljoin.use slpush.use result.use htab.use now.use strstrip.use env.use bitset.use getcwd.use rand.use resolve.use slurp.use intparse.use varargs.use strbuf.use clear.use hasprefix.use slput.use mkpath.use getint.use strsplit.use dirname.use sleq.use endian.use alloc.use optparse.use spork.use fltbits.use cmp.use syswrap-ss.use sldup.use chartype.use fltfmt.use bigint.use option.use extremum.use hashfuncs.use wait.use errno.use slcp.use
+echo ar vu libstd.a slfill.6 dial.6 putint.6 fmt.6 syswrap.6 try.6 sort.6 blat.6 pathjoin.6 strjoin.6 dir.6 mk.6 swap.6 hassuffix.6 execvp.6 types.6 ipparse.6 strfind.6 utf.6 cstrconv.6 search.6 die.6 units.6 sljoin.6 slpush.6 result.6 htab.6 now.6 strstrip.6 env.6 bitset.6 getcwd.6 rand.6 resolve.6 slurp.6 intparse.6 varargs.6 strbuf.6 clear.6 hasprefix.6 slput.6 mkpath.6 getint.6 strsplit.6 dirname.6 sleq.6 endian.6 alloc.6 optparse.6 spork.6 fltbits.6 cmp.6 syswrap-ss.6 sldup.6 chartype.6 fltfmt.6 bigint.6 option.6 extremum.6 hashfuncs.6 wait.6 errno.6 slcp.6
+ ar vu libstd.a slfill.6 dial.6 putint.6 fmt.6 syswrap.6 try.6 sort.6 blat.6 pathjoin.6 strjoin.6 dir.6 mk.6 swap.6 hassuffix.6 execvp.6 types.6 ipparse.6 strfind.6 utf.6 cstrconv.6 search.6 die.6 units.6 sljoin.6 slpush.6 result.6 htab.6 now.6 strstrip.6 env.6 bitset.6 getcwd.6 rand.6 resolve.6 slurp.6 intparse.6 varargs.6 strbuf.6 clear.6 hasprefix.6 slput.6 mkpath.6 getint.6 strsplit.6 dirname.6 sleq.6 endian.6 alloc.6 optparse.6 spork.6 fltbits.6 cmp.6 syswrap-ss.6 sldup.6 chartype.6 fltfmt.6 bigint.6 option.6 extremum.6 hashfuncs.6 wait.6 errno.6 slcp.6
+echo cd $pwd
+ cd $pwd
+echo cd $pwd/libbio
+ cd $pwd/libbio
+echo ../6/6.out -I ../libstd bio.myr
+ ../6/6.out -I ../libstd bio.myr
+echo ../6/6.out -I ../libstd puti.myr
+ ../6/6.out -I ../libstd puti.myr
+echo ../6/6.out -I ../libstd geti.myr
+ ../6/6.out -I ../libstd geti.myr
+echo ../muse/6.out -o bio puti.use bio.use geti.use
+ ../muse/6.out -o bio puti.use bio.use geti.use
+echo ar vu libbio.a puti.6 bio.6 geti.6
+ ar vu libbio.a puti.6 bio.6 geti.6
+echo cd $pwd
+ cd $pwd
+echo cd $pwd/libregex
+ cd $pwd/libregex
+echo ../6/6.out -I ../libstd types.myr
+ ../6/6.out -I ../libstd types.myr
+echo ../6/6.out -I ../libstd interp.myr
+ ../6/6.out -I ../libstd interp.myr
+echo ../6/6.out -I ../libstd ranges.myr
+ ../6/6.out -I ../libstd ranges.myr
+echo ../6/6.out -I ../libstd compile.myr
+ ../6/6.out -I ../libstd compile.myr
+echo ../muse/6.out -o regex interp.use types.use compile.use ranges.use
+ ../muse/6.out -o regex interp.use types.use compile.use ranges.use
+echo ar vu libregex.a interp.6 types.6 compile.6 ranges.6
+ ar vu libregex.a interp.6 types.6 compile.6 ranges.6
+echo cd $pwd
+ cd $pwd
+echo cd $pwd/mbld
+ cd $pwd/mbld
+echo ../6/6.out -I ../libstd -I ../libbio -I ../libregex `{ape/psh $pwd/sysselect.sh config}
+ ../6/6.out -I ../libstd -I ../libbio -I ../libregex `{ape/psh $pwd/sysselect.sh config}
+echo ../6/6.out -I ../libstd -I ../libbio -I ../libregex opts.myr
+ ../6/6.out -I ../libstd -I ../libbio -I ../libregex opts.myr
+echo ../6/6.out -I ../libstd -I ../libbio -I ../libregex types.myr
+ ../6/6.out -I ../libstd -I ../libbio -I ../libregex types.myr
+echo ../6/6.out -I ../libstd -I ../libbio -I ../libregex util.myr
+ ../6/6.out -I ../libstd -I ../libbio -I ../libregex util.myr
+echo ../6/6.out -I ../libstd -I ../libbio -I ../libregex deps.myr
+ ../6/6.out -I ../libstd -I ../libbio -I ../libregex deps.myr
+echo ../6/6.out -I ../libstd -I ../libbio -I ../libregex fsel.myr
+ ../6/6.out -I ../libstd -I ../libbio -I ../libregex fsel.myr
+echo ../6/6.out -I ../libstd -I ../libbio -I ../libregex parse.myr
+ ../6/6.out -I ../libstd -I ../libbio -I ../libregex parse.myr
+echo ../6/6.out -I ../libstd -I ../libbio -I ../libregex build.myr
+ ../6/6.out -I ../libstd -I ../libbio -I ../libregex build.myr
+echo ../6/6.out -I ../libstd -I ../libbio -I ../libregex install.myr
+ ../6/6.out -I ../libstd -I ../libbio -I ../libregex install.myr
+echo ../6/6.out -I ../libstd -I ../libbio -I ../libregex clean.myr
+ ../6/6.out -I ../libstd -I ../libbio -I ../libregex clean.myr
+echo ../6/6.out -I ../libstd -I ../libbio -I ../libregex test.myr
+ ../6/6.out -I ../libstd -I ../libbio -I ../libregex test.myr
+echo ../6/6.out -I ../libstd -I ../libbio -I ../libregex main.myr
+ ../6/6.out -I ../libstd -I ../libbio -I ../libregex main.myr
+echo 6l -o mbld ../rt/_myrrt.6 clean.6 config.6 deps.6 types.6 fsel.6 util.6 parse.6 main.6 build.6 opts.6 install.6 test.6 -l../libregex/libregex.a -l../libbio/libbio.a -l../libstd/libstd.a -l../libsys/libsys.a -l../libsys/libsys.a -l../libstd/libstd.a -l../libbio/libbio.a -l../libregex/libregex.a
+ 6l -o mbld ../rt/_myrrt.6 clean.6 config.6 deps.6 types.6 fsel.6 util.6 parse.6 main.6 build.6 opts.6 install.6 test.6 ../libregex/libregex.a ../libbio/libbio.a ../libstd/libstd.a ../libstd/libsys.a ../libstd/libsys.a ../libstd/libstd.a ../libbio/libbio.a ../libregex/libregex.a
+echo cd $pwd
+ cd $pwd
+echo cd $pwd/libregex
+ cd $pwd/libregex
--- a/libstd/dial+plan9.myr
+++ b/libstd/dial+plan9.myr
@@ -94,7 +94,7 @@
const call = {clone, addr, netdir
var namebuf : byte[Maxpath]
var databuf : byte[Maxpath]
- var name, base
+ var name, base, dpath
var cfd, datafd
var c, n
@@ -117,8 +117,8 @@
| `None: die("there should be a '/' here\n")
| `Some i: base = c[:i]
;;
- n = bfmt(databuf[:], "%s/%s/data", base, name)
- datafd = open(databuf[:n], Ordwr)
+ dpath = bfmt(databuf[:], "%s/%s/data", base, name)
+ datafd = open(dpath, Ordwr)
:cleanup
close(cfd)
slfree(c)
--- a/libstd/env+plan9.myr
+++ b/libstd/env+plan9.myr
@@ -32,13 +32,13 @@
const getenv = {name
var buf : byte[128]
- var n
+ var s
match envfind(name)
| `Some val: -> `Some val
| `None:
- n = bfmt(buf[:], "/env/%s", name)
- match std.slurp(buf[:n])
+ s = bfmt(buf[:], "/env/%s", name)
+ match std.slurp(s)
| `Fail m: -> `None
| `Ok data:
envkey = slpush(envkey, sldup(name))
--- a/libstd/resolve+plan9.myr
+++ b/libstd/resolve+plan9.myr
@@ -1,0 +1,2 @@
+pkg std =
+;;
--- a/libstd/syserrno+plan9.myr
+++ b/libstd/syserrno+plan9.myr
@@ -1,0 +1,38 @@
+pkg sys =
+ type errno = int
+
+ const Eperm : errno = -1 /* Operation not permitted */
+ const Enoent : errno = -2 /* No such file or directory */
+ const Esrch : errno = -3 /* No such process */
+ const Eintr : errno = -4 /* Interrupted system call */
+ const Eio : errno = -5 /* I/O error */
+ const Enxio : errno = -6 /* No such device or address */
+ const E2big : errno = -7 /* Argument list too long */
+ const Enoexec : errno = -8 /* Exec format error */
+ const Ebadf : errno = -9 /* Bad file number */
+ const Echild : errno = -10 /* No child processes */
+ const Eagain : errno = -11 /* Try again */
+ const Enomem : errno = -12 /* Out of memory */
+ const Eacces : errno = -13 /* Permission denied */
+ const Efault : errno = -14 /* Bad address */
+ const Enotblk : errno = -15 /* Block device required */
+ const Ebusy : errno = -16 /* Device or resource busy */
+ const Eexist : errno = -17 /* File exists */
+ const Exdev : errno = -18 /* Cross-device link */
+ const Enodev : errno = -19 /* No such device */
+ const Enotdir : errno = -20 /* Not a directory */
+ const Eisdir : errno = -21 /* Is a directory */
+ const Einval : errno = -22 /* Invalid argument */
+ const Enfile : errno = -23 /* File table overflow */
+ const Emfile : errno = -24 /* Too many open files */
+ const Enotty : errno = -25 /* Not a typewriter */
+ const Etxtbsy : errno = -26 /* Text file busy */
+ const Efbig : errno = -27 /* File too large */
+ const Enospc : errno = -28 /* No space left on device */
+ const Espipe : errno = -29 /* Illegal seek */
+ const Erofs : errno = -30 /* Read-only file system */
+ const Emlink : errno = -31 /* Too many links */
+ const Epipe : errno = -32 /* Broken pipe */
+ const Edom : errno = -33 /* Math argument out of domain of func */
+ const Erange : errno = -34 /* Math result not representable */
+;;
--- a/libstd/syswrap+plan9.myr
+++ b/libstd/syswrap+plan9.myr
@@ -60,7 +60,6 @@
const fork : (-> pid)
const execv : (cmd : byte[:], args : byte[:][:] -> int64)
const execve : (cmd : byte[:], args : byte[:][:], env : byte[:][:] -> int64)
- const exit : (status:int -> void)
const waitpid : (pid:pid, loc:int32#, opt : int64 -> pid)
pkglocal const Canunmap : bool = true
@@ -162,27 +161,6 @@
const fork = {; -> sys.rfork(sys.Rffdg | sys.Rfrend | sys.Rfproc) castto(pid)}
const execv = {cmd, args; -> sys.exec(cmd, args) castto(int64)}
const execve = {cmd, args, env; -> sys.exec(cmd, args) castto(int64)}
-const digitchars = "0123456789"
-const exit = {status
- var buf : byte[32] /* big enough for exit status numbers */
- var n, i
-
- if status == 0
- sys.exits("")
- else
- status &= 255
- i = 100
- n = 0
- while i > 0
- if status >= i
- buf[n++] = digitchars[(status/i)%10]
- ;;
- i /= 10
- ;;
- sys.exits(buf[:n])
- ;;
-}
-
/* memory stuff */
const getmem = {sz
--- /dev/null
+++ b/libstd/syswrap-ss+plan9.myr
@@ -1,0 +1,56 @@
+use sys
+
+use "errno.use"
+use "cstrconv.use"
+
+pkg std =
+ const exit : (status : int -> void)
+ pkglocal const bgetcwd : (buf : byte[:] -> errno)
+;;
+
+const bgetcwd = {buf
+ var fd
+
+ fd = sys.open(".", sys.Ordonly)
+ if fd < 0
+ -> fd castto(errno)
+ ;;
+
+ if sys.fd2path(fd, buf) == 0
+ /*
+ Because we don't return the size, the best we can do is
+ assume that if the buffer is completely full, we have
+ truncated it. Since we truncate at utf8 characters, we
+ can have at most 3 bytes truncated (4 bytes will fit
+ any utf8 char), and one byte for the nul terminator.
+ */
+ if cstrlen(buf) + 5 == buf.len
+ -> Erange
+ else
+ -> cstrlen(buf) castto(errno)
+ ;;
+ ;;
+ -> Emisc
+}
+
+const digitchars = "0123456789"
+const exit = {status
+ var buf : byte[32] /* big enough for exit status numbers */
+ var n, i
+
+ if status == 0
+ sys.exits("")
+ else
+ status &= 255
+ i = 100
+ n = 0
+ while i > 0
+ if status >= i
+ buf[n++] = digitchars[(status/i)%10]
+ ;;
+ i /= 10
+ ;;
+ sys.exits(buf[:n])
+ ;;
+}
+
--- a/mkfile
+++ b/mkfile
@@ -4,9 +4,7 @@
mi \
6 \
muse \
- myrbuild \
rt \
- libstd \
doc
all:V: $SUB config.h
--- a/sysselect.sh
+++ b/sysselect.sh
@@ -16,6 +16,8 @@
uname_arch=`uname -m`
if test $uname_arch = "x86_64"; then
arch="x64"
+elif test $uname_arch = "amd64"; then
+ arch="x64"
fi
# check for system prefixes on .myr src
@@ -26,11 +28,18 @@
$posixy \
$sys-$arch \
$sys \
- $arch
+ $arch
do
if test -f $1+$platform.$suffix; then
- echo $1+$platform.$suffix
+ found=true
+ echo $1+$platform.$suffix
fi
done
+ if test "x$found" = "x"; then
+ if test -f $1.$suffix; then
+ found=true
+ echo $1.$suffix
+ fi
+ fi
done