diff options
-rwxr-xr-x | bootstrap.sh | 4 | ||||
-rwxr-xr-x | configure | 9 | ||||
-rw-r--r-- | libstd/getcwd.myr | 1 | ||||
-rw-r--r-- | libstd/sys+osx-x64.myr | 47 | ||||
-rw-r--r-- | libstd/syscall+linux-x64.s | 1 | ||||
-rw-r--r-- | libstd/syscall+osx-x64.s | 13 | ||||
-rw-r--r-- | libstd/syswrap+posixy.myr | 2 | ||||
-rw-r--r-- | libstd/syswrap-ss+posixy-linux.myr | 2 | ||||
-rw-r--r-- | libstd/syswrap-ss+posixy-osx.myr | 16 | ||||
-rw-r--r-- | mbld/main.myr | 3 | ||||
-rw-r--r-- | mbld/parse.myr | 3 |
11 files changed, 88 insertions, 13 deletions
diff --git a/bootstrap.sh b/bootstrap.sh index 9a37036..efb4b57 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -208,5 +208,5 @@ echo ../6/6m -I ../libstd -I ../libbio -I ../libregex test.myr ../6/6m -I ../libstd -I ../libbio -I ../libregex test.myr echo ../6/6m -I ../libstd -I ../libbio -I ../libregex main.myr ../6/6m -I ../libstd -I ../libbio -I ../libregex main.myr -echo ld -o mbld ../rt/_myrrt.o clean.o config.o deps.o types.o fsel.o util.o subdir.o main.o parse.o build.o opts.o install.o test.o -L../libstd -L../libbio -L../libregex -L/home/ori/bin/lib/myr -lregex -lbio -lstd -lsys -lsys -lstd -lbio -lregex - ld -o mbld ../rt/_myrrt.o clean.o config.o deps.o types.o fsel.o util.o subdir.o main.o parse.o build.o opts.o install.o test.o -L../libstd -L../libbio -L../libregex -L/home/ori/bin/lib/myr -lregex -lbio -lstd -lsys -lsys -lstd -lbio -lregex +echo ld -macosx_version_min 10.6 -pagezero_size 100000000 -o mbld ../rt/_myrrt.o clean.o config.o deps.o types.o fsel.o util.o subdir.o main.o parse.o build.o opts.o install.o test.o -L../libstd -L../libbio -L../libregex -lregex -lbio -lstd -lsys -lsys -lstd -lbio -lregex + ld -macosx_version_min 10.6 -pagezero_size 100000000 -o mbld ../rt/_myrrt.o clean.o config.o deps.o types.o fsel.o util.o subdir.o main.o parse.o build.o opts.o install.o test.o -L../libstd -L../libbio -L../libregex -lregex -lbio -lstd -lsys -lsys -lstd -lbio -lregex @@ -40,8 +40,6 @@ echo export INST_ROOT=$prefix > config.mk echo '#define Instroot "'$prefix'"' > config.h echo '#define Asmcmd {"as", "-g", "-o", NULL}' >> config.h -echo '#define Arcmd {"ar", "-rcs", NULL}' >> config.h -echo '#define Ldcmd {"ld", "-o", NULL}' >> config.h echo '#define Defaultasm Gnugas' >> config.h echo '#define Objsuffix ".o"' >> config.h echo 'export SYSCLASS=posixy' >> config.mk @@ -50,7 +48,6 @@ echo 'export SYSCLASS=posixy' >> config.mk echo "pkg config = " > mbld/config.myr echo "const Instroot = \"$prefix\"" >> mbld/config.myr echo "const Objsuffix = \".o\"" >> mbld/config.myr -echo "const Linkcmd = [\"ld\", \"-o\"]" >> mbld/config.myr echo "const Arcmd = [\"ar\", \"-rcs\"]" >> mbld/config.myr echo "const Ascmd = [\"as\", \"-g\"]" >> mbld/config.myr echo "const Directlib = false" >> mbld/config.myr @@ -62,16 +59,22 @@ case $OS in echo '#define Defaultasm Gnugas' >> config.h echo 'export SYS=linux' >> config.mk echo 'const Sys = "Linux"' >> mbld/config.myr + echo 'const Linkcmd = ["ld", "-o"]' >> mbld/config.myr ;; *Darwin*) echo '#define Symprefix "_"' >> config.h echo 'export SYS=osx' >> config.mk + echo 'const Linkcmd = ["ld", ' \ + '"-pagezero_size", "0x100000000",' \ + '"-macosx_version_min", "10.6",'\ + '"-o"]' >> mbld/config.myr echo 'const Sys = "OSX"' >> mbld/config.myr ;; *FreeBSD*) echo '#define Symprefix ""' >> config.h echo '#define Defaultasm Gnugas' >> config.h echo 'export SYS=freebsd' >> config.mk + echo 'const Linkcmd = ["ld", "-o"]' >> mbld/config.myr echo 'const Sys = "FreeBSD"' >> mbld/config.myr ;; *) diff --git a/libstd/getcwd.myr b/libstd/getcwd.myr index 406c6a4..3e9bb03 100644 --- a/libstd/getcwd.myr +++ b/libstd/getcwd.myr @@ -3,6 +3,7 @@ use "alloc.use" use "errno.use" use "extremum.use" use "syswrap.use" +use "syswrap-ss.use" pkg std = const getcwd : (-> byte[:]) ;; diff --git a/libstd/sys+osx-x64.myr b/libstd/sys+osx-x64.myr index a84c006..566274c 100644 --- a/libstd/sys+osx-x64.myr +++ b/libstd/sys+osx-x64.myr @@ -13,6 +13,7 @@ pkg sys = type filemode = uint16 /* file permission bits */ type kflags = uint16 /* kqueue flags */ type whence = int64 + type fcntlcmd = int64 type timespec = struct sec : uint64 @@ -129,6 +130,49 @@ pkg sys = const Seekcur : whence = 1 const Seekend : whence = 2 + /* system specific constants */ + const Maxpathlen : size = 1024 + + /* fcntl constants */ + const Fdupfd : fcntlcmd = 0 /* duplicate file descriptor */ + const Fgetfd : fcntlcmd = 1 /* get file descriptor flags */ + const Fsetfd : fcntlcmd = 2 /* set file descriptor flags */ + const Fgetfl : fcntlcmd = 3 /* get file status flags */ + const Fsetfl : fcntlcmd = 4 /* set file status flags */ + const Fgetown : fcntlcmd = 5 /* get SIGIO/SIGURG proc/pgrp */ + const Fsetown : fcntlcmd = 6 /* set SIGIO/SIGURG proc/pgrp */ + const Fgetlk : fcntlcmd = 7 /* get record locking information */ + const Fsetlk : fcntlcmd = 8 /* set record locking information */ + const Fsetlkw : fcntlcmd = 9 /* F_SETLK; wait if blocked */ + const Fsetlkwtimeout : fcntlcmd = 10 /* F_SETLK; wait if blocked, return on timeout */ + const Fflush_data : fcntlcmd = 40 + const Fchkclean : fcntlcmd = 41 /* Used for regression test */ + const Fpreallocate : fcntlcmd = 42 /* Preallocate storage */ + const Fsetsize : fcntlcmd = 43 /* Truncate a file without zeroing space */ + const Frdadvise : fcntlcmd = 44 /* Issue an advisory read async with no copy to user */ + const Frdahead : fcntlcmd = 45 /* turn read ahead off/on for this fd */ + /* 46,47 used to be F_READBOOTSTRAP and F_WRITEBOOTSTRAP */ + const Fnocache : fcntlcmd = 48 /* turn data caching off/on for this fd */ + const Flog2phys : fcntlcmd = 49 /* file offset to device offset */ + const Fgetpath : fcntlcmd = 50 /* return the full path of the fd */ + const Ffullfsync : fcntlcmd = 51 /* fsync + ask the drive to flush to the media */ + const Fpathpkg_check : fcntlcmd = 52 /* find which component (if any) is a package */ + const Ffreeze_fs : fcntlcmd = 53 /* "freeze" all fs operations */ + const Fthaw_fs : fcntlcmd = 54 /* "thaw" all fs operations */ + const Fglobal_nocache : fcntlcmd = 55 /* turn data caching off/on (globally) for this file */ + const Faddsigs : fcntlcmd = 59 /* add detached signatures */ + const Faddfilesigs : fcntlcmd = 61 /* add signature from same file (used by dyld for shared libs) */ + const Fgetprotclass : fcntlcmd = 63 /* Get the protection class of a file from the EA, returns int */ + const Fsetprotclass : fcntlcmd = 64 /* Set the protection class of a file for the EA, requires int */ + const Flog2phys_ext : fcntlcmd = 65 /* file offset to device offset, extended */ + const Fgetlkpid : fcntlcmd = 66 /* get record locking information, per-process */ + /* See F_DUPFD_CLOEXEC below for 67 */ + const Fsetbacktore : fcntlcmd = 70 /* Mark the file as being the backing store for another filesystem */ + const Fgetpath_mtminfo : fcntlcmd = 71 /* return the full path of the FD, but error in specific mtmd circumstances */ + /* 72 is free. It used to be F_GETENCRYPTEDDATA, which is now removed. */ + const Fsetnosigpipe : fcntlcmd = 73 /* No SIGPIPE generated on EPIPE */ + const Fgetnosigpipe : fcntlcmd = 74 /* Status of SIGPIPE for this fd */ + /* kqueue events */ const Kevadd : kflags = 0x0001 /* add event to kq (implies enable) */ const Kevdelete : kflags = 0x0002 /* delete event from kq */ @@ -595,6 +639,8 @@ pkg sys = const pipe : (fd : fd[2]# -> int64) const dup : (fd : fd -> fd) const dup2 : (src : fd, dst : fd -> fd) + /* NB: the C ABI uses '...' for the args. */ + const fcntl : (fd : fd, cmd : fcntlcmd, args : byte# -> int64) /* kqueue */ const kqueue : (-> fd) @@ -733,6 +779,7 @@ const chdir = {dir; -> syscall(Syschdir, cstring(dir))} const pipe = {fd; -> __osx_pipe(fd)} const dup = {fd; -> syscall(Sysdup, a(fd)) castto(fd)} const dup2 = {src, dst; -> syscall(Sysdup2, a(src), a(dst)) castto(fd)} +const fcntl = {fd, cmd, args; -> syscall(Sysfcntl, a(fd), a(cmd), a(args))} /* kqueueueueueueue */ const kqueue = {; -> syscall(Syskqueue) castto(fd)} diff --git a/libstd/syscall+linux-x64.s b/libstd/syscall+linux-x64.s index d1a3086..0393497 100644 --- a/libstd/syscall+linux-x64.s +++ b/libstd/syscall+linux-x64.s @@ -18,6 +18,7 @@ sys$syscall: harmless. */ movq 80 (%rsp),%rax + /* 88: hidden type arg */ movq 96 (%rsp),%rdi movq 104(%rsp),%rsi movq 112(%rsp),%rdx diff --git a/libstd/syscall+osx-x64.s b/libstd/syscall+osx-x64.s index 33b4709..18968e6 100644 --- a/libstd/syscall+osx-x64.s +++ b/libstd/syscall+osx-x64.s @@ -17,12 +17,13 @@ _sys$syscall: harmless. */ movq 80 (%rsp),%rax - movq 88 (%rsp),%rdi - movq 96 (%rsp),%rsi - movq 104(%rsp),%rdx - movq 112(%rsp),%r10 - movq 120(%rsp),%r8 - movq 128(%rsp),%r9 + /* 88: hidden type arg */ + movq 96 (%rsp),%rdi + movq 104(%rsp),%rsi + movq 112(%rsp),%rdx + movq 120(%rsp),%r10 + movq 128(%rsp),%r8 + movq 136(%rsp),%r9 syscall jae .success diff --git a/libstd/syswrap+posixy.myr b/libstd/syswrap+posixy.myr index c426d1f..31d98b5 100644 --- a/libstd/syswrap+posixy.myr +++ b/libstd/syswrap+posixy.myr @@ -68,7 +68,6 @@ pkg std = pkglocal const getmem : (sz : size -> byte#) pkglocal const freemem : (p : byte#, sz : size -> void) pkglocal const curtime : (-> time) - pkglocal const bgetcwd : (buf : byte[:] -> errno) ;; /* fd stuff */ @@ -86,7 +85,6 @@ const dup2 = {ofd, nfd; -> sys.dup2(ofd castto(sys.fd), nfd castto(sys.fd)) cast const mkdir = {path, mode; -> sys.mkdir(path, mode)} const chdir = {path; -> sys.chdir(path) == 0} const remove = {path; -> sys.unlink(path) == 0} -const bgetcwd = {buf; -> sys.getcwd(buf) castto(errno)} /* useful/portable bits of uname */ const getsysinfo = {si diff --git a/libstd/syswrap-ss+posixy-linux.myr b/libstd/syswrap-ss+posixy-linux.myr index 4cd112c..485c0af 100644 --- a/libstd/syswrap-ss+posixy-linux.myr +++ b/libstd/syswrap-ss+posixy-linux.myr @@ -2,6 +2,8 @@ use sys pkg std = const exit : (status:int -> void) + pkglocal const bgetcwd : (buf : byte[:] -> errno) ;; const exit = {status; sys.exit_group(status)} +const bgetcwd = {buf; -> sys.getcwd(buf) castto(errno)} diff --git a/libstd/syswrap-ss+posixy-osx.myr b/libstd/syswrap-ss+posixy-osx.myr index 62bc6f4..91a5dee 100644 --- a/libstd/syswrap-ss+posixy-osx.myr +++ b/libstd/syswrap-ss+posixy-osx.myr @@ -1,7 +1,23 @@ use sys +use "errno.use" pkg std = const exit : (status:int -> void) + pkglocal const bgetcwd : (buf : byte[:] -> errno) ;; const exit = {status; sys.exit(status)} +const bgetcwd = {buf + var path : byte[sys.Maxpathlen] + var fd + + fd = sys.open(".", sys.Ordonly) + if fd < 0 + -> fd castto(errno) + ;; + /* + FIXME: if the path is longer than sys.Pathmax, we should fall back to + the ugly method of finding the path. + */ + -> sys.fcntl(fd, sys.Fgetpath, path[:] castto(byte#)) castto(errno) +} diff --git a/mbld/main.myr b/mbld/main.myr index caab00a..024d2c8 100644 --- a/mbld/main.myr +++ b/mbld/main.myr @@ -18,7 +18,10 @@ const main = {args : byte[:][:] var bintarg var optctx + /* optctx = std.optinit("hb:l:s:Sr:I:C:A:M:L:R:d", args) + */ + optctx = std.optinit("", args) bld.initopts() while !std.optdone(optctx) match std.optnext(optctx) diff --git a/mbld/parse.myr b/mbld/parse.myr index 3753166..57ae4ca 100644 --- a/mbld/parse.myr +++ b/mbld/parse.myr @@ -31,6 +31,7 @@ const loadall = {b, path, dir var p : parser# var subpath, subbld, ok + std.put("loading %s in dir '%s'\n", path, dir) p = mkparser(path, dir, b.basedir) ok = bld.parse(b, p, "") for s in p.subdirs @@ -62,11 +63,13 @@ const mkparser = {path, dir, basedir const freeparser = {p std.slfree(p.fname) + /* std.slfree(p.fdir) std.slfree(p.basedir) std.slfree(p.subdirs) std.slfree(p.data) std.free(p) + */ } const failparse = {p, msg, args : ... |