shithub: mc

Download patch

ref: e898ab8413e852b6f097e047157093014246c9a2
parent: f13090387d3a76daf8b531cb2e8bfa7e26b6f344
author: Ori Bernstein <[email protected]>
date: Fri Oct 3 09:22:46 EDT 2014

Use '+' as the system separator.

--- a/libstd/Makefile
+++ b/libstd/Makefile
@@ -63,10 +63,10 @@
 
 all: lib$(MYRLIB).a $(MYRBIN) test
 
-%.myr: %-$(SYS).myr
+%.myr: %+$(SYS).myr
 	cp $< $@
 
-%.s: %-$(SYS).s
+%.s: %+$(SYS).s
 	cp $< $@
 
 test: libstd.a test.myr ../6/6m
--- /dev/null
+++ b/libstd/dir+linux.myr
@@ -1,0 +1,65 @@
+use "alloc.use"
+use "die.use"
+use "option.use"
+use "result.use"
+use "slcp.use"
+use "sldup.use"
+use "sys.use"
+use "types.use"
+
+pkg std =
+	type dir = struct
+		fd	: fd
+		buf	: byte[16384]
+		len	: int64
+		off	: int64
+	;;
+
+	const diropen	: (p : byte[:] -> std.result(dir#, byte[:]))
+	const dirread	: (d : dir# -> std.option(byte[:]))
+	const dirclose	: (d : dir# -> void)
+;;
+
+const Direntoverhead = 20
+
+const diropen = {p
+	var fd
+	var dir
+
+	fd = open(p, Ordonly | Odir)
+	if fd < 0
+		-> `Fail "couldn't open directory"
+	;;
+	dir = zalloc()
+	dir.fd = fd
+	-> `Ok dir
+}
+
+const dirread = {d
+	var len
+	var dent
+	var namelen
+
+	if d.off >= d.len
+		len = getdents64(d.fd, d.buf[:])
+		if len <= 0
+			-> `None
+		;;
+		d.len = len
+		d.off = 0
+	;;
+
+	dent = &d.buf[d.off] castto(dirent64#)
+	namelen = 0
+	d.off += dent.reclen castto(int64)
+	while dent.name[namelen] != 0
+		namelen++
+	;;
+	-> `Some sldup(dent.name[:namelen])
+}
+
+const dirclose = {d
+	close(d.fd)
+	free(d)
+}
+
--- /dev/null
+++ b/libstd/dir+osx.myr
@@ -1,0 +1,59 @@
+use "alloc.use"
+use "die.use"
+use "option.use"
+use "result.use"
+use "slcp.use"
+use "sldup.use"
+use "sys.use"
+use "types.use"
+
+pkg std =
+	type dir = struct
+		fd	: fd
+		buf	: byte[16384]
+		len	: int64
+		off	: int64
+		base	: int64
+	;;
+
+	const diropen	: (p : byte[:] -> std.result(dir#, byte[:]))
+	const dirread	: (d : dir# -> std.option(byte[:]))
+	const dirclose	: (d : dir# -> void)
+;;
+
+const diropen = {p
+	var fd
+	var dir
+
+	fd = open(p, Ordonly | Odir)
+	if fd < 0
+		-> `Fail "couldn't open directory"
+	;;
+	dir = zalloc()
+	dir.fd = fd
+	-> `Ok dir
+}
+
+const dirread = {d
+	var len
+	var dent
+
+	if d.off >= d.len
+		len = getdirentries64(d.fd, d.buf[:], &d.base)
+		if len <= 0
+			-> `None
+		;;
+		d.len = len
+		d.off = 0
+	;;
+
+	dent = &d.buf[d.off] castto(dirent64#)
+	d.off += dent.reclen castto(int64)
+	-> `Some sldup(dent.name[:dent.namlen])
+}
+
+const dirclose = {d
+	close(d.fd)
+	free(d)
+}
+
--- a/libstd/dir-linux.myr
+++ /dev/null
@@ -1,65 +1,0 @@
-use "alloc.use"
-use "die.use"
-use "option.use"
-use "result.use"
-use "slcp.use"
-use "sldup.use"
-use "sys.use"
-use "types.use"
-
-pkg std =
-	type dir = struct
-		fd	: fd
-		buf	: byte[16384]
-		len	: int64
-		off	: int64
-	;;
-
-	const diropen	: (p : byte[:] -> std.result(dir#, byte[:]))
-	const dirread	: (d : dir# -> std.option(byte[:]))
-	const dirclose	: (d : dir# -> void)
-;;
-
-const Direntoverhead = 20
-
-const diropen = {p
-	var fd
-	var dir
-
-	fd = open(p, Ordonly | Odir)
-	if fd < 0
-		-> `Fail "couldn't open directory"
-	;;
-	dir = zalloc()
-	dir.fd = fd
-	-> `Ok dir
-}
-
-const dirread = {d
-	var len
-	var dent
-	var namelen
-
-	if d.off >= d.len
-		len = getdents64(d.fd, d.buf[:])
-		if len <= 0
-			-> `None
-		;;
-		d.len = len
-		d.off = 0
-	;;
-
-	dent = &d.buf[d.off] castto(dirent64#)
-	namelen = 0
-	d.off += dent.reclen castto(int64)
-	while dent.name[namelen] != 0
-		namelen++
-	;;
-	-> `Some sldup(dent.name[:namelen])
-}
-
-const dirclose = {d
-	close(d.fd)
-	free(d)
-}
-
--- a/libstd/dir-osx.myr
+++ /dev/null
@@ -1,59 +1,0 @@
-use "alloc.use"
-use "die.use"
-use "option.use"
-use "result.use"
-use "slcp.use"
-use "sldup.use"
-use "sys.use"
-use "types.use"
-
-pkg std =
-	type dir = struct
-		fd	: fd
-		buf	: byte[16384]
-		len	: int64
-		off	: int64
-		base	: int64
-	;;
-
-	const diropen	: (p : byte[:] -> std.result(dir#, byte[:]))
-	const dirread	: (d : dir# -> std.option(byte[:]))
-	const dirclose	: (d : dir# -> void)
-;;
-
-const diropen = {p
-	var fd
-	var dir
-
-	fd = open(p, Ordonly | Odir)
-	if fd < 0
-		-> `Fail "couldn't open directory"
-	;;
-	dir = zalloc()
-	dir.fd = fd
-	-> `Ok dir
-}
-
-const dirread = {d
-	var len
-	var dent
-
-	if d.off >= d.len
-		len = getdirentries64(d.fd, d.buf[:], &d.base)
-		if len <= 0
-			-> `None
-		;;
-		d.len = len
-		d.off = 0
-	;;
-
-	dent = &d.buf[d.off] castto(dirent64#)
-	d.off += dent.reclen castto(int64)
-	-> `Some sldup(dent.name[:dent.namlen])
-}
-
-const dirclose = {d
-	close(d.fd)
-	free(d)
-}
-
--- /dev/null
+++ b/libstd/ifreq+linux.myr
@@ -1,0 +1,67 @@
+use "sys.use"
+
+pkg std =
+	const Ifnamesz = 16
+
+	type ifreq_addr = struct
+		name	: byte[Ifnamesz]
+		addr	: sockaddr
+	;;
+
+	type ifreq_dstaddr = struct
+		name	: byte[Ifnamesz]
+		dstaddr	: sockaddr
+	;;
+
+	type ifreq_broadaddr = struct
+		name	: byte[Ifnamesz]
+		broadaddr	: sockaddr
+	;;
+
+	type ifreq_netmask = struct
+		name	: byte[Ifnamesz]
+		netmask	: sockaddr
+	;;
+
+
+	type ifreq_hwaddr = struct
+		name	: byte[Ifnamesz]
+		hwaddr	: sockaddr
+	;;
+
+	type ifreq_flags = struct
+		name	: byte[Ifnamesz]
+		flags	: int16
+	;;
+
+	type ifreq_ifindex = struct
+		name	: byte[Ifnamesz]
+		index	: int32
+	;;
+
+	type ifreq_metric = struct
+		name	: byte[Ifnamesz]
+		metric	: int32
+	;;
+
+
+	type ifreq_mtu = struct
+		name	: byte[Ifnamesz]
+		mtu	: int32
+	;;
+
+	type ifreq_slave = struct
+		name	: byte[Ifnamesz]
+		slave	: byte[Ifnamesz]
+	;;
+
+	type ifreq_newname = struct
+		name	: byte[Ifnamesz]
+		newname	: byte[Ifnamesz]
+	;;
+
+	type ifreq_data = struct
+		name	: byte[Ifnamesz]
+		data	: void#
+	;;
+;;
--- /dev/null
+++ b/libstd/ifreq+osx.myr
@@ -1,0 +1,77 @@
+use "sys.use"
+
+pkg std =
+	const Ifnamesz = 16
+
+	type ifreq_addr = struct
+		name	: byte[Ifnamesz]
+		addr	: sockaddr
+	;;
+
+	type ifreq_dstaddr = struct
+		name	: byte[Ifnamesz]
+		dstaddr	: sockaddr
+	;;
+
+	type ifreq_broadaddr = struct
+		name	: byte[Ifnamesz]
+		broadaddr	: sockaddr
+	;;
+
+	type ifreq_flags = struct
+		name	: byte[Ifnamesz]
+		flags	: int16
+	;;
+
+	type ifreq_metric = struct
+		name	: byte[Ifnamesz]
+		metric	: int32
+	;;
+
+
+	type ifreq_phys = struct
+		name	: byte[Ifnamesz]
+		phys	: int32
+	;;
+
+	type ifreq_media = struct
+		name	: byte[Ifnamesz]
+		media	: int32
+	;;
+
+	type ifreq_data = struct
+		name	: byte[Ifnamesz]
+		data	: void#
+	;;
+
+	type ifreq_devmtu = struct
+		name	: byte[Ifnamesz]
+                cur	: uint32
+                min	: uint32
+                max	: uint32
+	;;
+
+	type ifreq_kpi = struct
+		name	: byte[Ifnamesz]
+                modid	: uint32
+                typeid	: uint32
+		ptr	: void#
+	;;
+
+	type ifreq_wakeflg = struct
+		name	: byte[Ifnamesz]
+		wakeflg	: uint32
+	;;
+		
+	type ifreq_routerefs = struct
+		name	: byte[Ifnamesz]
+		refs	: uint32
+	;;
+
+	type ifreq_icaps = struct
+		name	: byte[Ifnamesz]
+		req	: uint32
+		cur	: uint32
+	;;
+
+;;
--- a/libstd/ifreq-linux.myr
+++ /dev/null
@@ -1,67 +1,0 @@
-use "sys.use"
-
-pkg std =
-	const Ifnamesz = 16
-
-	type ifreq_addr = struct
-		name	: byte[Ifnamesz]
-		addr	: sockaddr
-	;;
-
-	type ifreq_dstaddr = struct
-		name	: byte[Ifnamesz]
-		dstaddr	: sockaddr
-	;;
-
-	type ifreq_broadaddr = struct
-		name	: byte[Ifnamesz]
-		broadaddr	: sockaddr
-	;;
-
-	type ifreq_netmask = struct
-		name	: byte[Ifnamesz]
-		netmask	: sockaddr
-	;;
-
-
-	type ifreq_hwaddr = struct
-		name	: byte[Ifnamesz]
-		hwaddr	: sockaddr
-	;;
-
-	type ifreq_flags = struct
-		name	: byte[Ifnamesz]
-		flags	: int16
-	;;
-
-	type ifreq_ifindex = struct
-		name	: byte[Ifnamesz]
-		index	: int32
-	;;
-
-	type ifreq_metric = struct
-		name	: byte[Ifnamesz]
-		metric	: int32
-	;;
-
-
-	type ifreq_mtu = struct
-		name	: byte[Ifnamesz]
-		mtu	: int32
-	;;
-
-	type ifreq_slave = struct
-		name	: byte[Ifnamesz]
-		slave	: byte[Ifnamesz]
-	;;
-
-	type ifreq_newname = struct
-		name	: byte[Ifnamesz]
-		newname	: byte[Ifnamesz]
-	;;
-
-	type ifreq_data = struct
-		name	: byte[Ifnamesz]
-		data	: void#
-	;;
-;;
--- a/libstd/ifreq-osx.myr
+++ /dev/null
@@ -1,77 +1,0 @@
-use "sys.use"
-
-pkg std =
-	const Ifnamesz = 16
-
-	type ifreq_addr = struct
-		name	: byte[Ifnamesz]
-		addr	: sockaddr
-	;;
-
-	type ifreq_dstaddr = struct
-		name	: byte[Ifnamesz]
-		dstaddr	: sockaddr
-	;;
-
-	type ifreq_broadaddr = struct
-		name	: byte[Ifnamesz]
-		broadaddr	: sockaddr
-	;;
-
-	type ifreq_flags = struct
-		name	: byte[Ifnamesz]
-		flags	: int16
-	;;
-
-	type ifreq_metric = struct
-		name	: byte[Ifnamesz]
-		metric	: int32
-	;;
-
-
-	type ifreq_phys = struct
-		name	: byte[Ifnamesz]
-		phys	: int32
-	;;
-
-	type ifreq_media = struct
-		name	: byte[Ifnamesz]
-		media	: int32
-	;;
-
-	type ifreq_data = struct
-		name	: byte[Ifnamesz]
-		data	: void#
-	;;
-
-	type ifreq_devmtu = struct
-		name	: byte[Ifnamesz]
-                cur	: uint32
-                min	: uint32
-                max	: uint32
-	;;
-
-	type ifreq_kpi = struct
-		name	: byte[Ifnamesz]
-                modid	: uint32
-                typeid	: uint32
-		ptr	: void#
-	;;
-
-	type ifreq_wakeflg = struct
-		name	: byte[Ifnamesz]
-		wakeflg	: uint32
-	;;
-		
-	type ifreq_routerefs = struct
-		name	: byte[Ifnamesz]
-		refs	: uint32
-	;;
-
-	type ifreq_icaps = struct
-		name	: byte[Ifnamesz]
-		req	: uint32
-		cur	: uint32
-	;;
-
-;;
--- /dev/null
+++ b/libstd/sys+freebsd.myr
@@ -1,0 +1,795 @@
+use "types.use"
+use "varargs.use"
+
+pkg std =
+	type scno	= int64 /*syscall*/
+	type fdopt	= int64	/* fd options */
+	type fd		= int64	/* fd */
+	type mprot	= int64	/* memory protection */
+	type mopt	= int64	/* memory mapping options */
+	type socktype	= int64	/* socket type */
+	type sockproto	= int64	/* socket protocol */
+	type sockfam	= uint8	/* socket family */
+	type filemode	= uint16
+	type filetype	= uint8
+
+	type clock = union
+		`Clockrealtime
+		`Clockrealtime_precise
+		`Clockrealtime_fast
+		`Clockmonotonic
+		`Clockmonotonic_precise     
+		`Clockmonotonic_fast
+		`Clockuptime
+		`Clockuptime_precise
+		`Clockuptime_fast
+		`Clockvirtual
+		`Clockprof
+		`Clocksecond
+	;;
+
+	type timespec = struct
+		sec	: uint64
+		nsec	: uint64 
+	;;
+
+	type timeval = struct
+		sec	: uint64
+		usec	: uint64
+	;;
+
+	type rusage = struct
+		utime	: timeval /* user time */
+		stime	: timeval /* system time */
+		maxrss	: uint64 /* max resident set size*/
+		ixrss	: uint64 /* shared text size */
+		idrss	: uint64 /* unshared data size */
+		isrss	: uint64 /* unshared stack size */
+		minflt	: uint64 /* page reclaims */
+		majflt	: uint64 /* page faults */
+		nswap	: uint64 /* swaps */
+		inblock	: uint64 /* block input ops */
+		oublock	: uint64 /* block output ops */
+		msgsnd	: uint64 /* messages sent */	
+		msgrcv	: uint64 /* messages received */
+		nsignals : uint64 /* signals received */
+		nvcsw	: uint64 /* voluntary context switches */
+		nivcsw	: uint64 /* involuntary context switches */
+	;;
+
+	type statbuf = struct
+		dev	: uint32 
+		ino	: uint32 
+		mode	: filemode
+		nlink	: uint16
+		uid	: uint32
+		gid	: uint32
+		rdev	: uint32
+		atim	: timespec
+		mtim	: timespec
+		ctim	: timespec
+		size	: int64
+		blocks	: int64
+		blksize	: uint32
+		flags	: uint32
+		gen	: uint32
+		lspare	: int32
+		birthtim	: timespec 
+	;;
+
+	type utsname = struct
+		system	: byte[256]
+		node : byte[256] 
+		release : byte[256]
+		version : byte[256]
+		machine : byte[256]
+	;;
+
+	type sockaddr = struct
+		len	: byte
+		fam	: sockfam
+		data	: byte[14] /* what is the *actual* length? */
+	;;
+
+	type sockaddr_in = struct
+		len	: byte
+		fam	: sockfam
+		port	: uint16
+		addr	: byte[4]
+		zero	: byte[8]
+	;;
+
+	type sockaddr_storage = struct
+		len	: byte
+		fam	: sockfam
+		__pad1  : byte[6]
+		__align : int64
+		__pad2  : byte[112]
+	;;	
+	
+	type dirent = struct
+		fileno	: uint32
+		reclen	: uint16
+		ftype	: filetype
+		namelen	: uint8
+		name	: byte[256]	
+	;;	
+
+	/* open options */
+	const Ordonly  	: fdopt = 0x0
+	const Owronly  	: fdopt = 0x1
+	const Ordwr    	: fdopt = 0x2
+	const Oappend  	: fdopt = 0x8
+	const Ocreat   	: fdopt = 0x200
+	const Onofollow	: fdopt = 0x100
+	const Ondelay  	: fdopt = 0x4
+	const Otrunc   	: fdopt = 0x400
+	const Odir	: fdopt = 0x20000
+
+        /* stat modes */	
+	const Sifmt	: filemode = 0xf000
+	const Sififo	: filemode = 0x1000
+	const Sifchr	: filemode = 0x2000
+	const Sifdir	: filemode = 0x4000
+	const Sifblk	: filemode = 0x6000
+	const Sifreg	: filemode = 0x8000
+	const Siflnk	: filemode = 0xa000
+	const Sifsock 	: filemode = 0xc000
+
+	/* mmap protection */
+	const Mprotnone	: mprot = 0x0
+	const Mprotrd	: mprot = 0x1
+	const Mprotwr	: mprot = 0x2
+	const Mprotexec	: mprot = 0x4
+	const Mprotrw	: mprot = 0x3
+
+	/* mmap options */
+	const Mshared	: mopt = 0x1
+	const Mpriv	: mopt = 0x2
+	const Mfixed	: mopt = 0x10
+	const Mfile	: mopt = 0x0
+	const Manon	: mopt = 0x1000
+	const M32bit	: mopt = 0x80000
+
+	/* file types */
+	const Dtunknown	: filetype = 0
+	const Dtfifo	: filetype = 1
+	const Dtchr	: filetype = 2
+	const Dtdir	: filetype = 4
+	const Dtblk	: filetype = 6
+	const Dtreg	: filetype = 8
+	const Dtlnk	: filetype = 10
+	const Dtsock	: filetype = 12
+	const Dtwht	: filetype = 14
+
+	/* socket families. INCOMPLETE. */
+	const Afunspec	: sockfam = 0
+	const Afunix	: sockfam = 1
+	const Afinet	: sockfam = 2
+	const Afinet6	: sockfam = 28
+
+	/* socket types. */
+	const Sockstream	: socktype = 1
+	const Sockdgram		: socktype = 2
+	const Sockraw		: socktype = 3
+	const Sockrdm		: socktype = 4
+	const Sockseqpacket	: socktype = 5
+
+	/* network protocols */
+	const Ipproto_ip	: sockproto = 0
+	const Ipproto_icmp	: sockproto = 1
+	const Ipproto_tcp	: sockproto = 6
+	const Ipproto_udp	: sockproto = 17
+	const Ipproto_raw	: sockproto = 255
+
+	/* return value for a failed mapping */
+	const Mapbad	: byte# = -1 castto(byte#)
+
+	/* syscalls */
+	const Syssyscall                   : scno = 0
+	const Sysexit                      : scno = 1
+	const Sysfork                      : scno = 2
+	const Sysread                      : scno = 3
+	const Syswrite                     : scno = 4
+	const Sysopen                      : scno = 5
+	const Sysclose                     : scno = 6
+	const Syswait4                     : scno = 7
+	const Syslink                      : scno = 9
+	const Sysunlink                    : scno = 10
+	const Syschdir                     : scno = 12
+	const Sysfchdir                    : scno = 13
+	const Sysmknod                     : scno = 14
+	const Syschmod                     : scno = 15
+	const Syschown                     : scno = 16
+	const Sysbreak                     : scno = 17
+	const Sysfreebsd4_getfsstat        : scno = 18
+	const Sysgetpid                    : scno = 20
+	const Sysmount                     : scno = 21
+	const Sysunmount                   : scno = 22
+	const Syssetuid                    : scno = 23
+	const Sysgetuid                    : scno = 24
+	const Sysgeteuid                   : scno = 25
+	const Sysptrace                    : scno = 26
+	const Sysrecvmsg                   : scno = 27
+	const Syssendmsg                   : scno = 28
+	const Sysrecvfrom                  : scno = 29
+	const Sysaccept                    : scno = 30
+	const Sysgetpeername               : scno = 31
+	const Sysgetsockname               : scno = 32
+	const Sysaccess                    : scno = 33
+	const Syschflags                   : scno = 34
+	const Sysfchflags                  : scno = 35
+	const Syssync                      : scno = 36
+	const Syskill                      : scno = 37
+	const Sysgetppid                   : scno = 39
+	const Sysdup                       : scno = 41
+	const Syspipe                      : scno = 42
+	const Sysgetegid                   : scno = 43
+	const Sysprofil                    : scno = 44
+	const Sysktrace                    : scno = 45
+	const Sysgetgid                    : scno = 47
+	const Sysgetlogin                  : scno = 49
+	const Syssetlogin                  : scno = 50
+	const Sysacct                      : scno = 51
+	const Syssigaltstack               : scno = 53
+	const Sysioctl                     : scno = 54
+	const Sysreboot                    : scno = 55
+	const Sysrevoke                    : scno = 56
+	const Syssymlink                   : scno = 57
+	const Sysreadlink                  : scno = 58
+	const Sysexecve                    : scno = 59
+	const Sysumask                     : scno = 60
+	const Syschroot                    : scno = 61
+	const Sysmsync                     : scno = 65
+	const Sysvfork                     : scno = 66
+	const Syssbrk                      : scno = 69
+	const Syssstk                      : scno = 70
+	const Sysvadvise                   : scno = 72
+	const Sysmunmap                    : scno = 73
+	const Sysmprotect                  : scno = 74
+	const Sysmadvise                   : scno = 75
+	const Sysmincore                   : scno = 78
+	const Sysgetgroups                 : scno = 79
+	const Syssetgroups                 : scno = 80
+	const Sysgetpgrp                   : scno = 81
+	const Syssetpgid                   : scno = 82
+	const Syssetitimer                 : scno = 83
+	const Sysswapon                    : scno = 85
+	const Sysgetitimer                 : scno = 86
+	const Sysgetdtablesize             : scno = 89
+	const Sysdup2                      : scno = 90
+	const Sysfcntl                     : scno = 92
+	const Sysselect                    : scno = 93
+	const Sysfsync                     : scno = 95
+	const Syssetpriority               : scno = 96
+	const Syssocket                    : scno = 97
+	const Sysconnect                   : scno = 98
+	const Sysgetpriority               : scno = 100
+	const Sysbind                      : scno = 104
+	const Syssetsockopt                : scno = 105
+	const Syslisten                    : scno = 106
+	const Sysgettimeofday              : scno = 116
+	const Sysgetrusage                 : scno = 117
+	const Sysgetsockopt                : scno = 118
+	const Sysreadv                     : scno = 120
+	const Syswritev                    : scno = 121
+	const Syssettimeofday              : scno = 122
+	const Sysfchown                    : scno = 123
+	const Sysfchmod                    : scno = 124
+	const Syssetreuid                  : scno = 126
+	const Syssetregid                  : scno = 127
+	const Sysrename                    : scno = 128
+	const Sysflock                     : scno = 131
+	const Sysmkfifo                    : scno = 132
+	const Syssendto                    : scno = 133
+	const Sysshutdown                  : scno = 134
+	const Syssocketpair                : scno = 135
+	const Sysmkdir                     : scno = 136
+	const Sysrmdir                     : scno = 137
+	const Sysutimes                    : scno = 138
+	const Sysadjtime                   : scno = 140
+	const Syssetsid                    : scno = 147
+	const Sysquotactl                  : scno = 148
+	const Sysnlm_syscall               : scno = 154
+	const Sysnfssvc                    : scno = 155
+	const Sysfreebsd4_statfs           : scno = 157
+	const Sysfreebsd4_fstatfs          : scno = 158
+	const Syslgetfh                    : scno = 160
+	const Sysgetfh                     : scno = 161
+	const Sysfreebsd4_getdomainname    : scno = 162
+	const Sysfreebsd4_setdomainname    : scno = 163
+	const Sysfreebsd4_uname            : scno = 164
+	const Syssysarch                   : scno = 165
+	const Sysrtprio                    : scno = 166
+	const Syssemsys                    : scno = 169
+	const Sysmsgsys                    : scno = 170
+	const Sysshmsys                    : scno = 171
+	const Sysfreebsd6_pread            : scno = 173
+	const Sysfreebsd6_pwrite           : scno = 174
+	const Syssetfib                    : scno = 175
+	const Sysntp_adjtime               : scno = 176
+	const Syssetgid                    : scno = 181
+	const Syssetegid                   : scno = 182
+	const Sysseteuid                   : scno = 183
+	const Sysstat                      : scno = 188
+	const Sysfstat                     : scno = 189
+	const Syslstat                     : scno = 190
+	const Syspathconf                  : scno = 191
+	const Sysfpathconf                 : scno = 192
+	const Sysgetrlimit                 : scno = 194
+	const Syssetrlimit                 : scno = 195
+	const Sysgetdirentries             : scno = 196
+	const Sysfreebsd6_mmap             : scno = 197
+	const Sys__syscall                 : scno = 198
+	const Sysfreebsd6_lseek            : scno = 199
+	const Sysfreebsd6_truncate         : scno = 200
+	const Sysfreebsd6_ftruncate        : scno = 201
+	const Sys__sysctl                  : scno = 202
+	const Sysmlock                     : scno = 203
+	const Sysmunlock                   : scno = 204
+	const Sysundelete                  : scno = 205
+	const Sysfutimes                   : scno = 206
+	const Sysgetpgid                   : scno = 207
+	const Syspoll                      : scno = 209
+	const Sysfreebsd7___semctl         : scno = 220
+	const Syssemget                    : scno = 221
+	const Syssemop                     : scno = 222
+	const Sysfreebsd7_msgctl           : scno = 224
+	const Sysmsgget                    : scno = 225
+	const Sysmsgsnd                    : scno = 226
+	const Sysmsgrcv                    : scno = 227
+	const Sysshmat                     : scno = 228
+	const Sysfreebsd7_shmctl           : scno = 229
+	const Sysshmdt                     : scno = 230
+	const Sysshmget                    : scno = 231
+	const Sysclock_gettime             : scno = 232
+	const Sysclock_settime             : scno = 233
+	const Sysclock_getres              : scno = 234
+	const Sysktimer_create             : scno = 235
+	const Sysktimer_delete             : scno = 236
+	const Sysktimer_settime            : scno = 237
+	const Sysktimer_gettime            : scno = 238
+	const Sysktimer_getoverrun         : scno = 239
+	const Sysnanosleep                 : scno = 240
+	const Sysffclock_getcounter        : scno = 241
+	const Sysffclock_setestimate       : scno = 242
+	const Sysffclock_getestimate       : scno = 243
+	const Sysclock_getcpuclockid2      : scno = 247
+	const Sysntp_gettime               : scno = 248
+	const Sysminherit                  : scno = 250
+	const Sysrfork                     : scno = 251
+	const Sysopenbsd_poll              : scno = 252
+	const Sysissetugid                 : scno = 253
+	const Syslchown                    : scno = 254
+	const Sysaio_read                  : scno = 255
+	const Sysaio_write                 : scno = 256
+	const Syslio_listio                : scno = 257
+	const Sysgetdents                  : scno = 272
+	const Syslchmod                    : scno = 274
+	const Sysnetbsd_lchown             : scno = 275
+	const Syslutimes                   : scno = 276
+	const Sysnetbsd_msync              : scno = 277
+	const Sysnstat                     : scno = 278
+	const Sysnfstat                    : scno = 279
+	const Sysnlstat                    : scno = 280
+	const Syspreadv                    : scno = 289
+	const Syspwritev                   : scno = 290
+	const Sysfreebsd4_fhstatfs         : scno = 297
+	const Sysfhopen                    : scno = 298
+	const Sysfhstat                    : scno = 299
+	const Sysmodnext                   : scno = 300
+	const Sysmodstat                   : scno = 301
+	const Sysmodfnext                  : scno = 302
+	const Sysmodfind                   : scno = 303
+	const Syskldload                   : scno = 304
+	const Syskldunload                 : scno = 305
+	const Syskldfind                   : scno = 306
+	const Syskldnext                   : scno = 307
+	const Syskldstat                   : scno = 308
+	const Syskldfirstmod               : scno = 309
+	const Sysgetsid                    : scno = 310
+	const Syssetresuid                 : scno = 311
+	const Syssetresgid                 : scno = 312
+	const Sysaio_return                : scno = 314
+	const Sysaio_suspend               : scno = 315
+	const Sysaio_cancel                : scno = 316
+	const Sysaio_error                 : scno = 317
+	const Sysoaio_read                 : scno = 318
+	const Sysoaio_write                : scno = 319
+	const Sysolio_listio               : scno = 320
+	const Sysyield                     : scno = 321
+	const Sysmlockall                  : scno = 324
+	const Sysmunlockall                : scno = 325
+	const Sys__getcwd                  : scno = 326
+	const Syssched_setparam            : scno = 327
+	const Syssched_getparam            : scno = 328
+	const Syssched_setscheduler        : scno = 329
+	const Syssched_getscheduler        : scno = 330
+	const Syssched_yield               : scno = 331
+	const Syssched_get_priority_max    : scno = 332
+	const Syssched_get_priority_min    : scno = 333
+	const Syssched_rr_get_interval     : scno = 334
+	const Sysutrace                    : scno = 335
+	const Sysfreebsd4_sendfile         : scno = 336
+	const Syskldsym                    : scno = 337
+	const Sysjail                      : scno = 338
+	const Sysnnpfs_syscall             : scno = 339
+	const Syssigprocmask               : scno = 340
+	const Syssigsuspend                : scno = 341
+	const Sysfreebsd4_sigaction        : scno = 342
+	const Syssigpending                : scno = 343
+	const Sysfreebsd4_sigreturn        : scno = 344
+	const Syssigtimedwait              : scno = 345
+	const Syssigwaitinfo               : scno = 346
+	const Sys__acl_get_file            : scno = 347
+	const Sys__acl_set_file            : scno = 348
+	const Sys__acl_get_fd              : scno = 349
+	const Sys__acl_set_fd              : scno = 350
+	const Sys__acl_delete_file         : scno = 351
+	const Sys__acl_delete_fd           : scno = 352
+	const Sys__acl_aclcheck_file       : scno = 353
+	const Sys__acl_aclcheck_fd         : scno = 354
+	const Sysextattrctl                : scno = 355
+	const Sysextattr_set_file          : scno = 356
+	const Sysextattr_get_file          : scno = 357
+	const Sysextattr_delete_file       : scno = 358
+	const Sysaio_waitcomplete          : scno = 359
+	const Sysgetresuid                 : scno = 360
+	const Sysgetresgid                 : scno = 361
+	const Syskqueue                    : scno = 362
+	const Syskevent                    : scno = 363
+	const Sysextattr_set_fd            : scno = 371
+	const Sysextattr_get_fd            : scno = 372
+	const Sysextattr_delete_fd         : scno = 373
+	const Sys__setugid                 : scno = 374
+	const Syseaccess                   : scno = 376
+	const Sysafs3_syscall              : scno = 377
+	const Sysnmount                    : scno = 378
+	const Sys__mac_get_proc            : scno = 384
+	const Sys__mac_set_proc            : scno = 385
+	const Sys__mac_get_fd              : scno = 386
+	const Sys__mac_get_file            : scno = 387
+	const Sys__mac_set_fd              : scno = 388
+	const Sys__mac_set_file            : scno = 389
+	const Syskenv                      : scno = 390
+	const Syslchflags                  : scno = 391
+	const Sysuuidgen                   : scno = 392
+	const Syssendfile                  : scno = 393
+	const Sysmac_syscall               : scno = 394
+	const Sysgetfsstat                 : scno = 395
+	const Sysstatfs                    : scno = 396
+	const Sysfstatfs                   : scno = 397
+	const Sysfhstatfs                  : scno = 398
+	const Sysksem_close                : scno = 400
+	const Sysksem_post                 : scno = 401
+	const Sysksem_wait                 : scno = 402
+	const Sysksem_trywait              : scno = 403
+	const Sysksem_init                 : scno = 404
+	const Sysksem_open                 : scno = 405
+	const Sysksem_unlink               : scno = 406
+	const Sysksem_getvalue             : scno = 407
+	const Sysksem_destroy              : scno = 408
+	const Sys__mac_get_pid             : scno = 409
+	const Sys__mac_get_link            : scno = 410
+	const Sys__mac_set_link            : scno = 411
+	const Sysextattr_set_link          : scno = 412
+	const Sysextattr_get_link          : scno = 413
+	const Sysextattr_delete_link       : scno = 414
+	const Sys__mac_execve              : scno = 415
+	const Syssigaction                 : scno = 416
+	const Syssigreturn                 : scno = 417
+	const Sysgetcontext                : scno = 421
+	const Syssetcontext                : scno = 422
+	const Sysswapcontext               : scno = 423
+	const Sysswapoff                   : scno = 424
+	const Sys__acl_get_link            : scno = 425
+	const Sys__acl_set_link            : scno = 426
+	const Sys__acl_delete_link         : scno = 427
+	const Sys__acl_aclcheck_link       : scno = 428
+	const Syssigwait                   : scno = 429
+	const Systhr_create                : scno = 430
+	const Systhr_exit                  : scno = 431
+	const Systhr_self                  : scno = 432
+	const Systhr_kill                  : scno = 433
+	const Sys_umtx_lock                : scno = 434
+	const Sys_umtx_unlock              : scno = 435
+	const Sysjail_attach               : scno = 436
+	const Sysextattr_list_fd           : scno = 437
+	const Sysextattr_list_file         : scno = 438
+	const Sysextattr_list_link         : scno = 439
+	const Sysksem_timedwait            : scno = 441
+	const Systhr_suspend               : scno = 442
+	const Systhr_wake                  : scno = 443
+	const Syskldunloadf                : scno = 444
+	const Sysaudit                     : scno = 445
+	const Sysauditon                   : scno = 446
+	const Sysgetauid                   : scno = 447
+	const Syssetauid                   : scno = 448
+	const Sysgetaudit                  : scno = 449
+	const Syssetaudit                  : scno = 450
+	const Sysgetaudit_addr             : scno = 451
+	const Syssetaudit_addr             : scno = 452
+	const Sysauditctl                  : scno = 453
+	const Sys_umtx_op                  : scno = 454
+	const Systhr_new                   : scno = 455
+	const Syssigqueue                  : scno = 456
+	const Syskmq_open                  : scno = 457
+	const Syskmq_setattr               : scno = 458
+	const Syskmq_timedreceive          : scno = 459
+	const Syskmq_timedsend             : scno = 460
+	const Syskmq_notify                : scno = 461
+	const Syskmq_unlink                : scno = 462
+	const Sysabort2                    : scno = 463
+	const Systhr_set_name              : scno = 464
+	const Sysaio_fsync                 : scno = 465
+	const Sysrtprio_thread             : scno = 466
+	const Syssctp_peeloff              : scno = 471
+	const Syssctp_generic_sendmsg      : scno = 472
+	const Syssctp_generic_sendmsg_iov  : scno = 473
+	const Syssctp_generic_recvmsg      : scno = 474
+	const Syspread                     : scno = 475
+	const Syspwrite                    : scno = 476
+	const Sysmmap                      : scno = 477
+	const Syslseek                     : scno = 478
+	const Systruncate                  : scno = 479
+	const Sysftruncate                 : scno = 480
+	const Systhr_kill2                 : scno = 481
+	const Sysshm_open                  : scno = 482
+	const Sysshm_unlink                : scno = 483
+	const Syscpuset                    : scno = 484
+	const Syscpuset_setid              : scno = 485
+	const Syscpuset_getid              : scno = 486
+	const Syscpuset_getaffinity        : scno = 487
+	const Syscpuset_setaffinity        : scno = 488
+	const Sysfaccessat                 : scno = 489
+	const Sysfchmodat                  : scno = 490
+	const Sysfchownat                  : scno = 491
+	const Sysfexecve                   : scno = 492
+	const Sysfstatat                   : scno = 493
+	const Sysfutimesat                 : scno = 494
+	const Syslinkat                    : scno = 495
+	const Sysmkdirat                   : scno = 496
+	const Sysmkfifoat                  : scno = 497
+	const Sysmknodat                   : scno = 498
+	const Sysopenat                    : scno = 499
+	const Sysreadlinkat                : scno = 500
+	const Sysrenameat                  : scno = 501
+	const Syssymlinkat                 : scno = 502
+	const Sysunlinkat                  : scno = 503
+	const Sysposix_openpt              : scno = 504
+	const Sysgssd_syscall              : scno = 505
+	const Sysjail_get                  : scno = 506
+	const Sysjail_set                  : scno = 507
+	const Sysjail_remove               : scno = 508
+	const Sysclosefrom                 : scno = 509
+	const Sys__semctl                  : scno = 510
+	const Sysmsgctl                    : scno = 511
+	const Sysshmctl                    : scno = 512
+	const Syslpathconf                 : scno = 513
+	const Sys__cap_rights_get          : scno = 515
+	const Syscap_enter                 : scno = 516
+	const Syscap_getmode               : scno = 517
+	const Syspdfork                    : scno = 518
+	const Syspdkill                    : scno = 519
+	const Syspdgetpid                  : scno = 520
+	const Syspselect                   : scno = 522
+	const Sysgetloginclass             : scno = 523
+	const Syssetloginclass             : scno = 524
+	const Sysrctl_get_racct            : scno = 525
+	const Sysrctl_get_rules            : scno = 526
+	const Sysrctl_get_limits           : scno = 527
+	const Sysrctl_add_rule             : scno = 528
+	const Sysrctl_remove_rule          : scno = 529
+	const Sysposix_fallocate           : scno = 530
+	const Sysposix_fadvise             : scno = 531
+	const Syswait6                     : scno = 532
+	const Syscap_rights_limit          : scno = 533
+	const Syscap_ioctls_limit          : scno = 534
+	const Syscap_ioctls_get            : scno = 535
+	const Syscap_fcntls_limit          : scno = 536
+	const Syscap_fcntls_get            : scno = 537
+	const Sysbindat                    : scno = 538
+	const Sysconnectat                 : scno = 539
+	const Syschflagsat                 : scno = 540
+	const Sysaccept4                   : scno = 541
+	const Syspipe2                     : scno = 542
+	const Sysaio_mlock                 : scno = 543
+	const Sysprocctl                   : scno = 544
+
+	extern const syscall : (sc:scno, args:... -> int64)
+
+	/* process control */
+	const exit	: (status:int -> void)
+	const getpid	: ( -> int64)
+	const kill	: (pid:int64, sig:int64 -> int64)
+	const fork	: (-> int64)
+	const wait4	: (pid:int64, loc:int32#, opt : int64, usage:rusage#	-> int64)
+	const waitpid	: (pid:int64, loc:int32#, opt : int64	-> int64)
+	const execv	: (cmd : byte[:], args : byte[:][:] -> int64)
+	const execve	: (cmd : byte[:], args : byte[:][:], env : byte[:][:] -> int64)
+
+	/* fd manipulation */
+	const open	: (path:byte[:], opts:fdopt -> fd)
+	const openmode	: (path:byte[:], opts:fdopt, mode:int64 -> fd)
+	const close	: (fd:fd -> int64)
+	const creat	: (path:byte[:], mode:int64 -> fd)
+	const read	: (fd:fd, buf:byte[:] -> size)
+	const write	: (fd:fd, buf:byte[:] -> size)
+	const lseek	: (fd:fd, off:uint64, whence:int64 -> int64)
+	const stat	: (path:byte[:], sb:statbuf# -> int64)
+	const lstat	: (path:byte[:], sb:statbuf# -> int64)
+	const fstat	: (fd:fd, sb:statbuf# -> int64)
+	const mkdir	: (path : byte[:], mode : int64	-> int64)
+	const ioctl	: (fd:fd, req : int64, args:... -> int64)
+	const getdirentries64	: (fd : fd, buf : byte[:], basep : uint64# -> int64)
+
+	/* networking */
+	const socket	: (dom : sockfam, stype : socktype, proto : sockproto	-> fd)
+	const connect	: (sock	: fd, addr : sockaddr#, len : size -> int)
+	const accept	: (sock : fd, addr : sockaddr#, len : size# -> fd)
+	const listen	: (sock : fd, backlog : int	-> int)
+	const bind	: (sock : fd, addr : sockaddr#, len : size -> int)
+
+	/* memory mapping */
+	const munmap	: (addr:byte#, len:size -> int64)
+	const mmap	: (addr:byte#, len:size, prot:mprot, flags:mopt, fd:fd, off:off -> byte#)
+
+	/* time - doublecheck if this is right */
+	const clock_getres	: (clk : clock, ts : timespec# -> int32)
+	const clock_gettime	: (clk : clock, ts : timespec# -> int32)
+	const clock_settime	: (clk : clock, ts : timespec# -> int32)
+	const sleep	: (time : uint64 -> int32)
+	const nanosleep	: (req : timespec#, rem : timespec# -> int32)
+
+	/* system information */
+	const uname 	: (buf : utsname# -> int)
+	const sysctl	: (mib : int[:], old : byte[:]#, new : byte[:] -> int)
+;;
+
+/* 
+wraps a syscall argument, converting it to 64 bits for the syscall function. This is
+the same as casting, but more concise than writing castto(int64)
+*/
+generic a = {x : @t
+	-> a(x)
+}
+
+extern const cstring	: (str : byte[:] -> byte#)
+extern const alloca	: (sz : size	-> byte#)
+extern const __cenvp : byte##
+
+/* process management */
+const exit	= {status;		syscall(Sysexit, a(status))}
+const getpid	= {;			-> syscall(Sysgetpid, 1)}
+const kill	= {pid, sig;		-> syscall(Syskill, pid, sig)}
+const fork	= {;			-> syscall(Sysfork)}
+const wait4	= {pid, loc, opt, usage;	-> syscall(Syswait4, pid, loc, opt, usage)}
+const waitpid	= {pid, loc, opt;
+	-> wait4(pid, loc, opt, 0 castto(rusage#)) 
+}
+
+const execv	= {cmd, args
+	var p, cargs, i
+
+	/* of course we fucking have to duplicate this code everywhere,
+	* since we want to stack allocate... */
+	p = alloca((args.len + 1)*sizeof(byte#))
+	cargs = (p castto(byte##))[:args.len]
+	for i = 0; i < args.len; i++
+		cargs[i] = cstring(args[i])
+	;;
+	cargs[args.len] = 0 castto(byte#)
+	-> syscall(Sysexecve, cstring(cmd), a(p), a(__cenvp))
+}
+
+const execve	= {cmd, args, env
+	var cargs, cenv, i
+	var p
+
+	/* copy the args */
+	p = alloca((args.len + 1)*sizeof(byte#))
+	cargs = (p castto(byte##))[:args.len]
+	for i = 0; i < args.len; i++
+		cargs[i] = cstring(args[i])
+	;;
+	cargs[args.len] = 0 castto(byte#)
+
+	/*
+	 copy the env.
+	 of course we fucking have to duplicate this code everywhere,
+	 since we want to stack allocate... 
+	*/
+	p = alloca((env.len + 1)*sizeof(byte#))
+	cenv = (p castto(byte##))[:env.len]
+	for i = 0; i < env.len; i++
+		cenv[i] = cstring(env[i])
+	;;
+	cenv[env.len] = 0 castto(byte#)
+
+	-> syscall(Sysexecve, cstring(cmd), a(p), a(cenv))
+}
+
+/* fd manipulation */
+const open	= {path, opts;		-> syscall(Sysopen, cstring(path), a(opts), a(0o777)) castto(fd)}
+const openmode	= {path, opts, mode;	-> syscall(Sysopen, cstring(path), a(opts), a(mode)) castto(fd)}
+const close	= {fd;			-> syscall(Sysclose, a(fd))}
+const creat	= {path, mode;		-> openmode(path, Ocreat | Otrunc | Owronly, mode) castto(fd)}
+const read	= {fd, buf;		-> syscall(Sysread, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
+const write	= {fd, buf;		-> syscall(Syswrite, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
+const lseek	= {fd, off, whence;	-> syscall(Syslseek, a(fd), a(off), a(whence))}
+const stat	= {path, sb;		-> syscall(Sysstat, cstring(path), a(sb))}
+const lstat	= {path, sb;		-> syscall(Syslstat, cstring(path), a(sb))}
+const fstat	= {fd, sb;		-> syscall(Sysfstat, a(fd), a(sb))}
+const mkdir	= {path, mode;		-> syscall(Sysmkdir, cstring(path), a(mode)) castto(int64)}
+const ioctl	= {fd, req, args
+	var arg : byte#
+	var ap
+
+	ap = vastart(&args)
+	(arg, ap) = vanext(ap)
+	-> syscall(Sysioctl, a(fd), a(req), a(arg)) castto(int64)
+}
+const getdirentries64	= {fd, buf, basep;	-> syscall(Sysgetdirentries, a(fd), buf castto(byte#), a(buf.len), a(basep))}
+
+/* networking */
+const socket	= {dom, stype, proto;	-> syscall(Syssocket, a(dom), a(stype), a(proto)) castto(fd) }
+const connect	= {sock, addr, len;	-> syscall(Sysconnect, a(sock), a(addr), a(len)) castto(int)}
+const accept	= {sock, addr, len;	-> syscall(Sysaccept, a(sock), a(addr), a(len)) castto(fd)}
+const listen	= {sock, backlog;	-> syscall(Syslisten, a(sock), a(backlog)) castto(int)}
+const bind	= {sock, addr, len;	-> syscall(Sysbind, a(sock), a(addr), a(len)) castto(int)}
+
+/* memory management */
+const munmap	= {addr, len;		-> syscall(Sysmunmap, a(addr), a(len))}
+const mmap	= {addr, len, prot, flags, fd, off;
+	-> syscall(Sysmmap, a(addr), a(len), a(prot), a(flags), a(fd), a(off)) castto(byte#)}
+
+/* time */
+const clock_getres = {clk, ts;	-> syscall(Sysclock_getres, clockid(clk), a(ts)) castto(int32)}
+const clock_gettime = {clk, ts;	-> syscall(Sysclock_gettime, clockid(clk), a(ts)) castto(int32)}
+const clock_settime = {clk, ts;	-> syscall(Sysclock_settime, clockid(clk), a(ts)) castto(int32)}
+
+/* system information */
+const uname	= {buf;	-> syscall(Sysfreebsd4_uname, a(buf)) castto(int)}
+
+const sysctl = {mib, old, new
+	var mibp
+	var mibsz
+	var o
+	var oldp
+	var oldsz
+	var newp
+	var newsz
+	var ret
+
+	mibp = mib castto(byte#)
+	mibsz = a(mib.len)
+	o = old#
+	oldp = o castto(byte#)
+	oldsz = a(o.len)
+	newp = new castto(byte#)
+	newsz = a(new.len)
+
+	/* all args already passed through a() or ar  ptrs */
+	ret = syscall(Sys__sysctl, mibp, mibsz, oldp, oldsz, newp, newsz) castto(int)
+
+	old# = o[:oldsz]
+	-> ret
+}
+
+const clockid = {clk
+	match clk
+	| `Clockrealtime:		-> 0
+	| `Clockvirtual:		-> 1
+	| `Clockprof:			-> 2
+	| `Clockmonotonic:		-> 4
+	| `Clockuptime:			-> 5
+	| `Clockuptime_precise:		-> 7
+	| `Clockuptime_fast:		-> 8
+	| `Clockrealtime_precise:	-> 9
+	| `Clockrealtime_fast:		-> 10
+	| `Clockmonotonic_precise:	-> 11
+	| `Clockmonotonic_fast:		-> 12
+	| `Clocksecond:			-> 13
+	;;
+	-> a(-1)
+}
--- /dev/null
+++ b/libstd/sys+linux.myr
@@ -1,0 +1,751 @@
+use "types.use"
+use "varargs.use"
+
+pkg std =
+	type pid	= int64	/* process id */
+	type scno	= int64	/* syscall */
+	type fdopt	= int64	/* fd options */
+	type fd		= int32	/* fd */
+	type mprot	= int64	/* memory protection */
+	type mopt	= int64	/* memory mapping options */
+
+	type socktype	= int64	/* socket type */
+	type sockproto	= int64	/* socket protocol */
+	type sockfam	= uint16	/* socket family */
+
+	type whence	= uint64
+	type filemode	= uint32
+
+	type epollflags	= uint32
+	type epollop	= uint32
+	type epollevttype	= uint32
+
+	type pollevt	= uint16
+
+	type clock = union
+		`Clockrealtime
+		`Clockmonotonic
+		`Clockproccpu
+		`Clockthreadcpu
+		`Clockmonotonicraw
+		`Clockrealtimecoarse
+		`Clockmonotoniccoarse
+		`Clockboottime
+		`Clockrealtimealarm
+		`Clockboottimealarm
+	;;
+
+	type timespec = struct
+		sec	: uint64
+		nsec	: uint64
+	;;
+
+	type timeval = struct
+		sec	: uint64
+		usec	: uint64
+	;;
+
+	type rusage = struct
+		utime	: timeval	/* user time */
+		stime	: timeval	/* system time */
+		_opaque	: uint64[14]	/* padding (darwin-specific data) */
+	;;
+
+	type statbuf = struct
+		 dev	: uint64
+		 ino	: uint64
+		 nlink	: uint64
+		 mode	: filemode
+		 uid	: uint32
+		 gid	: uint32
+		 __pad0	: uint32
+		 rdev	: uint64
+		 size	: uint64
+		 blksz	: uint32
+		 blocks	: uint64
+		 atime	: timespec
+		 mtime	: timespec
+		 ctime	: timespec
+		 __pad1	: uint64[3]
+	;;
+
+	type dirent64 = struct
+		ino	: uint64
+		off	: uint64
+		reclen	: uint16
+		etype	: byte
+		name	: byte[0]
+	;;
+
+	type utsname = struct
+		system	: byte[65]
+		node	: byte[65]
+		release	: byte[65]
+		version	: byte[65]
+		machine	: byte[65]
+		domain	: byte[65]
+	;;
+
+	type sockaddr = struct
+		fam	: sockfam
+		data	: byte[14]
+	;;
+
+	type sockaddr_in = struct
+		fam	: sockfam
+		port	: uint16
+		addr	: byte[4]
+		zero	: byte[8]
+	;;
+
+	type sockaddr_storage = struct
+		fam	: sockfam
+		__align	: uint32
+		__pad	: byte[112]
+	;;
+
+	type epollevt = struct
+		events	: epollevttype
+		data	: byte[8]
+	;;
+
+	type pollfd = struct
+		fd	: fd
+		events	: pollevt
+		revents	: pollevt
+	;;
+
+
+	/* open options */
+	const Ordonly  	: fdopt = 0x0
+	const Owronly  	: fdopt = 0x1
+	const Ordwr    	: fdopt = 0x2
+	const Ocreat   	: fdopt = 0x40
+	const Oexcl  	: fdopt = 0x80
+	const Otrunc   	: fdopt = 0x200
+	const Oappend  	: fdopt = 0x400
+	const Ondelay  	: fdopt = 0x800
+	const Odirect	: fdopt = 0x4000
+	const Odir	: fdopt = 0x10000
+	const Onofollow	: fdopt = 0x20000
+
+	/* stat modes */
+	const Sifmt	: filemode = 0xf000
+	const Sififo	: filemode = 0x1000
+	const Sifchr	: filemode = 0x2000
+	const Sifdir	: filemode = 0x4000
+	const Sifblk	: filemode = 0x6000
+	const Sifreg	: filemode = 0x8000
+	const Siflnk	: filemode = 0xa000
+	const Sifsock	: filemode = 0xc000
+
+	/* mmap protection */
+	const Mprotnone	: mprot = 0x0
+	const Mprotrd	: mprot = 0x1
+	const Mprotwr	: mprot = 0x2
+	const Mprotexec	: mprot = 0x4
+	const Mprotrw	: mprot = 0x3 /* convenience */
+	
+	/* mmap options */
+	const Mshared	: mopt = 0x1
+	const Mpriv	: mopt = 0x2
+	const Mfixed	: mopt = 0x10
+	const Mfile	: mopt = 0x0
+	const Manon	: mopt = 0x20
+	const M32bit	: mopt = 0x40
+
+	/* socket families. INCOMPLETE. */
+	const Afunspec	: sockfam = 0
+	const Afunix	: sockfam = 1
+	const Afinet	: sockfam = 2
+	const Afinet6	: sockfam = 10
+
+	/* socket types. */
+	const Sockstream	: socktype = 1	/* sequenced, reliable byte stream */
+	const Sockdgram		: socktype = 2	/* datagrams */
+	const Sockraw		: socktype = 3	/* raw proto */
+	const Sockrdm		: socktype = 4	/* reliably delivered messages */
+	const Sockseqpacket	: socktype = 5	/* sequenced, reliable packets */
+	const Sockdccp		: socktype = 6	/* data congestion control protocol */
+	const Sockpack		: socktype = 10	/* linux specific packet */
+
+	/* network protocols */
+	const Ipproto_ip	: sockproto = 0
+	const Ipproto_icmp	: sockproto = 1
+	const Ipproto_tcp	: sockproto = 6
+	const Ipproto_udp	: sockproto = 17
+	const Ipproto_raw	: sockproto = 255
+
+	/* epoll flags */
+	const Epollcloexec	: epollflags	= 0o2000000
+
+	/* epoll ops */
+	const Epollctladd	: epollop	= 0
+	const Epollctlmod	: epollop	= 1
+	const Epollctldel	: epollop	= 1
+
+	/* epoll events */
+	const Epollin	: epollevttype = 0x001
+	const Epollpri	: epollevttype = 0x002
+	const Epollout	: epollevttype = 0x004
+	const Epollerr	: epollevttype = 0x008
+	const Epollhup	: epollevttype = 0x010
+	const Epollrdnorm	: epollevttype = 0x040
+	const Epollrdband	: epollevttype = 0x080
+	const Epollwrnorm	: epollevttype = 0x100
+	const Epollwrband	: epollevttype = 0x200
+	const Epollmsg		: epollevttype = 0x400
+	const Epollrdhup	: epollevttype = 0x2000
+	const Epollwakeup	: epollevttype = 1 << 29
+	const Epolloneshot	: epollevttype = 1 << 30
+	const Epolledge	: epollevttype = 1 << 31
+
+	/* poll events : posix */
+	const Pollin	: pollevt = 0x001	/* There is data to read.  */
+	const Pollpri	: pollevt = 0x002	/* There is urgent data to read.  */
+	const Pollout	: pollevt = 0x004	/* Writing now will not block.  */
+
+	/* poll events: xopen */
+	const Pollrdnorm	: pollevt = 0x040	/* Normal data may be read.  */
+	const Pollrdband	: pollevt = 0x080	/* Priority data may be read.  */
+	const Pollwrnorm	: pollevt = 0x100	/* Writing now will not block.  */
+	const Pollwrband	: pollevt = 0x200	/* Priority data may be written.  */
+
+	/* poll events: linux */
+	const Pollmsg		: pollevt = 0x400
+	const Pollremove	: pollevt = 0x1000
+	const Pollrdhup		: pollevt = 0x2000
+
+	const Seekset	: whence = 0
+	const Seekcur	: whence = 1
+	const Seekend	: whence = 2
+
+	/* return value for a failed mapping */
+	const Mapbad	: byte# = -1 castto(byte#)
+
+	/* syscalls */
+	const Sysread			: scno = 0
+	const Syswrite			: scno = 1
+	const Sysopen			: scno = 2
+	const Sysclose			: scno = 3
+	const Sysstat			: scno = 4
+	const Sysfstat			: scno = 5
+	const Syslstat			: scno = 6
+	const Syspoll			: scno = 7
+	const Syslseek			: scno = 8
+	const Sysmmap			: scno = 9
+	const Sysmprotect		: scno = 10
+	const Sysmunmap			: scno = 11
+	const Sysbrk			: scno = 12
+	const Sysrt_sigaction		: scno = 13
+	const Sysrt_sigprocmask		: scno = 14
+	const Sysrt_sigreturn		: scno = 15
+	const Sysioctl			: scno = 16
+	const Syspread64		: scno = 17
+	const Syspwrite64		: scno = 18
+	const Sysreadv			: scno = 19
+	const Syswritev			: scno = 20
+	const Sysaccess			: scno = 21
+	const Syspipe			: scno = 22
+	const Sysselect			: scno = 23
+	const Syssched_yield		: scno = 24
+	const Sysmremap			: scno = 25
+	const Sysmsync			: scno = 26
+	const Sysmincore		: scno = 27
+	const Sysmadvise		: scno = 28
+	const Sysshmget			: scno = 29
+	const Sysshmat			: scno = 30
+	const Sysshmctl			: scno = 31
+	const Sysdup			: scno = 32
+	const Sysdup2			: scno = 33
+	const Syspause			: scno = 34
+	const Sysnanosleep		: scno = 35
+	const Sysgetitimer		: scno = 36
+	const Sysalarm			: scno = 37
+	const Syssetitimer		: scno = 38
+	const Sysgetpid			: scno = 39
+	const Syssendfile		: scno = 40
+	const Syssocket			: scno = 41
+	const Sysconnect		: scno = 42
+	const Sysaccept			: scno = 43
+	const Syssendto			: scno = 44
+	const Sysrecvfrom		: scno = 45
+	const Syssendmsg		: scno = 46
+	const Sysrecvmsg		: scno = 47
+	const Sysshutdown		: scno = 48
+	const Sysbind			: scno = 49
+	const Syslisten			: scno = 50
+	const Sysgetsockname		: scno = 51
+	const Sysgetpeername		: scno = 52
+	const Syssocketpair		: scno = 53
+	const Syssetsockopt		: scno = 54
+	const Sysgetsockopt		: scno = 55
+	const Sysclone			: scno = 56
+	const Sysfork			: scno = 57
+	const Sysvfork			: scno = 58
+	const Sysexecve			: scno = 59
+	const Sysexit			: scno = 60
+	const Syswait4			: scno = 61
+	const Syskill			: scno = 62
+	const Sysuname			: scno = 63
+	const Syssemget			: scno = 64
+	const Syssemop			: scno = 65
+	const Syssemctl			: scno = 66
+	const Sysshmdt			: scno = 67
+	const Sysmsgget			: scno = 68
+	const Sysmsgsnd			: scno = 69
+	const Sysmsgrcv			: scno = 70
+	const Sysmsgctl			: scno = 71
+	const Sysfcntl			: scno = 72
+	const Sysflock			: scno = 73
+	const Sysfsync			: scno = 74
+	const Sysfdatasync		: scno = 75
+	const Systruncate		: scno = 76
+	const Sysftruncate		: scno = 77
+	const Sysgetdents		: scno = 78
+	const Sysgetcwd			: scno = 79
+	const Syschdir			: scno = 80
+	const Sysfchdir			: scno = 81
+	const Sysrename			: scno = 82
+	const Sysmkdir			: scno = 83
+	const Sysrmdir			: scno = 84
+	const Syscreat			: scno = 85
+	const Syslink			: scno = 86
+	const Sysunlink			: scno = 87
+	const Syssymlink		: scno = 88
+	const Sysreadlink		: scno = 89
+	const Syschmod			: scno = 90
+	const Sysfchmod			: scno = 91
+	const Syschown			: scno = 92
+	const Sysfchown			: scno = 93
+	const Syslchown			: scno = 94
+	const Sysumask			: scno = 95
+	const Sysgettimeofday		: scno = 96
+	const Sysgetrlimit		: scno = 97
+	const Sysgetrusage		: scno = 98
+	const Syssysinfo		: scno = 99
+	const Systimes			: scno = 100
+	const Sysptrace			: scno = 101
+	const Sysgetuid			: scno = 102
+	const Syssyslog			: scno = 103
+	const Sysgetgid			: scno = 104
+	const Syssetuid			: scno = 105
+	const Syssetgid			: scno = 106
+	const Sysgeteuid		: scno = 107
+	const Sysgetegid		: scno = 108
+	const Syssetpgid		: scno = 109
+	const Sysgetppid		: scno = 110
+	const Sysgetpgrp		: scno = 111
+	const Syssetsid			: scno = 112
+	const Syssetreuid		: scno = 113
+	const Syssetregid		: scno = 114
+	const Sysgetgroups		: scno = 115
+	const Syssetgroups		: scno = 116
+	const Syssetresuid		: scno = 117
+	const Sysgetresuid		: scno = 118
+	const Syssetresgid		: scno = 119
+	const Sysgetresgid		: scno = 120
+	const Sysgetpgid		: scno = 121
+	const Syssetfsuid		: scno = 122
+	const Syssetfsgid		: scno = 123
+	const Sysgetsid			: scno = 124
+	const Syscapget			: scno = 125
+	const Syscapset			: scno = 126
+	const Sysrt_sigpending		: scno = 127
+	const Sysrt_sigtimedwait	: scno = 128
+	const Sysrt_sigqueueinfo	: scno = 129
+	const Sysrt_sigsuspend		: scno = 130
+	const Syssigaltstack		: scno = 131
+	const Sysutime			: scno = 132
+	const Sysmknod			: scno = 133
+	const Sysuselib			: scno = 134
+	const Syspersonality		: scno = 135
+	const Sysustat			: scno = 136
+	const Sysstatfs			: scno = 137
+	const Sysfstatfs		: scno = 138
+	const Syssysfs			: scno = 139
+	const Sysgetpriority		: scno = 140
+	const Syssetpriority		: scno = 141
+	const Syssched_setparam		: scno = 142
+	const Syssched_getparam		: scno = 143
+	const Syssched_setscheduler	: scno = 144
+	const Syssched_getscheduler	: scno = 145
+	const Syssched_get_priority_max	: scno = 146
+	const Syssched_get_priority_min	: scno = 147
+	const Syssched_rr_get_interval	: scno = 148
+	const Sysmlock			: scno = 149
+	const Sysmunlock		: scno = 150
+	const Sysmlockall		: scno = 151
+	const Sysmunlockall		: scno = 152
+	const Sysvhangup		: scno = 153
+	const Sysmodify_ldt		: scno = 154
+	const Syspivot_root		: scno = 155
+	const Sys_sysctl		: scno = 156
+	const Sysprctl			: scno = 157
+	const Sysarch_prctl		: scno = 158
+	const Sysadjtimex		: scno = 159
+	const Syssetrlimit		: scno = 160
+	const Syschroot			: scno = 161
+	const Syssync			: scno = 162
+	const Sysacct			: scno = 163
+	const Syssettimeofday		: scno = 164
+	const Sysmount			: scno = 165
+	const Sysumount2		: scno = 166
+	const Sysswapon			: scno = 167
+	const Sysswapoff		: scno = 168
+	const Sysreboot			: scno = 169
+	const Syssethostname		: scno = 170
+	const Syssetdomainname		: scno = 171
+	const Sysiopl			: scno = 172
+	const Sysioperm			: scno = 173
+	const Syscreate_module		: scno = 174
+	const Sysinit_module		: scno = 175
+	const Sysdelete_module		: scno = 176
+	const Sysget_kernel_syms	: scno = 177
+	const Sysquery_module		: scno = 178
+	const Sysquotactl		: scno = 179
+	const Sysnfsservctl		: scno = 180
+	const Sysgetpmsg		: scno = 181
+	const Sysputpmsg		: scno = 182
+	const Sysafs_syscall		: scno = 183
+	const Systuxcall		: scno = 184
+	const Syssecurity		: scno = 185
+	const Sysgettid			: scno = 186
+	const Sysreadahead		: scno = 187
+	const Syssetxattr		: scno = 188
+	const Syslsetxattr		: scno = 189
+	const Sysfsetxattr		: scno = 190
+	const Sysgetxattr		: scno = 191
+	const Syslgetxattr		: scno = 192
+	const Sysfgetxattr		: scno = 193
+	const Syslistxattr		: scno = 194
+	const Sysllistxattr		: scno = 195
+	const Sysflistxattr		: scno = 196
+	const Sysremovexattr		: scno = 197
+	const Syslremovexattr		: scno = 198
+	const Sysfremovexattr		: scno = 199
+	const Systkill			: scno = 200
+	const Systime			: scno = 201
+	const Sysfutex			: scno = 202
+	const Syssched_setaffinity	: scno = 203
+	const Syssched_getaffinity	: scno = 204
+	const Sysset_thread_area	: scno = 205
+	const Sysio_setup		: scno = 206
+	const Sysio_destroy		: scno = 207
+	const Sysio_getevents		: scno = 208
+	const Sysio_submit		: scno = 209
+	const Sysio_cancel		: scno = 210
+	const Sysget_thread_area	: scno = 211
+	const Syslookup_dcookie		: scno = 212
+	const Sysepoll_create		: scno = 213
+	const Sysepoll_ctl_old		: scno = 214
+	const Sysepoll_wait_old		: scno = 215
+	const Sysremap_file_pages	: scno = 216
+	const Sysgetdents64		: scno = 217
+	const Sysset_tid_address	: scno = 218
+	const Sysrestart_syscall	: scno = 219
+	const Syssemtimedop		: scno = 220
+	const Sysfadvise64		: scno = 221
+	const Systimer_create		: scno = 222
+	const Systimer_settime		: scno = 223
+	const Systimer_gettime		: scno = 224
+	const Systimer_getoverrun	: scno = 225
+	const Systimer_delete		: scno = 226
+	const Sysclock_settime		: scno = 227
+	const Sysclock_gettime		: scno = 228
+	const Sysclock_getres		: scno = 229
+	const Sysclock_nanosleep	: scno = 230
+	const Sysexit_group		: scno = 231
+	const Sysepoll_wait		: scno = 232
+	const Sysepoll_ctl		: scno = 233
+	const Systgkill			: scno = 234
+	const Sysutimes			: scno = 235
+	const Sysvserver		: scno = 236
+	const Sysmbind			: scno = 237
+	const Sysset_mempolicy		: scno = 238
+	const Sysget_mempolicy		: scno = 239
+	const Sysmq_open		: scno = 240
+	const Sysmq_unlink		: scno = 241
+	const Sysmq_timedsend		: scno = 242
+	const Sysmq_timedreceive	: scno = 243
+	const Sysmq_notify		: scno = 244
+	const Sysmq_getsetattr		: scno = 245
+	const Syskexec_load		: scno = 246
+	const Syswaitid			: scno = 247
+	const Sysadd_key		: scno = 248
+	const Sysrequest_key		: scno = 249
+	const Syskeyctl			: scno = 250
+	const Sysioprio_set		: scno = 251
+	const Sysioprio_get		: scno = 252
+	const Sysinotify_init		: scno = 253
+	const Sysinotify_add_watch	: scno = 254
+	const Sysinotify_rm_watch	: scno = 255
+	const Sysmigrate_pages		: scno = 256
+	const Sysopenat			: scno = 257
+	const Sysmkdirat		: scno = 258
+	const Sysmknodat		: scno = 259
+	const Sysfchownat		: scno = 260
+	const Sysfutimesat		: scno = 261
+	const Sysnewfstatat		: scno = 262
+	const Sysunlinkat		: scno = 263
+	const Sysrenameat		: scno = 264
+	const Syslinkat			: scno = 265
+	const Syssymlinkat		: scno = 266
+	const Sysreadlinkat		: scno = 267
+	const Sysfchmodat		: scno = 268
+	const Sysfaccessat		: scno = 269
+	const Syspselect6		: scno = 270
+	const Sysppoll			: scno = 271
+	const Sysunshare		: scno = 272
+	const Sysset_robust_list	: scno = 273
+	const Sysget_robust_list	: scno = 274
+	const Syssplice			: scno = 275
+	const Systee			: scno = 276
+	const Syssync_file_range	: scno = 277
+	const Sysvmsplice		: scno = 278
+	const Sysmove_pages		: scno = 279
+	const Sysutimensat		: scno = 280
+	const Sysepoll_pwait		: scno = 281
+	const Syssignalfd		: scno = 282
+	const Systimerfd_create		: scno = 283
+	const Syseventfd		: scno = 284
+	const Sysfallocate		: scno = 285
+	const Systimerfd_settime	: scno = 286
+	const Systimerfd_gettime	: scno = 287
+	const Sysaccept4		: scno = 288
+	const Syssignalfd4		: scno = 289
+	const Syseventfd2		: scno = 290
+	const Sysepoll_create1		: scno = 291
+	const Sysdup3			: scno = 292
+	const Syspipe2			: scno = 293
+	const Sysinotify_init1		: scno = 294
+	const Syspreadv			: scno = 295
+	const Syspwritev		: scno = 296
+	const Sysrt_tgsigqueueinfo	: scno = 297
+	const Sysperf_event_open	: scno = 298
+	const Sysrecvmmsg		: scno = 299
+	const Sysfanotify_init		: scno = 300
+	const Sysfanotify_mark		: scno = 301
+	const Sysprlimit64		: scno = 302
+	const Sysname_to_handle_at	: scno = 303
+	const Sysopen_by_handle_at	: scno = 304
+	const Sysclock_adjtime		: scno = 305
+	const Syssyncfs			: scno = 306
+	const Syssendmmsg		: scno = 307
+	const Syssetns			: scno = 308
+	const Sysgetcpu			: scno = 309
+	const Sysprocess_vm_readv	: scno = 310
+	const Sysprocess_vm_writev	: scno = 311
+
+	/* getting to the os */
+	extern const syscall	: (sc:scno, args:... -> int64)
+
+	/* process management */
+	const exit	: (status:int -> void)
+	const getpid	: ( -> pid)
+	const kill	: (pid:pid, sig:int64 -> int64)
+	const fork	: (-> pid)
+	const clone	: (flags : uint64, stk : void#, ptid : void#, ctid : void#, ptreg : void# -> pid)
+	const wait4	: (pid:pid, loc:int32#, opt : int64, usage:rusage#	-> int64)
+	const waitpid	: (pid:pid, loc:int32#, opt : int64	-> int64)
+	const execv	: (cmd : byte[:], args : byte[:][:] -> int64)
+	const execve	: (cmd : byte[:], args : byte[:][:], env : byte[:][:] -> int64)
+
+
+	/* file manipulation */
+	const open	: (path:byte[:], opts:fdopt -> fd)
+	const openmode	: (path:byte[:], opts:fdopt, mode:int64 -> fd)
+	const close	: (fd:fd -> int64)
+	const creat	: (path:byte[:], mode:int64 -> fd)
+	const unlink	: (path:byte[:] -> int)
+	const read	: (fd:fd, buf:byte[:] -> size)
+	const write	: (fd:fd, buf:byte[:] -> size)
+	const lseek	: (fd:fd, off:uint64, whence:int64 -> int64)
+	const stat	: (path:byte[:], sb:statbuf# -> int64)
+	const lstat	: (path:byte[:], sb:statbuf# -> int64)
+	const fstat	: (fd:fd, sb:statbuf# -> int64)
+	const mkdir	: (path : byte[:], mode : int64	-> int64)
+	const ioctl	: (fd:fd, req : int64, args:... -> int64)
+	const getdents64	: (fd:fd, buf : byte[:] -> int64)
+	const chdir	: (p : byte[:] -> int64)
+
+	/* fd stuff */
+	const pipe	: (fds : fd[:] -> int64)
+	const dup	: (fd : fd -> fd)
+	const dup2	: (src : fd, dst : fd -> fd)
+
+	/* polling */
+	const epollcreate	: (flg : epollflags	-> fd)	/* actually epoll_create1 */
+	const epollctl	: (epfd : fd, op : int, fd : fd, evt : epollevt# -> int)
+	const epollwait	: (epfd : fd, evts : epollevt[:], timeout : int -> int)
+	const poll	: (pfd	: pollfd[:], timeout : int	-> int)
+
+	/* networking */
+	const socket	: (dom : sockfam, stype : socktype, proto : sockproto	-> fd)
+	const connect	: (sock	: fd, addr : sockaddr#, len : size -> int)
+	const accept	: (sock : fd, addr : sockaddr#, len : size# -> fd)
+	const listen	: (sock : fd, backlog : int	-> int)
+	const bind	: (sock : fd, addr : sockaddr#, len : size -> int)
+
+	/* memory mapping */
+	const munmap	: (addr:byte#, len:size -> int64)
+	const mmap	: (addr:byte#, len:size, prot:mprot, flags:mopt, fd:fd, off:off -> byte#)
+
+	/* time */
+	const clock_getres	: (clk : clock, ts : timespec# -> int32)
+	const clock_gettime	: (clk : clock, ts : timespec# -> int32)
+	const clock_settime	: (clk : clock, ts : timespec# -> int32)
+	const sleep	: (time : uint64 -> int32)
+	const nanosleep	: (req : timespec#, rem : timespec# -> int32)
+
+	/* system information */
+	const uname 	: (buf : utsname# -> int)
+;;
+
+/* 
+wraps a syscall argument, converting it to 64 bits for the syscall function. This is
+the same as casting, but more concise than writing castto(int64)
+*/
+generic a = {x : @t
+	-> x castto(uint64)
+}
+
+extern const cstring	: (str : byte[:] -> byte#)
+extern const alloca	: (sz : size	-> byte#)
+extern const __cenvp : byte##
+
+/* process management */
+const exit	= {status;		syscall(Sysexit, a(status))}
+const getpid	= {;			-> syscall(Sysgetpid) castto(pid)}
+const kill	= {pid, sig;		-> syscall(Syskill, a(pid), a(sig))}
+const fork	= {;			-> syscall(Sysfork) castto(pid)}
+const clone	= {flags, stk, ptid, ctid, ptreg;	-> syscall(Sysclone, a(flags), a(stk), a(ptid), a(ctid), a(ptreg)) castto(pid)}
+const wait4	= {pid, loc, opt, usage;	-> syscall(Syswait4, a(pid), a(loc), a(opt), a(usage))}
+const waitpid	= {pid, loc, opt;
+	var rusage
+	-> wait4(pid, loc, opt, &rusage)
+}
+
+const execv	= {cmd, args
+	var p, cargs, i
+
+	/* of course we fucking have to duplicate this code everywhere,
+	* since we want to stack allocate... */
+	p = alloca((args.len + 1)*sizeof(byte#))
+	cargs = (p castto(byte##))[:args.len + 1]
+	for i = 0; i < args.len; i++
+		cargs[i] = cstring(args[i])
+	;;
+	cargs[args.len] = 0 castto(byte#)
+	-> syscall(Sysexecve, cstring(cmd), a(p), a(__cenvp))
+}
+
+const execve	= {cmd, args, env
+	var cargs, cenv, i
+	var p
+
+	/* copy the args */
+	p = alloca((args.len + 1)*sizeof(byte#))
+	cargs = (p castto(byte##))[:args.len + 1]
+	for i = 0; i < args.len; i++
+		cargs[i] = cstring(args[i])
+	;;
+	cargs[args.len] = 0 castto(byte#)
+
+	/*
+	 copy the env.
+	 of course we fucking have to duplicate this code everywhere,
+	 since we want to stack allocate... 
+	*/
+	p = alloca((env.len + 1)*sizeof(byte#))
+	cenv = (p castto(byte##))[:env.len]
+	for i = 0; i < env.len; i++
+		cenv[i] = cstring(env[i])
+	;;
+	cenv[env.len] = 0 castto(byte#)
+
+	-> syscall(Sysexecve, cstring(cmd), a(p), a(cenv))
+}
+
+/* file manipulation */
+const open	= {path, opts;		-> syscall(Sysopen, cstring(path), a(opts), a(0o777)) castto(fd)}
+const openmode	= {path, opts, mode;	-> syscall(Sysopen, cstring(path), a(opts), a(mode)) castto(fd)}
+const close	= {fd;			-> syscall(Sysclose, a(fd))}
+const creat	= {path, mode;		-> syscall(Syscreat, cstring(path), a(mode)) castto(fd)}
+const unlink	= {path;		-> syscall(Sysunlink, cstring(path)) castto(int)}
+const read	= {fd, buf;		-> syscall(Sysread, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
+const write	= {fd, buf;		-> syscall(Syswrite, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
+const lseek	= {fd, off, whence;	-> syscall(Syslseek, a(fd), a(off), a(whence))}
+const stat	= {path, sb;		-> syscall(Sysstat, cstring(path), a(sb))}
+const lstat	= {path, sb;		-> syscall(Syslstat, cstring(path), a(sb))}
+const fstat	= {fd, sb;		-> syscall(Sysfstat, a(fd), a(sb))}
+const mkdir	= {path, mode;		-> syscall(Sysmkdir, cstring(path), a(mode)) castto(int64)}
+const ioctl	= {fd, req, args
+	var arg : byte#
+	var ap
+
+	ap = vastart(&args)
+	(arg, ap) = vanext(ap)
+	-> syscall(Sysioctl, a(fd), a(req), a(arg)) castto(int64)
+}
+const getdents64	= {fd, buf;	-> syscall(Sysgetdents64, a(fd), buf castto(byte#), a(buf.len))}
+const chdir	= {dir;	-> syscall(Syschdir, dir)}
+
+/* file stuff */
+const pipe	= {fds;	-> syscall(Syspipe, fds castto(fd#))}
+const dup 	= {fd;	-> syscall(Sysdup, a(fd)) castto(fd)}
+const dup2 	= {src, dst;	-> syscall(Sysdup2, a(src), a(dst)) castto(fd)}
+
+/* epoll */
+const poll	= {pfd, timeout;	-> syscall(Syspoll, pfd castto(pollfd#), a(pfd.len), a(timeout)) castto(int)}
+const epollctl	= {epfd, op, fd, evt;
+	-> syscall(Sysepoll_ctl, a(epfd), a(op), a(fd), a(evt)) castto(int)}
+const epollwait	= {epfd, evts, timeout;
+	-> syscall(Sysepoll_wait, a(epfd), evts castto(epollevt#), a(evts.len), a(timeout)) castto(int)}
+const epollcreate	= {flg;	-> syscall(Sysepoll_create1, a(flg)) castto(fd)}
+
+/* networking */
+const socket	= {dom, stype, proto;	-> syscall(Syssocket, a(dom), a(stype), a(proto)) castto(fd)}
+const connect	= {sock, addr, len;	-> syscall(Sysconnect, a(sock), a(addr), a(len)) castto(int)}
+const bind	= {sock, addr, len;	-> syscall(Sysbind, a(sock), a(addr), a(len)) castto(int)}
+const listen	= {sock, backlog;	-> syscall(Syslisten, a(sock), a(backlog)) castto(int)}
+const accept	= {sock, addr, lenp;	-> syscall(Sysaccept, a(sock), a(addr), a(lenp)) castto(fd)}
+
+/* memory mapping */
+const munmap	= {addr, len;		-> syscall(Sysmunmap, a(addr), a(len))}
+const mmap	= {addr, len, prot, flags, fd, off;
+	-> syscall(Sysmmap, a(addr), a(len), a(prot), a(flags), a(fd), a(off)) castto(byte#)
+}
+
+/* time */
+const clock_getres = {clk, ts;	-> syscall(Sysclock_getres, clockid(clk), a(ts)) castto(int32)}
+const clock_gettime = {clk, ts;	-> syscall(Sysclock_gettime, clockid(clk), a(ts)) castto(int32)}
+const clock_settime = {clk, ts;	-> syscall(Sysclock_settime, clockid(clk), a(ts)) castto(int32)}
+
+const sleep = {time
+	var req, rem
+	req = [.sec = time, .nsec = 0]
+	-> nanosleep(&req, &rem)
+}
+
+const nanosleep	= {req, rem;	-> syscall(Sysnanosleep, a(req), a(rem)) castto(int32)}
+
+/* system information */
+const uname	= {buf;	-> syscall(Sysuname, buf) castto(int)}
+
+const clockid = {clk
+	match clk
+	| `Clockrealtime:	-> 0
+	| `Clockmonotonic:	-> 1
+	| `Clockproccpu:	-> 2
+	| `Clockthreadcpu:	-> 3
+	| `Clockmonotonicraw:	-> 4
+	| `Clockrealtimecoarse:	-> 5
+	| `Clockmonotoniccoarse:-> 6
+	| `Clockboottime:	-> 7
+	| `Clockrealtimealarm:	-> 8
+	| `Clockboottimealarm:	-> 9
+	;;
+	-> -1
+}
+
--- /dev/null
+++ b/libstd/sys+osx.myr
@@ -1,0 +1,865 @@
+use "types.use"
+use "varargs.use"
+
+pkg std =
+	type scno 	= int64	/* syscall */
+	type fdopt	= int64	/* fd options */
+	type fd		= int32	/* fd */
+	type pid	= int64	/* pid */
+	type mprot	= int64	/* memory protection */
+	type mopt	= int64	/* memory mapping options */
+	type socktype	= int64	/* socket type */
+	type sockproto	= int64	/* socket protocol */
+	type sockfam	= uint8	/* socket family */
+	type filemode	= uint16	/* file permission bits */
+	type kflags	= uint16	/* kqueue flags */
+
+	type timespec = struct
+		sec	: uint64
+		nsec	: uint32
+	;;
+
+	type timeval = struct
+		sec	: uint64
+		usec	: uint32
+	;;
+
+	type timezone = struct
+		minwest	: int32 /* of greenwich */
+		dsttime	: int32	/* nonzero if DST applies */
+	;;
+
+	type clock = union
+		`Clockrealtime
+		`Clockmonotonic
+	;;
+
+	type statbuf = struct
+		dev	: int32
+		mode	: filemode
+		nlink	: uint16
+		ino	: uint64
+		uid	: uint32
+		gid	: uint32
+		rdev	: uint32
+		atime	: timespec
+		mtime	: timespec
+		ctime	: timespec
+		birthtimespec	: timespec
+		size	: off
+		blocks	: int64
+		blksize	: int32
+		flags	: uint32
+		gen	: uint32
+		_spare	: uint32
+		_qspare	: uint64[2]
+	;;
+
+	type rusage = struct
+		utime	: timeval	/* user time */
+		stime	: timeval	/* system time */
+		_opaque	: uint64[14]	/* padding (darwin-specific data) */
+	;;
+
+	type utsname = struct
+		system	: byte[256]
+		node	: byte[256]
+		release	: byte[256]
+		version	: byte[256]
+		machine	: byte[256]
+	;;
+
+	type sockaddr = struct
+		len	: byte
+		fam	: sockfam
+		data	: byte[14] /* what is the *actual* length? */
+	;;
+
+	type sockaddr_in = struct
+		len	: byte
+		fam	: sockfam
+		port	: uint16
+		addr	: byte[4]
+		zero	: byte[8]
+	;;
+
+	type sockaddr_storage = struct
+		len	: byte
+		fam	: sockfam
+		__pad1	: byte[6]
+		__align	: uint64
+		__pad2	: byte[112]
+	;;
+
+	type dirent64 = struct
+		ino	: uint64
+		seekoff	: uint64	/* seek offset (optional, used by servers) */
+		reclen	: uint16	/* length of this record */
+		namlen	: uint16	/* length of string in d_name */
+		typeid  : uint8		/* file type, see below */
+		name	: byte[0]
+	;;
+
+	type kevent = struct
+		ident	: intptr	/* identifier for this event */
+		filter	: int16		/* filter for event */
+		flags	: uint16	/* general flags */
+		fflags	: uint32	/* filter-specific flags */
+		data	: intptr	/* filter-specific data */
+		udata	: byte#		/* opaque user data identifier */
+	;;
+
+	type kevent64 = struct
+		ident	: uint64	/* identifier for this event */
+		filter	: int16		/* filter for event */
+		flags	: kflags	/* general flags */
+		fflags	: uint32	/* filter-specific flags */
+		data	: int64		/* filter-specific data */
+		udata	: uint64	/* opaque user data identifier */
+		ext	: uint64[2]	/* filter-specific extensions */
+	;;
+
+	/* kqueue events */
+	const Kevadd		: kflags = 0x0001	/* add event to kq (implies enable) */
+	const Kevdelete		: kflags = 0x0002	/* delete event from kq */
+	const Kevenable		: kflags = 0x0004	/* enable event */
+	const Kevdisable	: kflags = 0x0008	/* disable event (not reported) */
+	const Kevreceipt	: kflags = 0x0040	/* force EV_ERROR on success, data == 0 */
+
+	/* kqueue flags */
+	const Kevoneshot	: kflags = 0x0010	/* only report one occurrence */
+	const Kevclear		: kflags = 0x0020	/* clear event state after reporting */
+	const Kevdispatch	: kflags = 0x0080	/* disable event after reporting */
+
+	const Kevsysflags	: kflags = 0xf000	/* reserved by system */
+	const Kevflag0		: kflags = 0x1000	/* filter-specific flag */
+	const Kevflag1		: kflags = 0x2000	/* filter-specific flag */
+
+	/* kqueue returned values */
+	const Keveof		: kflags = 0x8000	/* eof detected */
+	const Keverror		: kflags = 0x4000	/* error, data contains errno */
+
+	/* open options */
+	const Ordonly  	: fdopt = 0x0
+	const Owronly  	: fdopt = 0x1
+	const Ordwr    	: fdopt = 0x2
+	const Ondelay  	: fdopt = 0x4
+	const Oappend  	: fdopt = 0x8
+	const Ocreat   	: fdopt = 0x200
+	const Onofollow	: fdopt = 0x100
+	const Otrunc   	: fdopt = 0x400
+	const Odir	: fdopt = 0x100000
+
+	/* stat modes */
+	const Sifmt	: filemode = 0xf000
+	const Sififo	: filemode = 0x1000
+	const Sifchr	: filemode = 0x2000
+	const Sifdir	: filemode = 0x4000
+	const Sifblk	: filemode = 0x6000
+	const Sifreg	: filemode = 0x8000
+	const Siflnk	: filemode = 0xa000
+	const Sifsock	: filemode = 0xc000
+
+	/* mmap protection */
+	const Mprotnone	: mprot = 0x0
+	const Mprotrd	: mprot = 0x1
+	const Mprotwr	: mprot = 0x2
+	const Mprotexec	: mprot = 0x4
+	const Mprotrw	: mprot = 0x3
+
+	/* mmap options */
+	const Mshared	: mopt = 0x1
+	const Mpriv	: mopt = 0x2
+	const Mfixed	: mopt = 0x10
+	const Mfile	: mopt = 0x0
+	const Manon	: mopt = 0x1000
+	/* Only on Linux
+	const M32bit	: mopt = 0x40
+	*/
+
+	/* socket families. INCOMPLETE. */
+	const Afunspec	: sockfam = 0
+	const Afunix	: sockfam = 1
+	const Afinet	: sockfam = 2
+	const Afinet6	: sockfam = 30
+
+	/* socket types. */
+	const Sockstream	: socktype = 1
+	const Sockdgram		: socktype = 2
+	const Sockraw		: socktype = 3
+	const Sockrdm		: socktype = 4
+	const Sockseqpacket	: socktype = 5
+
+	/* network protocols */
+	const Ipproto_ip	: sockproto = 0
+	const Ipproto_icmp	: sockproto = 1
+	const Ipproto_tcp	: sockproto = 6
+	const Ipproto_udp	: sockproto = 17
+	const Ipproto_raw	: sockproto = 255
+
+	/* return value for a failed mapping */
+	const Mapbad	: byte# = -1 castto(byte#)
+
+	/* syscalls.
+	note, creat() implemented as open(path, Creat|Trunc|Wronly) */
+	const Syssyscall	: scno = 0x2000000
+	const Sysexit		: scno = 0x2000001
+	const Sysfork		: scno = 0x2000002
+	const Sysread		: scno = 0x2000003
+	const Syswrite		: scno = 0x2000004
+	const Sysopen		: scno = 0x2000005
+	const Sysclose		: scno = 0x2000006
+	const Syswait4		: scno = 0x2000007
+	const Syslink		: scno = 0x2000009
+	const Sysunlink		: scno = 0x200000a
+	const Syschdir		: scno = 0x200000c
+	const Sysfchdir		: scno = 0x200000d
+	const Sysmknod		: scno = 0x200000e
+	const Syschmod		: scno = 0x200000f
+	const Syschown		: scno = 0x2000010
+	const Sysgetfsstat	: scno = 0x2000012
+	const Sysgetpid		: scno = 0x2000014
+	const Syssetuid		: scno = 0x2000017
+	const Sysgetuid		: scno = 0x2000018
+	const Sysgeteuid	: scno = 0x2000019
+	const Sysptrace		: scno = 0x200001a
+	const Sysrecvmsg	: scno = 0x200001b
+	const Syssendmsg	: scno = 0x200001c
+	const Sysrecvfrom	: scno = 0x200001d
+	const Sysaccept		: scno = 0x200001e
+	const Sysgetpeername	: scno = 0x200001f
+	const Sysgetsockname	: scno = 0x2000020
+	const Sysaccess		: scno = 0x2000021
+	const Syschflags	: scno = 0x2000022
+	const Sysfchflags	: scno = 0x2000023
+	const Syssync		: scno = 0x2000024
+	const Syskill		: scno = 0x2000025
+	const Sysgetppid	: scno = 0x2000027
+	const Sysdup		: scno = 0x2000029
+	const Syspipe		: scno = 0x200002a
+	const Sysgetegid	: scno = 0x200002b
+	const Sysprofil		: scno = 0x200002c
+	const Syssigaction	: scno = 0x200002e
+	const Sysgetgid		: scno = 0x200002f
+	const Syssigprocmask	: scno = 0x2000030
+	const Sysgetlogin	: scno = 0x2000031
+	const Syssetlogin	: scno = 0x2000032
+	const Sysacct		: scno = 0x2000033
+	const Syssigpending	: scno = 0x2000034
+	const Syssigaltstack	: scno = 0x2000035
+	const Sysioctl		: scno = 0x2000036
+	const Sysreboot		: scno = 0x2000037
+	const Sysrevoke		: scno = 0x2000038
+	const Syssymlink	: scno = 0x2000039
+	const Sysreadlink	: scno = 0x200003a
+	const Sysexecve		: scno = 0x200003b
+	const Sysumask		: scno = 0x200003c
+	const Syschroot		: scno = 0x200003d
+	const Sysmsync		: scno = 0x2000041
+	const Sysvfork		: scno = 0x2000042
+	const Sysmunmap		: scno = 0x2000049
+	const Sysmprotect	: scno = 0x200004a
+	const Sysmadvise	: scno = 0x200004b
+	const Sysmincore	: scno = 0x200004e
+	const Sysgetgroups	: scno = 0x200004f
+	const Syssetgroups	: scno = 0x2000050
+	const Sysgetpgrp	: scno = 0x2000051
+	const Syssetpgid	: scno = 0x2000052
+	const Syssetitimer	: scno = 0x2000053
+	const Sysswapon		: scno = 0x2000055
+	const Sysgetitimer	: scno = 0x2000056
+	const Sysgetdtablesize	: scno = 0x2000059
+	const Sysdup2		: scno = 0x200005a
+	const Sysfcntl		: scno = 0x200005c
+	const Sysselect		: scno = 0x200005d
+	const Sysfsync		: scno = 0x200005f
+	const Syssetpriority	: scno = 0x2000060
+	const Syssocket		: scno = 0x2000061
+	const Sysconnect	: scno = 0x2000062
+	const Sysgetpriority	: scno = 0x2000064
+	const Sysbind		: scno = 0x2000068
+	const Syssetsockopt	: scno = 0x2000069
+	const Syslisten		: scno = 0x200006a
+	const Syssigsuspend	: scno = 0x200006f
+	const Sysgettimeofday	: scno = 0x2000074
+	const Sysgetrusage	: scno = 0x2000075
+	const Sysgetsockopt	: scno = 0x2000076
+	const Sysreadv		: scno = 0x2000078
+	const Syswritev		: scno = 0x2000079
+	const Syssettimeofday	: scno = 0x200007a
+	const Sysfchown		: scno = 0x200007b
+	const Sysfchmod		: scno = 0x200007c
+	const Syssetreuid	: scno = 0x200007e
+	const Syssetregid	: scno = 0x200007f
+	const Sysrename		: scno = 0x2000080
+	const Sysflock		: scno = 0x2000083
+	const Sysmkfifo		: scno = 0x2000084
+	const Syssendto		: scno = 0x2000085
+	const Sysshutdown	: scno = 0x2000086
+	const Syssocketpair	: scno = 0x2000087
+	const Sysmkdir		: scno = 0x2000088
+	const Sysrmdir		: scno = 0x2000089
+	const Sysutimes		: scno = 0x200008a
+	const Sysfutimes	: scno = 0x200008b
+	const Sysadjtime	: scno = 0x200008c
+	const Sysgethostuuid	: scno = 0x200008e
+	const Syssetsid		: scno = 0x2000093
+	const Sysgetpgid	: scno = 0x2000097
+	const Syssetprivexec	: scno = 0x2000098
+	const Syspread		: scno = 0x2000099
+	const Syspwrite		: scno = 0x200009a
+	const Sysnfssvc		: scno = 0x200009b
+	const Sysstatfs		: scno = 0x200009d
+	const Sysfstatfs	: scno = 0x200009e
+	const Sysunmount	: scno = 0x200009f
+	const Sysgetfh		: scno = 0x20000a1
+	const Sysquotactl	: scno = 0x20000a5
+	const Sysmount		: scno = 0x20000a7
+	const Syscsops		: scno = 0x20000a9
+	const Syswaitid		: scno = 0x20000ad
+	const Sysadd_profil	: scno = 0x20000b0
+	const Syskdebug_trace	: scno = 0x20000b4
+	const Syssetgid		: scno = 0x20000b5
+	const Syssetegid	: scno = 0x20000b6
+	const Sysseteuid	: scno = 0x20000b7
+	const Syssigreturn	: scno = 0x20000b8
+	const Syschud		: scno = 0x20000b9
+	const Sysfdatasync	: scno = 0x20000bb
+	const Sysstat		: scno = 0x20000bc
+	const Sysfstat		: scno = 0x20000bd
+	const Syslstat		: scno = 0x20000be
+	const Syspathconf	: scno = 0x20000bf
+	const Sysfpathconf	: scno = 0x20000c0
+	const Sysgetrlimit	: scno = 0x20000c2
+	const Syssetrlimit	: scno = 0x20000c3
+	const Sysgetdirentries	: scno = 0x20000c4
+	const Sysmmap		: scno = 0x20000c5
+	const Syslseek		: scno = 0x20000c7
+	const Systruncate	: scno = 0x20000c8
+	const Sysftruncate	: scno = 0x20000c9
+	const Sys__sysctl	: scno = 0x20000ca
+	const Sysmlock		: scno = 0x20000cb
+	const Sysmunlock	: scno = 0x20000cc
+	const Sysundelete	: scno = 0x20000cd
+	const SysATsocket	: scno = 0x20000ce
+	const SysATgetmsg	: scno = 0x20000cf
+	const SysATputmsg	: scno = 0x20000d0
+	const SysATPsndreq	: scno = 0x20000d1
+	const SysATPsndrsp	: scno = 0x20000d2
+	const SysATPgetreq	: scno = 0x20000d3
+	const SysATPgetrsp	: scno = 0x20000d4
+	const Sysmkcomplex	: scno = 0x20000d8
+	const Sysstatv		: scno = 0x20000d9
+	const Syslstatv		: scno = 0x20000da
+	const Sysfstatv		: scno = 0x20000db
+	const Sysgetattrlist	: scno = 0x20000dc
+	const Syssetattrlist	: scno = 0x20000dd
+	const Sysgetdirentriesattr	: scno = 0x20000de
+	const Sysexchangedata	: scno = 0x20000df
+	const Syssearchfs	: scno = 0x20000e1
+	const Sysdelete		: scno = 0x20000e2
+	const Syscopyfile	: scno = 0x20000e3
+	const Sysfgetattrlist	: scno = 0x20000e4
+	const Sysfsetattrlist	: scno = 0x20000e5
+	const Syspoll		: scno = 0x20000e6
+	const Syswatchevent	: scno = 0x20000e7
+	const Syswaitevent	: scno = 0x20000e8
+	const Sysmodwatch	: scno = 0x20000e9
+	const Sysgetxattr	: scno = 0x20000ea
+	const Sysfgetxattr	: scno = 0x20000eb
+	const Syssetxattr	: scno = 0x20000ec
+	const Sysfsetxattr	: scno = 0x20000ed
+	const Sysremovexattr	: scno = 0x20000ee
+	const Sysfremovexattr	: scno = 0x20000ef
+	const Syslistxattr	: scno = 0x20000f0
+	const Sysflistxattr	: scno = 0x20000f1
+	const Sysfsctl		: scno = 0x20000f2
+	const Sysinitgroups	: scno = 0x20000f3
+	const Sysposix_spawn	: scno = 0x20000f4
+	const Sysffsctl		: scno = 0x20000f5
+	const Sysnfsclnt	: scno = 0x20000f7
+	const Sysfhopen		: scno = 0x20000f8
+	const Sysminherit	: scno = 0x20000fa
+	const Syssemsys		: scno = 0x20000fb
+	const Sysmsgsys		: scno = 0x20000fc
+	const Sysshmsys		: scno = 0x20000fd
+	const Syssemctl		: scno = 0x20000fe
+	const Syssemget		: scno = 0x20000ff
+	const Syssemop		: scno = 0x2000100
+	const Sysmsgctl		: scno = 0x2000102
+	const Sysmsgget		: scno = 0x2000103
+	const Sysmsgsnd		: scno = 0x2000104
+	const Sysmsgrcv		: scno = 0x2000105
+	const Sysshmat		: scno = 0x2000106
+	const Sysshmctl		: scno = 0x2000107
+	const Sysshmdt		: scno = 0x2000108
+	const Sysshmget		: scno = 0x2000109
+	const Sysshm_open	: scno = 0x200010a
+	const Sysshm_unlink	: scno = 0x200010b
+	const Syssem_open	: scno = 0x200010c
+	const Syssem_close	: scno = 0x200010d
+	const Syssem_unlink	: scno = 0x200010e
+	const Syssem_wait	: scno = 0x200010f
+	const Syssem_trywait	: scno = 0x2000110
+	const Syssem_post	: scno = 0x2000111
+	const Syssem_getvalue	: scno = 0x2000112
+	const Syssem_init	: scno = 0x2000113
+	const Syssem_destroy	: scno = 0x2000114
+	const Sysopen_extended	: scno = 0x2000115
+	const Sysumask_extended	: scno = 0x2000116
+	const Sysstat_extended	: scno = 0x2000117
+	const Syslstat_extended	: scno = 0x2000118
+	const Sysfstat_extended	: scno = 0x2000119
+	const Syschmod_extended	: scno = 0x200011a
+	const Sysfchmod_extended	: scno = 0x200011b
+	const Sysaccess_extended	: scno = 0x200011c
+	const Syssettid		: scno = 0x200011d
+	const Sysgettid		: scno = 0x200011e
+	const Syssetsgroups	: scno = 0x200011f
+	const Sysgetsgroups	: scno = 0x2000120
+	const Syssetwgroups	: scno = 0x2000121
+	const Sysgetwgroups	: scno = 0x2000122
+	const Sysmkfifo_extended	: scno = 0x2000123
+	const Sysmkdir_extended	: scno = 0x2000124
+	const Sysidentitysvc	: scno = 0x2000125
+	const Sysshared_region_check_np	: scno = 0x2000126
+	const Sysshared_region_map_np	: scno = 0x2000127
+	const Sysvm_pressure_monitor	: scno = 0x2000128
+	const Syspsynch_rw_longrdlock	: scno = 0x2000129
+	const Syspsynch_rw_yieldwrlock	: scno = 0x200012a
+	const Syspsynch_rw_downgrade	: scno = 0x200012b
+	const Syspsynch_rw_upgrade	: scno = 0x200012c
+	const Syspsynch_mutexwait	: scno = 0x200012d
+	const Syspsynch_mutexdrop	: scno = 0x200012e
+	const Syspsynch_cvbroad	: scno = 0x200012f
+	const Syspsynch_cvsignal	: scno = 0x2000130
+	const Syspsynch_cvwait	: scno = 0x2000131
+	const Syspsynch_rw_rdlock	: scno = 0x2000132
+	const Syspsynch_rw_wrlock	: scno = 0x2000133
+	const Syspsynch_rw_unlock	: scno = 0x2000134
+	const Syspsynch_rw_unlock2	: scno = 0x2000135
+	const Sysgetsid		: scno = 0x2000136
+	const Syssettid_with_pid	: scno = 0x2000137
+	const Sysaio_fsync	: scno = 0x2000139
+	const Sysaio_return	: scno = 0x200013a
+	const Sysaio_suspend	: scno = 0x200013b
+	const Sysaio_cancel	: scno = 0x200013c
+	const Sysaio_error	: scno = 0x200013d
+	const Sysaio_read	: scno = 0x200013e
+	const Sysaio_write	: scno = 0x200013f
+	const Syslio_listio	: scno = 0x2000140
+	const Sysiopolicysys	: scno = 0x2000142
+	const Sysmlockall	: scno = 0x2000144
+	const Sysmunlockall	: scno = 0x2000145
+	const Sysissetugid	: scno = 0x2000147
+	const Sys__pthread_kill	: scno = 0x2000148
+	const Sys__pthread_sigmask	: scno = 0x2000149
+	const Sys__sigwait	: scno = 0x200014a
+	const Sys__disable_threadsignal	: scno = 0x200014b
+	const Sys__pthread_markcancel	: scno = 0x200014c
+	const Sys__pthread_canceled	: scno = 0x200014d
+	const Sys__semwait_signal	: scno = 0x200014e
+	const Sysproc_info	: scno = 0x2000150
+	const Syssendfile	: scno = 0x2000151
+	const Sysstat64		: scno = 0x2000152
+	const Sysfstat64	: scno = 0x2000153
+	const Syslstat64	: scno = 0x2000154
+	const Sysstat64_extended	: scno = 0x2000155
+	const Syslstat64_extended	: scno = 0x2000156
+	const Sysfstat64_extended	: scno = 0x2000157
+	const Sysgetdirentries64	: scno = 0x2000158
+	const Sysstatfs64	: scno = 0x2000159
+	const Sysfstatfs64	: scno = 0x200015a
+	const Sysgetfsstat64	: scno = 0x200015b
+	const Sys__pthread_chdir	: scno = 0x200015c
+	const Sys__pthread_fchdir	: scno = 0x200015d
+	const Sysaudit		: scno = 0x200015e
+	const Sysauditon	: scno = 0x200015f
+	const Sysgetauid	: scno = 0x2000161
+	const Syssetauid	: scno = 0x2000162
+	const Sysgetaudit	: scno = 0x2000163
+	const Syssetaudit	: scno = 0x2000164
+	const Sysgetaudit_addr	: scno = 0x2000165
+	const Syssetaudit_addr	: scno = 0x2000166
+	const Sysauditctl	: scno = 0x2000167
+	const Sysbsdthread_create	: scno = 0x2000168
+	const Sysbsdthread_terminate	: scno = 0x2000169
+	const Syskqueue		: scno = 0x200016a
+	const Syskevent		: scno = 0x200016b
+	const Syslchown		: scno = 0x200016c
+	const Sysstack_snapshot	: scno = 0x200016d
+	const Sysbsdthread_register	: scno = 0x200016e
+	const Sysworkq_open	: scno = 0x200016f
+	const Sysworkq_kernreturn	: scno = 0x2000170
+	const Syskevent64	: scno = 0x2000171
+	const Sys__old_semwait_signal	: scno = 0x2000172
+	const Sys__old_semwait_signal_nocancel	: scno = 0x2000173
+	const Systhread_selfid	: scno = 0x2000174
+	const Sys__mac_execve	: scno = 0x200017c
+	const Sys__mac_syscall	: scno = 0x200017d
+	const Sys__mac_get_file	: scno = 0x200017e
+	const Sys__mac_set_file	: scno = 0x200017f
+	const Sys__mac_get_link	: scno = 0x2000180
+	const Sys__mac_set_link	: scno = 0x2000181
+	const Sys__mac_get_proc	: scno = 0x2000182
+	const Sys__mac_set_proc	: scno = 0x2000183
+	const Sys__mac_get_fd	: scno = 0x2000184
+	const Sys__mac_set_fd	: scno = 0x2000185
+	const Sys__mac_get_pid	: scno = 0x2000186
+	const Sys__mac_get_lcid	: scno = 0x2000187
+	const Sys__mac_get_lctx	: scno = 0x2000188
+	const Sys__mac_set_lctx	: scno = 0x2000189
+	const Syssetlcid	: scno = 0x200018a
+	const Sysgetlcid	: scno = 0x200018b
+	const Sysread_nocancel	: scno = 0x200018c
+	const Syswrite_nocancel	: scno = 0x200018d
+	const Sysopen_nocancel	: scno = 0x200018e
+	const Sysclose_nocancel	: scno = 0x200018f
+	const Syswait4_nocancel	: scno = 0x2000190
+	const Sysrecvmsg_nocancel	: scno = 0x2000191
+	const Syssendmsg_nocancel	: scno = 0x2000192
+	const Sysrecvfrom_nocancel	: scno = 0x2000193
+	const Sysaccept_nocancel	: scno = 0x2000194
+	const Sysmsync_nocancel		: scno = 0x2000195
+	const Sysfcntl_nocancel		: scno = 0x2000196
+	const Sysselect_nocancel	: scno = 0x2000197
+	const Sysfsync_nocancel		: scno = 0x2000198
+	const Sysconnect_nocancel	: scno = 0x2000199
+	const Syssigsuspend_nocancel	: scno = 0x200019a
+	const Sysreadv_nocancel		: scno = 0x200019b
+	const Syswritev_nocancel	: scno = 0x200019c
+	const Syssendto_nocancel	: scno = 0x200019d
+	const Syspread_nocancel		: scno = 0x200019e
+	const Syspwrite_nocancel	: scno = 0x200019f
+	const Syswaitid_nocancel	: scno = 0x20001a0
+	const Syspoll_nocancel		: scno = 0x20001a1
+	const Sysmsgsnd_nocancel	: scno = 0x20001a2
+	const Sysmsgrcv_nocancel	: scno = 0x20001a3
+	const Syssem_wait_nocancel	: scno = 0x20001a4
+	const Sysaio_suspend_nocancel	: scno = 0x20001a5
+	const Sys__sigwait_nocancel	: scno = 0x20001a6
+	const Sys__semwait_signal_nocancel	: scno = 0x20001a7
+	const Sys__mac_mount		: scno = 0x20001a8
+	const Sys__mac_get_mount	: scno = 0x20001a9
+	const Sys__mac_getfsstat	: scno = 0x20001aa
+	const Sysfsgetpath		: scno = 0x20001ab
+	const Sysaudit_session_self	: scno = 0x20001ac
+	const Sysaudit_session_join	: scno = 0x20001ad
+	const Syspid_suspend		: scno = 0x20001ae
+	const Syspid_resume		: scno = 0x20001af
+	const Sysfileport_makeport	: scno = 0x20001b0
+	const Sysfileport_makefd	: scno = 0x20001b1
+
+	extern const syscall : (sc:scno, args:... -> int64)
+
+	/* process control */
+	const exit	: (status:int -> void)
+	const getpid	: ( -> pid)
+	const kill	: (pid : pid, sig:int64 -> int64)
+	const fork	: (-> pid)
+	const wait4	: (pid : pid, loc:int32#, opt : int64, rusage:rusage#	-> int64)
+	const waitpid	: (pid : pid, loc:int32#, opt : int64	-> int64)
+	const execv	: (cmd : byte[:], args : byte[:][:] -> int64)
+	const execve	: (cmd : byte[:], args : byte[:][:], env : byte[:][:] -> int64)
+
+	/* file manipulation */
+	const open	: (path:byte[:], opts:fdopt -> fd)
+	const openmode	: (path:byte[:], opts:fdopt, mode:int64 -> fd)
+	const close	: (fd:fd -> int64)
+	const creat	: (path:byte[:], mode:int64 -> fd)
+	const unlink	: (path:byte[:] -> int)
+	const read	: (fd:fd, buf:byte[:] -> size)
+	const write	: (fd:fd, buf:byte[:] -> size)
+	const lseek	: (fd:fd, off:uint64, whence:int64 -> int64)
+	const stat	: (path:byte[:], sb:statbuf# -> int64)
+	const lstat	: (path:byte[:], sb:statbuf# -> int64)
+	const fstat	: (fd:fd, sb:statbuf# -> int64)
+	const mkdir	: (path : byte[:], mode : int64	-> int64)
+	const ioctl	: (fd:fd, req : int64, args:... -> int64)
+	const getdirentries64	: (fd : fd, buf : byte[:], basep : int64# -> int64)
+	const chdir	: (p : byte[:] -> int64)
+
+	/* fd stuff */
+	const pipe	: (fd : fd[:] -> int64)
+	const dup	: (fd : fd -> fd)
+	const dup2	: (src : fd, dst : fd -> fd)
+
+	/* kqueue */
+	const kqueue	: (-> fd)
+	const kevent	: (q : fd, cl : kevent[:], el : kevent[:], flg : kflags, timeout : timespec# -> int64)
+	const kevent64	: (q : fd, cl : kevent64[:], el : kevent64[:], flg : kflags, timeout : timespec# -> int64)
+
+
+
+	/* networking */
+	const socket	: (dom : sockfam, stype : socktype, proto : sockproto	-> fd)
+	const connect	: (sock	: fd, addr : sockaddr#, len : size -> int)
+	const accept	: (sock : fd, addr : sockaddr#, len : size# -> fd)
+	const listen	: (sock : fd, backlog : int	-> int)
+	const bind	: (sock : fd, addr : sockaddr#, len : size -> int)
+
+
+	/* memory mapping */
+	const munmap	: (addr:byte#, len:size -> int64)
+	const mmap	: (addr:byte#, len:size, prot:mprot, flags:mopt, fd:fd, off:off -> byte#)
+
+	/* time */
+	const gettimeofday	: (tv : timeval#, tz : timezone# -> int)
+	const settimeofday	: (tv : timeval#, tz : timezone# -> int)
+	/* faked with gettimeofday */
+	const clock_getres	: (clk : clock, ts : timespec# -> int)
+	const clock_gettime	: (clk : clock, ts : timespec# -> int)
+	const clock_settime	: (clk : clock, ts : timespec# -> int)
+
+	/* system information */
+	const uname 	: (buf : utsname# -> int)
+	const sysctl	: (mib : int[:], old : byte[:]#, new : byte[:] -> int)
+;;
+
+/*
+wraps a syscall argument, converting it to 64 bits for the syscall function. This is
+the same as casting, but more concise than writing castto(int64)
+*/
+generic a = {x : @t
+	-> x castto(uint64)
+}
+
+/* OSX has a number of funky syscalls */
+extern const __osx_fork	: (-> pid)
+extern const __osx_pipe : (fd : fd# -> int64)
+extern const __osx_getpid	: (-> pid)
+extern const __osx_lseek	: (fd:fd, off:uint64, whence:int64 -> int64)
+extern const __osx_gettimeofday	: (tv : timeval#, tz : timezone# -> int)
+/*
+extern const __osx_ptrace
+extern const __osx_signalstack
+extern const __osx_sigreturn
+extern const __osx_thread_selfid
+extern const __osx_vfork
+*/
+
+extern const cstring : (str : byte[:] -> byte#)
+extern const alloca : (sz : size -> byte#)
+extern const __cenvp : byte##
+
+/* process control */
+const exit	= {status;		syscall(Sysexit, a(status))}
+const getpid	= {;			-> syscall(Sysgetpid) castto(pid)}
+const kill	= {pid, sig;		-> syscall(Syskill, a(pid), a(sig))}
+const fork	= {;			-> __osx_fork()}
+const wait4	= {pid, loc, opt, rusage;	-> syscall(Syswait4, a(pid), a(loc), a(opt), a(rusage))}
+const waitpid	= {pid, loc, opt;
+	-> wait4(pid, loc, opt, 0 castto(rusage#))
+}
+
+const execv	= {cmd, args
+	var p, cargs, i
+
+	/* doesn't just call execve() for efficiency's sake. */
+	p = alloca((args.len + 1)*sizeof(byte#))
+	cargs = (p castto(byte##))[:args.len + 1]
+	for i = 0; i < args.len; i++
+		cargs[i] = cstring(args[i])
+	;;
+	cargs[args.len] = 0 castto(byte#)
+	-> syscall(Sysexecve, cstring(cmd), a(p), a(__cenvp))
+}
+
+const execve	= {cmd, args, env
+	var cargs, cenv, i
+	var p
+
+	/* copy the args */
+	p = alloca((args.len + 1)*sizeof(byte#))
+	cargs = (p castto(byte##))[:args.len + 1]
+	for i = 0; i < args.len; i++
+		cargs[i] = cstring(args[i])
+	;;
+	cargs[args.len] = 0 castto(byte#)
+
+	/*
+	 copy the env.
+	 of course we fucking have to duplicate this code everywhere,
+	 since we want to stack allocate...
+	*/
+	p = alloca((env.len + 1)*sizeof(byte#))
+	cenv = (p castto(byte##))[:env.len]
+	for i = 0; i < env.len; i++
+		cenv[i] = cstring(env[i])
+	;;
+	cenv[env.len] = 0 castto(byte#)
+
+	-> syscall(Sysexecve, cstring(cmd), a(p), a(cenv))
+}
+
+
+/* fd manipulation */
+const open	= {path, opts;		-> syscall(Sysopen, cstring(path), a(opts), a(0o777)) castto(fd)}
+const openmode	= {path, opts, mode;	-> syscall(Sysopen, cstring(path), a(opts), a(mode)) castto(fd)}
+const close	= {fd;			-> syscall(Sysclose, a(fd))}
+const creat	= {path, mode;		-> openmode(path, Ocreat | Otrunc | Owronly, mode) castto(fd)}
+const unlink	= {path;		-> syscall(Sysunlink, cstring(path)) castto(int)}
+const read	= {fd, buf;		-> syscall(Sysread, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
+const write	= {fd, buf;		-> syscall(Syswrite, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
+const lseek	= {fd, off, whence;	-> syscall(Syslseek, a(fd), a(off), a(whence))}
+const stat	= {path, sb;		-> syscall(Sysstat64, cstring(path), a(sb))}
+const lstat	= {path, sb;		-> syscall(Syslstat64, cstring(path), a(sb))}
+const fstat	= {fd, sb;		-> syscall(Sysfstat64, a(fd), a(sb))}
+const mkdir	= {path, mode;		-> syscall(Sysmkdir, cstring(path), a(mode)) castto(int64)}
+const ioctl	= {fd, req, args
+	var arg : byte#
+	var ap
+
+	ap = vastart(&args)
+	(arg, ap) = vanext(ap)
+	-> syscall(Sysioctl, a(fd), a(req), a(arg)) castto(int64)
+}
+const getdirentries64	= {fd, buf, basep;	-> syscall(Sysgetdirentries64, a(fd), buf castto(byte#), a(buf.len), a(basep))}
+const chdir	= {dir;	-> syscall(Syschdir, dir)}
+
+/* fd stuff */
+const pipe	= {fd;	-> __osx_pipe(fd castto(fd#))}
+const dup 	= {fd;	-> syscall(Sysdup, a(fd)) castto(fd)}
+const dup2 	= {src, dst;	-> syscall(Sysdup2, a(src), a(dst)) castto(fd)}
+
+/* kqueueueueueueue */
+const kqueue	= {;	-> syscall(Syskqueue) castto(fd)}
+const kevent	= {q, cl, el, flg, timeout
+	-> syscall(Syskevent, a(q), \
+		cl castto(kevent#), a(cl.len), \
+		el castto(kevent#), a(el.len), \
+		a(flg), \
+		timeout)
+}
+
+const kevent64	= {q, cl, el, flg, timeout
+	-> syscall(Syskevent, a(q), \
+		cl castto(kevent#), a(cl.len), \
+		el castto(kevent#), a(el.len), \
+		a(flg), \
+		timeout)
+}
+
+/* networking */
+const socket	= {dom, stype, proto;	-> syscall(Syssocket, a(dom), a(stype), a(proto)) castto(fd) }
+const connect	= {sock, addr, len;	-> syscall(Sysconnect, a(sock), a(addr), a(len)) castto(int)}
+const accept	= {sock, addr, len;	-> syscall(Sysaccept, a(sock), a(addr), a(len)) castto(fd)}
+const listen	= {sock, backlog;	-> syscall(Syslisten, a(sock), a(backlog)) castto(int)}
+const bind	= {sock, addr, len;	-> syscall(Sysbind, a(sock), a(addr), a(len)) castto(int)}
+
+/* memory management */
+const munmap	= {addr, len;		-> syscall(Sysmunmap, a(addr), a(len))}
+const mmap	= {addr, len, prot, flags, fd, off;
+	-> syscall(Sysmmap, a(addr), a(len), a(prot), a(flags), a(fd), a(off)) castto(byte#)}
+
+/* time */
+const gettimeofday = {tv, tz;	-> __osx_gettimeofday(tv, tz) castto(int)}
+const settimeofday = {tv, tz;	-> syscall(Syssettimeofday, a(tv), a(tz)) castto(int)}
+
+/* faked  with gettimeofday */
+const clock_getres = {clk, ts
+	ts.sec = 0
+	ts.nsec = 1000*10 /* 10ms is reasonable resolution */
+	-> 0
+}
+
+const clock_gettime = {clk, ts
+	var tv
+	var ret
+
+	ret = gettimeofday(&tv, 0 castto(timezone#))
+	ts.sec = tv.sec
+	ts.nsec = tv.usec * 1000
+	-> ret
+}
+
+const clock_settime = {clk, ts
+	var tv
+
+	tv.sec = ts.sec
+	tv.usec = ts.nsec / 1000
+	-> settimeofday(&tv, 0 castto(timezone#))
+}
+
+/* system information */
+const uname	= {buf;
+	var mib : int[2]
+	var ret
+	var sys
+	var nod
+	var rel
+	var ver
+	var mach
+
+	ret = 0
+	mib[0] = 1 /* CTL_KERN */
+	mib[1] = 1 /* KERN_OSTYPE */
+	sys = buf.system[:]
+	ret = sysctl(mib[:], &sys, [][:])
+	if ret < 0
+		-> ret
+	;;
+
+	mib[0] = 1 /* CTL_KERN */
+	mib[1] = 10 /* KERN_HOSTNAME */
+	nod = buf.node[:]
+	ret = sysctl(mib[:], &nod, [][:])
+	if ret < 0
+		-> ret
+	;;
+
+	mib[0] = 1 /* CTL_KERN */
+	mib[1] = 2 /* KERN_OSRELEASE */
+	rel = buf.release[:]
+	ret = sysctl(mib[:], &rel, [][:])
+	if ret < 0
+		-> ret
+	;;
+
+	mib[0] = 1 /* CTL_KERN */
+	mib[1] = 4 /* KERN_VERSION */
+	ver = buf.version[:]
+	ret = sysctl(mib[:], &ver, [][:])
+	if ret < 0
+		-> ret
+	;;
+
+	mib[0] = 6 /* CTL_HW */
+	mib[1] = 1 /* HW_MACHINE */
+	mach = buf.machine[:]
+	ret = sysctl(mib[:], &mach, [][:])
+	if ret < 0
+		-> ret
+	;;
+
+	-> 0
+}
+
+const sysctl = {mib, old, new
+	var mibp
+	var mibsz
+	var o
+	var oldp
+	var oldsz
+	var newp
+	var newsz
+	var ret
+
+	mibp = mib castto(byte#)
+	mibsz = mib.len castto(uint64)
+	o = old#
+	oldp = o castto(byte#)
+	oldsz = (o.len castto(uint64))
+	if new.len > 0
+		newp = new castto(byte#)
+		newsz = new.len castto(uint64)
+	else
+		newp = 0 castto(byte#)
+		newsz = 0
+	;;
+
+	ret = syscall(Sys__sysctl, a(mibp), a(mibsz), a(oldp), a(&oldsz), a(newp), a(newsz)) castto(int)
+
+	old# = o[:oldsz]
+	-> ret
+}
--- a/libstd/sys-freebsd.myr
+++ /dev/null
@@ -1,795 +1,0 @@
-use "types.use"
-use "varargs.use"
-
-pkg std =
-	type scno	= int64 /*syscall*/
-	type fdopt	= int64	/* fd options */
-	type fd		= int64	/* fd */
-	type mprot	= int64	/* memory protection */
-	type mopt	= int64	/* memory mapping options */
-	type socktype	= int64	/* socket type */
-	type sockproto	= int64	/* socket protocol */
-	type sockfam	= uint8	/* socket family */
-	type filemode	= uint16
-	type filetype	= uint8
-
-	type clock = union
-		`Clockrealtime
-		`Clockrealtime_precise
-		`Clockrealtime_fast
-		`Clockmonotonic
-		`Clockmonotonic_precise     
-		`Clockmonotonic_fast
-		`Clockuptime
-		`Clockuptime_precise
-		`Clockuptime_fast
-		`Clockvirtual
-		`Clockprof
-		`Clocksecond
-	;;
-
-	type timespec = struct
-		sec	: uint64
-		nsec	: uint64 
-	;;
-
-	type timeval = struct
-		sec	: uint64
-		usec	: uint64
-	;;
-
-	type rusage = struct
-		utime	: timeval /* user time */
-		stime	: timeval /* system time */
-		maxrss	: uint64 /* max resident set size*/
-		ixrss	: uint64 /* shared text size */
-		idrss	: uint64 /* unshared data size */
-		isrss	: uint64 /* unshared stack size */
-		minflt	: uint64 /* page reclaims */
-		majflt	: uint64 /* page faults */
-		nswap	: uint64 /* swaps */
-		inblock	: uint64 /* block input ops */
-		oublock	: uint64 /* block output ops */
-		msgsnd	: uint64 /* messages sent */	
-		msgrcv	: uint64 /* messages received */
-		nsignals : uint64 /* signals received */
-		nvcsw	: uint64 /* voluntary context switches */
-		nivcsw	: uint64 /* involuntary context switches */
-	;;
-
-	type statbuf = struct
-		dev	: uint32 
-		ino	: uint32 
-		mode	: filemode
-		nlink	: uint16
-		uid	: uint32
-		gid	: uint32
-		rdev	: uint32
-		atim	: timespec
-		mtim	: timespec
-		ctim	: timespec
-		size	: int64
-		blocks	: int64
-		blksize	: uint32
-		flags	: uint32
-		gen	: uint32
-		lspare	: int32
-		birthtim	: timespec 
-	;;
-
-	type utsname = struct
-		system	: byte[256]
-		node : byte[256] 
-		release : byte[256]
-		version : byte[256]
-		machine : byte[256]
-	;;
-
-	type sockaddr = struct
-		len	: byte
-		fam	: sockfam
-		data	: byte[14] /* what is the *actual* length? */
-	;;
-
-	type sockaddr_in = struct
-		len	: byte
-		fam	: sockfam
-		port	: uint16
-		addr	: byte[4]
-		zero	: byte[8]
-	;;
-
-	type sockaddr_storage = struct
-		len	: byte
-		fam	: sockfam
-		__pad1  : byte[6]
-		__align : int64
-		__pad2  : byte[112]
-	;;	
-	
-	type dirent = struct
-		fileno	: uint32
-		reclen	: uint16
-		ftype	: filetype
-		namelen	: uint8
-		name	: byte[256]	
-	;;	
-
-	/* open options */
-	const Ordonly  	: fdopt = 0x0
-	const Owronly  	: fdopt = 0x1
-	const Ordwr    	: fdopt = 0x2
-	const Oappend  	: fdopt = 0x8
-	const Ocreat   	: fdopt = 0x200
-	const Onofollow	: fdopt = 0x100
-	const Ondelay  	: fdopt = 0x4
-	const Otrunc   	: fdopt = 0x400
-	const Odir	: fdopt = 0x20000
-
-        /* stat modes */	
-	const Sifmt	: filemode = 0xf000
-	const Sififo	: filemode = 0x1000
-	const Sifchr	: filemode = 0x2000
-	const Sifdir	: filemode = 0x4000
-	const Sifblk	: filemode = 0x6000
-	const Sifreg	: filemode = 0x8000
-	const Siflnk	: filemode = 0xa000
-	const Sifsock 	: filemode = 0xc000
-
-	/* mmap protection */
-	const Mprotnone	: mprot = 0x0
-	const Mprotrd	: mprot = 0x1
-	const Mprotwr	: mprot = 0x2
-	const Mprotexec	: mprot = 0x4
-	const Mprotrw	: mprot = 0x3
-
-	/* mmap options */
-	const Mshared	: mopt = 0x1
-	const Mpriv	: mopt = 0x2
-	const Mfixed	: mopt = 0x10
-	const Mfile	: mopt = 0x0
-	const Manon	: mopt = 0x1000
-	const M32bit	: mopt = 0x80000
-
-	/* file types */
-	const Dtunknown	: filetype = 0
-	const Dtfifo	: filetype = 1
-	const Dtchr	: filetype = 2
-	const Dtdir	: filetype = 4
-	const Dtblk	: filetype = 6
-	const Dtreg	: filetype = 8
-	const Dtlnk	: filetype = 10
-	const Dtsock	: filetype = 12
-	const Dtwht	: filetype = 14
-
-	/* socket families. INCOMPLETE. */
-	const Afunspec	: sockfam = 0
-	const Afunix	: sockfam = 1
-	const Afinet	: sockfam = 2
-	const Afinet6	: sockfam = 28
-
-	/* socket types. */
-	const Sockstream	: socktype = 1
-	const Sockdgram		: socktype = 2
-	const Sockraw		: socktype = 3
-	const Sockrdm		: socktype = 4
-	const Sockseqpacket	: socktype = 5
-
-	/* network protocols */
-	const Ipproto_ip	: sockproto = 0
-	const Ipproto_icmp	: sockproto = 1
-	const Ipproto_tcp	: sockproto = 6
-	const Ipproto_udp	: sockproto = 17
-	const Ipproto_raw	: sockproto = 255
-
-	/* return value for a failed mapping */
-	const Mapbad	: byte# = -1 castto(byte#)
-
-	/* syscalls */
-	const Syssyscall                   : scno = 0
-	const Sysexit                      : scno = 1
-	const Sysfork                      : scno = 2
-	const Sysread                      : scno = 3
-	const Syswrite                     : scno = 4
-	const Sysopen                      : scno = 5
-	const Sysclose                     : scno = 6
-	const Syswait4                     : scno = 7
-	const Syslink                      : scno = 9
-	const Sysunlink                    : scno = 10
-	const Syschdir                     : scno = 12
-	const Sysfchdir                    : scno = 13
-	const Sysmknod                     : scno = 14
-	const Syschmod                     : scno = 15
-	const Syschown                     : scno = 16
-	const Sysbreak                     : scno = 17
-	const Sysfreebsd4_getfsstat        : scno = 18
-	const Sysgetpid                    : scno = 20
-	const Sysmount                     : scno = 21
-	const Sysunmount                   : scno = 22
-	const Syssetuid                    : scno = 23
-	const Sysgetuid                    : scno = 24
-	const Sysgeteuid                   : scno = 25
-	const Sysptrace                    : scno = 26
-	const Sysrecvmsg                   : scno = 27
-	const Syssendmsg                   : scno = 28
-	const Sysrecvfrom                  : scno = 29
-	const Sysaccept                    : scno = 30
-	const Sysgetpeername               : scno = 31
-	const Sysgetsockname               : scno = 32
-	const Sysaccess                    : scno = 33
-	const Syschflags                   : scno = 34
-	const Sysfchflags                  : scno = 35
-	const Syssync                      : scno = 36
-	const Syskill                      : scno = 37
-	const Sysgetppid                   : scno = 39
-	const Sysdup                       : scno = 41
-	const Syspipe                      : scno = 42
-	const Sysgetegid                   : scno = 43
-	const Sysprofil                    : scno = 44
-	const Sysktrace                    : scno = 45
-	const Sysgetgid                    : scno = 47
-	const Sysgetlogin                  : scno = 49
-	const Syssetlogin                  : scno = 50
-	const Sysacct                      : scno = 51
-	const Syssigaltstack               : scno = 53
-	const Sysioctl                     : scno = 54
-	const Sysreboot                    : scno = 55
-	const Sysrevoke                    : scno = 56
-	const Syssymlink                   : scno = 57
-	const Sysreadlink                  : scno = 58
-	const Sysexecve                    : scno = 59
-	const Sysumask                     : scno = 60
-	const Syschroot                    : scno = 61
-	const Sysmsync                     : scno = 65
-	const Sysvfork                     : scno = 66
-	const Syssbrk                      : scno = 69
-	const Syssstk                      : scno = 70
-	const Sysvadvise                   : scno = 72
-	const Sysmunmap                    : scno = 73
-	const Sysmprotect                  : scno = 74
-	const Sysmadvise                   : scno = 75
-	const Sysmincore                   : scno = 78
-	const Sysgetgroups                 : scno = 79
-	const Syssetgroups                 : scno = 80
-	const Sysgetpgrp                   : scno = 81
-	const Syssetpgid                   : scno = 82
-	const Syssetitimer                 : scno = 83
-	const Sysswapon                    : scno = 85
-	const Sysgetitimer                 : scno = 86
-	const Sysgetdtablesize             : scno = 89
-	const Sysdup2                      : scno = 90
-	const Sysfcntl                     : scno = 92
-	const Sysselect                    : scno = 93
-	const Sysfsync                     : scno = 95
-	const Syssetpriority               : scno = 96
-	const Syssocket                    : scno = 97
-	const Sysconnect                   : scno = 98
-	const Sysgetpriority               : scno = 100
-	const Sysbind                      : scno = 104
-	const Syssetsockopt                : scno = 105
-	const Syslisten                    : scno = 106
-	const Sysgettimeofday              : scno = 116
-	const Sysgetrusage                 : scno = 117
-	const Sysgetsockopt                : scno = 118
-	const Sysreadv                     : scno = 120
-	const Syswritev                    : scno = 121
-	const Syssettimeofday              : scno = 122
-	const Sysfchown                    : scno = 123
-	const Sysfchmod                    : scno = 124
-	const Syssetreuid                  : scno = 126
-	const Syssetregid                  : scno = 127
-	const Sysrename                    : scno = 128
-	const Sysflock                     : scno = 131
-	const Sysmkfifo                    : scno = 132
-	const Syssendto                    : scno = 133
-	const Sysshutdown                  : scno = 134
-	const Syssocketpair                : scno = 135
-	const Sysmkdir                     : scno = 136
-	const Sysrmdir                     : scno = 137
-	const Sysutimes                    : scno = 138
-	const Sysadjtime                   : scno = 140
-	const Syssetsid                    : scno = 147
-	const Sysquotactl                  : scno = 148
-	const Sysnlm_syscall               : scno = 154
-	const Sysnfssvc                    : scno = 155
-	const Sysfreebsd4_statfs           : scno = 157
-	const Sysfreebsd4_fstatfs          : scno = 158
-	const Syslgetfh                    : scno = 160
-	const Sysgetfh                     : scno = 161
-	const Sysfreebsd4_getdomainname    : scno = 162
-	const Sysfreebsd4_setdomainname    : scno = 163
-	const Sysfreebsd4_uname            : scno = 164
-	const Syssysarch                   : scno = 165
-	const Sysrtprio                    : scno = 166
-	const Syssemsys                    : scno = 169
-	const Sysmsgsys                    : scno = 170
-	const Sysshmsys                    : scno = 171
-	const Sysfreebsd6_pread            : scno = 173
-	const Sysfreebsd6_pwrite           : scno = 174
-	const Syssetfib                    : scno = 175
-	const Sysntp_adjtime               : scno = 176
-	const Syssetgid                    : scno = 181
-	const Syssetegid                   : scno = 182
-	const Sysseteuid                   : scno = 183
-	const Sysstat                      : scno = 188
-	const Sysfstat                     : scno = 189
-	const Syslstat                     : scno = 190
-	const Syspathconf                  : scno = 191
-	const Sysfpathconf                 : scno = 192
-	const Sysgetrlimit                 : scno = 194
-	const Syssetrlimit                 : scno = 195
-	const Sysgetdirentries             : scno = 196
-	const Sysfreebsd6_mmap             : scno = 197
-	const Sys__syscall                 : scno = 198
-	const Sysfreebsd6_lseek            : scno = 199
-	const Sysfreebsd6_truncate         : scno = 200
-	const Sysfreebsd6_ftruncate        : scno = 201
-	const Sys__sysctl                  : scno = 202
-	const Sysmlock                     : scno = 203
-	const Sysmunlock                   : scno = 204
-	const Sysundelete                  : scno = 205
-	const Sysfutimes                   : scno = 206
-	const Sysgetpgid                   : scno = 207
-	const Syspoll                      : scno = 209
-	const Sysfreebsd7___semctl         : scno = 220
-	const Syssemget                    : scno = 221
-	const Syssemop                     : scno = 222
-	const Sysfreebsd7_msgctl           : scno = 224
-	const Sysmsgget                    : scno = 225
-	const Sysmsgsnd                    : scno = 226
-	const Sysmsgrcv                    : scno = 227
-	const Sysshmat                     : scno = 228
-	const Sysfreebsd7_shmctl           : scno = 229
-	const Sysshmdt                     : scno = 230
-	const Sysshmget                    : scno = 231
-	const Sysclock_gettime             : scno = 232
-	const Sysclock_settime             : scno = 233
-	const Sysclock_getres              : scno = 234
-	const Sysktimer_create             : scno = 235
-	const Sysktimer_delete             : scno = 236
-	const Sysktimer_settime            : scno = 237
-	const Sysktimer_gettime            : scno = 238
-	const Sysktimer_getoverrun         : scno = 239
-	const Sysnanosleep                 : scno = 240
-	const Sysffclock_getcounter        : scno = 241
-	const Sysffclock_setestimate       : scno = 242
-	const Sysffclock_getestimate       : scno = 243
-	const Sysclock_getcpuclockid2      : scno = 247
-	const Sysntp_gettime               : scno = 248
-	const Sysminherit                  : scno = 250
-	const Sysrfork                     : scno = 251
-	const Sysopenbsd_poll              : scno = 252
-	const Sysissetugid                 : scno = 253
-	const Syslchown                    : scno = 254
-	const Sysaio_read                  : scno = 255
-	const Sysaio_write                 : scno = 256
-	const Syslio_listio                : scno = 257
-	const Sysgetdents                  : scno = 272
-	const Syslchmod                    : scno = 274
-	const Sysnetbsd_lchown             : scno = 275
-	const Syslutimes                   : scno = 276
-	const Sysnetbsd_msync              : scno = 277
-	const Sysnstat                     : scno = 278
-	const Sysnfstat                    : scno = 279
-	const Sysnlstat                    : scno = 280
-	const Syspreadv                    : scno = 289
-	const Syspwritev                   : scno = 290
-	const Sysfreebsd4_fhstatfs         : scno = 297
-	const Sysfhopen                    : scno = 298
-	const Sysfhstat                    : scno = 299
-	const Sysmodnext                   : scno = 300
-	const Sysmodstat                   : scno = 301
-	const Sysmodfnext                  : scno = 302
-	const Sysmodfind                   : scno = 303
-	const Syskldload                   : scno = 304
-	const Syskldunload                 : scno = 305
-	const Syskldfind                   : scno = 306
-	const Syskldnext                   : scno = 307
-	const Syskldstat                   : scno = 308
-	const Syskldfirstmod               : scno = 309
-	const Sysgetsid                    : scno = 310
-	const Syssetresuid                 : scno = 311
-	const Syssetresgid                 : scno = 312
-	const Sysaio_return                : scno = 314
-	const Sysaio_suspend               : scno = 315
-	const Sysaio_cancel                : scno = 316
-	const Sysaio_error                 : scno = 317
-	const Sysoaio_read                 : scno = 318
-	const Sysoaio_write                : scno = 319
-	const Sysolio_listio               : scno = 320
-	const Sysyield                     : scno = 321
-	const Sysmlockall                  : scno = 324
-	const Sysmunlockall                : scno = 325
-	const Sys__getcwd                  : scno = 326
-	const Syssched_setparam            : scno = 327
-	const Syssched_getparam            : scno = 328
-	const Syssched_setscheduler        : scno = 329
-	const Syssched_getscheduler        : scno = 330
-	const Syssched_yield               : scno = 331
-	const Syssched_get_priority_max    : scno = 332
-	const Syssched_get_priority_min    : scno = 333
-	const Syssched_rr_get_interval     : scno = 334
-	const Sysutrace                    : scno = 335
-	const Sysfreebsd4_sendfile         : scno = 336
-	const Syskldsym                    : scno = 337
-	const Sysjail                      : scno = 338
-	const Sysnnpfs_syscall             : scno = 339
-	const Syssigprocmask               : scno = 340
-	const Syssigsuspend                : scno = 341
-	const Sysfreebsd4_sigaction        : scno = 342
-	const Syssigpending                : scno = 343
-	const Sysfreebsd4_sigreturn        : scno = 344
-	const Syssigtimedwait              : scno = 345
-	const Syssigwaitinfo               : scno = 346
-	const Sys__acl_get_file            : scno = 347
-	const Sys__acl_set_file            : scno = 348
-	const Sys__acl_get_fd              : scno = 349
-	const Sys__acl_set_fd              : scno = 350
-	const Sys__acl_delete_file         : scno = 351
-	const Sys__acl_delete_fd           : scno = 352
-	const Sys__acl_aclcheck_file       : scno = 353
-	const Sys__acl_aclcheck_fd         : scno = 354
-	const Sysextattrctl                : scno = 355
-	const Sysextattr_set_file          : scno = 356
-	const Sysextattr_get_file          : scno = 357
-	const Sysextattr_delete_file       : scno = 358
-	const Sysaio_waitcomplete          : scno = 359
-	const Sysgetresuid                 : scno = 360
-	const Sysgetresgid                 : scno = 361
-	const Syskqueue                    : scno = 362
-	const Syskevent                    : scno = 363
-	const Sysextattr_set_fd            : scno = 371
-	const Sysextattr_get_fd            : scno = 372
-	const Sysextattr_delete_fd         : scno = 373
-	const Sys__setugid                 : scno = 374
-	const Syseaccess                   : scno = 376
-	const Sysafs3_syscall              : scno = 377
-	const Sysnmount                    : scno = 378
-	const Sys__mac_get_proc            : scno = 384
-	const Sys__mac_set_proc            : scno = 385
-	const Sys__mac_get_fd              : scno = 386
-	const Sys__mac_get_file            : scno = 387
-	const Sys__mac_set_fd              : scno = 388
-	const Sys__mac_set_file            : scno = 389
-	const Syskenv                      : scno = 390
-	const Syslchflags                  : scno = 391
-	const Sysuuidgen                   : scno = 392
-	const Syssendfile                  : scno = 393
-	const Sysmac_syscall               : scno = 394
-	const Sysgetfsstat                 : scno = 395
-	const Sysstatfs                    : scno = 396
-	const Sysfstatfs                   : scno = 397
-	const Sysfhstatfs                  : scno = 398
-	const Sysksem_close                : scno = 400
-	const Sysksem_post                 : scno = 401
-	const Sysksem_wait                 : scno = 402
-	const Sysksem_trywait              : scno = 403
-	const Sysksem_init                 : scno = 404
-	const Sysksem_open                 : scno = 405
-	const Sysksem_unlink               : scno = 406
-	const Sysksem_getvalue             : scno = 407
-	const Sysksem_destroy              : scno = 408
-	const Sys__mac_get_pid             : scno = 409
-	const Sys__mac_get_link            : scno = 410
-	const Sys__mac_set_link            : scno = 411
-	const Sysextattr_set_link          : scno = 412
-	const Sysextattr_get_link          : scno = 413
-	const Sysextattr_delete_link       : scno = 414
-	const Sys__mac_execve              : scno = 415
-	const Syssigaction                 : scno = 416
-	const Syssigreturn                 : scno = 417
-	const Sysgetcontext                : scno = 421
-	const Syssetcontext                : scno = 422
-	const Sysswapcontext               : scno = 423
-	const Sysswapoff                   : scno = 424
-	const Sys__acl_get_link            : scno = 425
-	const Sys__acl_set_link            : scno = 426
-	const Sys__acl_delete_link         : scno = 427
-	const Sys__acl_aclcheck_link       : scno = 428
-	const Syssigwait                   : scno = 429
-	const Systhr_create                : scno = 430
-	const Systhr_exit                  : scno = 431
-	const Systhr_self                  : scno = 432
-	const Systhr_kill                  : scno = 433
-	const Sys_umtx_lock                : scno = 434
-	const Sys_umtx_unlock              : scno = 435
-	const Sysjail_attach               : scno = 436
-	const Sysextattr_list_fd           : scno = 437
-	const Sysextattr_list_file         : scno = 438
-	const Sysextattr_list_link         : scno = 439
-	const Sysksem_timedwait            : scno = 441
-	const Systhr_suspend               : scno = 442
-	const Systhr_wake                  : scno = 443
-	const Syskldunloadf                : scno = 444
-	const Sysaudit                     : scno = 445
-	const Sysauditon                   : scno = 446
-	const Sysgetauid                   : scno = 447
-	const Syssetauid                   : scno = 448
-	const Sysgetaudit                  : scno = 449
-	const Syssetaudit                  : scno = 450
-	const Sysgetaudit_addr             : scno = 451
-	const Syssetaudit_addr             : scno = 452
-	const Sysauditctl                  : scno = 453
-	const Sys_umtx_op                  : scno = 454
-	const Systhr_new                   : scno = 455
-	const Syssigqueue                  : scno = 456
-	const Syskmq_open                  : scno = 457
-	const Syskmq_setattr               : scno = 458
-	const Syskmq_timedreceive          : scno = 459
-	const Syskmq_timedsend             : scno = 460
-	const Syskmq_notify                : scno = 461
-	const Syskmq_unlink                : scno = 462
-	const Sysabort2                    : scno = 463
-	const Systhr_set_name              : scno = 464
-	const Sysaio_fsync                 : scno = 465
-	const Sysrtprio_thread             : scno = 466
-	const Syssctp_peeloff              : scno = 471
-	const Syssctp_generic_sendmsg      : scno = 472
-	const Syssctp_generic_sendmsg_iov  : scno = 473
-	const Syssctp_generic_recvmsg      : scno = 474
-	const Syspread                     : scno = 475
-	const Syspwrite                    : scno = 476
-	const Sysmmap                      : scno = 477
-	const Syslseek                     : scno = 478
-	const Systruncate                  : scno = 479
-	const Sysftruncate                 : scno = 480
-	const Systhr_kill2                 : scno = 481
-	const Sysshm_open                  : scno = 482
-	const Sysshm_unlink                : scno = 483
-	const Syscpuset                    : scno = 484
-	const Syscpuset_setid              : scno = 485
-	const Syscpuset_getid              : scno = 486
-	const Syscpuset_getaffinity        : scno = 487
-	const Syscpuset_setaffinity        : scno = 488
-	const Sysfaccessat                 : scno = 489
-	const Sysfchmodat                  : scno = 490
-	const Sysfchownat                  : scno = 491
-	const Sysfexecve                   : scno = 492
-	const Sysfstatat                   : scno = 493
-	const Sysfutimesat                 : scno = 494
-	const Syslinkat                    : scno = 495
-	const Sysmkdirat                   : scno = 496
-	const Sysmkfifoat                  : scno = 497
-	const Sysmknodat                   : scno = 498
-	const Sysopenat                    : scno = 499
-	const Sysreadlinkat                : scno = 500
-	const Sysrenameat                  : scno = 501
-	const Syssymlinkat                 : scno = 502
-	const Sysunlinkat                  : scno = 503
-	const Sysposix_openpt              : scno = 504
-	const Sysgssd_syscall              : scno = 505
-	const Sysjail_get                  : scno = 506
-	const Sysjail_set                  : scno = 507
-	const Sysjail_remove               : scno = 508
-	const Sysclosefrom                 : scno = 509
-	const Sys__semctl                  : scno = 510
-	const Sysmsgctl                    : scno = 511
-	const Sysshmctl                    : scno = 512
-	const Syslpathconf                 : scno = 513
-	const Sys__cap_rights_get          : scno = 515
-	const Syscap_enter                 : scno = 516
-	const Syscap_getmode               : scno = 517
-	const Syspdfork                    : scno = 518
-	const Syspdkill                    : scno = 519
-	const Syspdgetpid                  : scno = 520
-	const Syspselect                   : scno = 522
-	const Sysgetloginclass             : scno = 523
-	const Syssetloginclass             : scno = 524
-	const Sysrctl_get_racct            : scno = 525
-	const Sysrctl_get_rules            : scno = 526
-	const Sysrctl_get_limits           : scno = 527
-	const Sysrctl_add_rule             : scno = 528
-	const Sysrctl_remove_rule          : scno = 529
-	const Sysposix_fallocate           : scno = 530
-	const Sysposix_fadvise             : scno = 531
-	const Syswait6                     : scno = 532
-	const Syscap_rights_limit          : scno = 533
-	const Syscap_ioctls_limit          : scno = 534
-	const Syscap_ioctls_get            : scno = 535
-	const Syscap_fcntls_limit          : scno = 536
-	const Syscap_fcntls_get            : scno = 537
-	const Sysbindat                    : scno = 538
-	const Sysconnectat                 : scno = 539
-	const Syschflagsat                 : scno = 540
-	const Sysaccept4                   : scno = 541
-	const Syspipe2                     : scno = 542
-	const Sysaio_mlock                 : scno = 543
-	const Sysprocctl                   : scno = 544
-
-	extern const syscall : (sc:scno, args:... -> int64)
-
-	/* process control */
-	const exit	: (status:int -> void)
-	const getpid	: ( -> int64)
-	const kill	: (pid:int64, sig:int64 -> int64)
-	const fork	: (-> int64)
-	const wait4	: (pid:int64, loc:int32#, opt : int64, usage:rusage#	-> int64)
-	const waitpid	: (pid:int64, loc:int32#, opt : int64	-> int64)
-	const execv	: (cmd : byte[:], args : byte[:][:] -> int64)
-	const execve	: (cmd : byte[:], args : byte[:][:], env : byte[:][:] -> int64)
-
-	/* fd manipulation */
-	const open	: (path:byte[:], opts:fdopt -> fd)
-	const openmode	: (path:byte[:], opts:fdopt, mode:int64 -> fd)
-	const close	: (fd:fd -> int64)
-	const creat	: (path:byte[:], mode:int64 -> fd)
-	const read	: (fd:fd, buf:byte[:] -> size)
-	const write	: (fd:fd, buf:byte[:] -> size)
-	const lseek	: (fd:fd, off:uint64, whence:int64 -> int64)
-	const stat	: (path:byte[:], sb:statbuf# -> int64)
-	const lstat	: (path:byte[:], sb:statbuf# -> int64)
-	const fstat	: (fd:fd, sb:statbuf# -> int64)
-	const mkdir	: (path : byte[:], mode : int64	-> int64)
-	const ioctl	: (fd:fd, req : int64, args:... -> int64)
-	const getdirentries64	: (fd : fd, buf : byte[:], basep : uint64# -> int64)
-
-	/* networking */
-	const socket	: (dom : sockfam, stype : socktype, proto : sockproto	-> fd)
-	const connect	: (sock	: fd, addr : sockaddr#, len : size -> int)
-	const accept	: (sock : fd, addr : sockaddr#, len : size# -> fd)
-	const listen	: (sock : fd, backlog : int	-> int)
-	const bind	: (sock : fd, addr : sockaddr#, len : size -> int)
-
-	/* memory mapping */
-	const munmap	: (addr:byte#, len:size -> int64)
-	const mmap	: (addr:byte#, len:size, prot:mprot, flags:mopt, fd:fd, off:off -> byte#)
-
-	/* time - doublecheck if this is right */
-	const clock_getres	: (clk : clock, ts : timespec# -> int32)
-	const clock_gettime	: (clk : clock, ts : timespec# -> int32)
-	const clock_settime	: (clk : clock, ts : timespec# -> int32)
-	const sleep	: (time : uint64 -> int32)
-	const nanosleep	: (req : timespec#, rem : timespec# -> int32)
-
-	/* system information */
-	const uname 	: (buf : utsname# -> int)
-	const sysctl	: (mib : int[:], old : byte[:]#, new : byte[:] -> int)
-;;
-
-/* 
-wraps a syscall argument, converting it to 64 bits for the syscall function. This is
-the same as casting, but more concise than writing castto(int64)
-*/
-generic a = {x : @t
-	-> a(x)
-}
-
-extern const cstring	: (str : byte[:] -> byte#)
-extern const alloca	: (sz : size	-> byte#)
-extern const __cenvp : byte##
-
-/* process management */
-const exit	= {status;		syscall(Sysexit, a(status))}
-const getpid	= {;			-> syscall(Sysgetpid, 1)}
-const kill	= {pid, sig;		-> syscall(Syskill, pid, sig)}
-const fork	= {;			-> syscall(Sysfork)}
-const wait4	= {pid, loc, opt, usage;	-> syscall(Syswait4, pid, loc, opt, usage)}
-const waitpid	= {pid, loc, opt;
-	-> wait4(pid, loc, opt, 0 castto(rusage#)) 
-}
-
-const execv	= {cmd, args
-	var p, cargs, i
-
-	/* of course we fucking have to duplicate this code everywhere,
-	* since we want to stack allocate... */
-	p = alloca((args.len + 1)*sizeof(byte#))
-	cargs = (p castto(byte##))[:args.len]
-	for i = 0; i < args.len; i++
-		cargs[i] = cstring(args[i])
-	;;
-	cargs[args.len] = 0 castto(byte#)
-	-> syscall(Sysexecve, cstring(cmd), a(p), a(__cenvp))
-}
-
-const execve	= {cmd, args, env
-	var cargs, cenv, i
-	var p
-
-	/* copy the args */
-	p = alloca((args.len + 1)*sizeof(byte#))
-	cargs = (p castto(byte##))[:args.len]
-	for i = 0; i < args.len; i++
-		cargs[i] = cstring(args[i])
-	;;
-	cargs[args.len] = 0 castto(byte#)
-
-	/*
-	 copy the env.
-	 of course we fucking have to duplicate this code everywhere,
-	 since we want to stack allocate... 
-	*/
-	p = alloca((env.len + 1)*sizeof(byte#))
-	cenv = (p castto(byte##))[:env.len]
-	for i = 0; i < env.len; i++
-		cenv[i] = cstring(env[i])
-	;;
-	cenv[env.len] = 0 castto(byte#)
-
-	-> syscall(Sysexecve, cstring(cmd), a(p), a(cenv))
-}
-
-/* fd manipulation */
-const open	= {path, opts;		-> syscall(Sysopen, cstring(path), a(opts), a(0o777)) castto(fd)}
-const openmode	= {path, opts, mode;	-> syscall(Sysopen, cstring(path), a(opts), a(mode)) castto(fd)}
-const close	= {fd;			-> syscall(Sysclose, a(fd))}
-const creat	= {path, mode;		-> openmode(path, Ocreat | Otrunc | Owronly, mode) castto(fd)}
-const read	= {fd, buf;		-> syscall(Sysread, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
-const write	= {fd, buf;		-> syscall(Syswrite, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
-const lseek	= {fd, off, whence;	-> syscall(Syslseek, a(fd), a(off), a(whence))}
-const stat	= {path, sb;		-> syscall(Sysstat, cstring(path), a(sb))}
-const lstat	= {path, sb;		-> syscall(Syslstat, cstring(path), a(sb))}
-const fstat	= {fd, sb;		-> syscall(Sysfstat, a(fd), a(sb))}
-const mkdir	= {path, mode;		-> syscall(Sysmkdir, cstring(path), a(mode)) castto(int64)}
-const ioctl	= {fd, req, args
-	var arg : byte#
-	var ap
-
-	ap = vastart(&args)
-	(arg, ap) = vanext(ap)
-	-> syscall(Sysioctl, a(fd), a(req), a(arg)) castto(int64)
-}
-const getdirentries64	= {fd, buf, basep;	-> syscall(Sysgetdirentries, a(fd), buf castto(byte#), a(buf.len), a(basep))}
-
-/* networking */
-const socket	= {dom, stype, proto;	-> syscall(Syssocket, a(dom), a(stype), a(proto)) castto(fd) }
-const connect	= {sock, addr, len;	-> syscall(Sysconnect, a(sock), a(addr), a(len)) castto(int)}
-const accept	= {sock, addr, len;	-> syscall(Sysaccept, a(sock), a(addr), a(len)) castto(fd)}
-const listen	= {sock, backlog;	-> syscall(Syslisten, a(sock), a(backlog)) castto(int)}
-const bind	= {sock, addr, len;	-> syscall(Sysbind, a(sock), a(addr), a(len)) castto(int)}
-
-/* memory management */
-const munmap	= {addr, len;		-> syscall(Sysmunmap, a(addr), a(len))}
-const mmap	= {addr, len, prot, flags, fd, off;
-	-> syscall(Sysmmap, a(addr), a(len), a(prot), a(flags), a(fd), a(off)) castto(byte#)}
-
-/* time */
-const clock_getres = {clk, ts;	-> syscall(Sysclock_getres, clockid(clk), a(ts)) castto(int32)}
-const clock_gettime = {clk, ts;	-> syscall(Sysclock_gettime, clockid(clk), a(ts)) castto(int32)}
-const clock_settime = {clk, ts;	-> syscall(Sysclock_settime, clockid(clk), a(ts)) castto(int32)}
-
-/* system information */
-const uname	= {buf;	-> syscall(Sysfreebsd4_uname, a(buf)) castto(int)}
-
-const sysctl = {mib, old, new
-	var mibp
-	var mibsz
-	var o
-	var oldp
-	var oldsz
-	var newp
-	var newsz
-	var ret
-
-	mibp = mib castto(byte#)
-	mibsz = a(mib.len)
-	o = old#
-	oldp = o castto(byte#)
-	oldsz = a(o.len)
-	newp = new castto(byte#)
-	newsz = a(new.len)
-
-	/* all args already passed through a() or ar  ptrs */
-	ret = syscall(Sys__sysctl, mibp, mibsz, oldp, oldsz, newp, newsz) castto(int)
-
-	old# = o[:oldsz]
-	-> ret
-}
-
-const clockid = {clk
-	match clk
-	| `Clockrealtime:		-> 0
-	| `Clockvirtual:		-> 1
-	| `Clockprof:			-> 2
-	| `Clockmonotonic:		-> 4
-	| `Clockuptime:			-> 5
-	| `Clockuptime_precise:		-> 7
-	| `Clockuptime_fast:		-> 8
-	| `Clockrealtime_precise:	-> 9
-	| `Clockrealtime_fast:		-> 10
-	| `Clockmonotonic_precise:	-> 11
-	| `Clockmonotonic_fast:		-> 12
-	| `Clocksecond:			-> 13
-	;;
-	-> a(-1)
-}
--- a/libstd/sys-linux.myr
+++ /dev/null
@@ -1,751 +1,0 @@
-use "types.use"
-use "varargs.use"
-
-pkg std =
-	type pid	= int64	/* process id */
-	type scno	= int64	/* syscall */
-	type fdopt	= int64	/* fd options */
-	type fd		= int32	/* fd */
-	type mprot	= int64	/* memory protection */
-	type mopt	= int64	/* memory mapping options */
-
-	type socktype	= int64	/* socket type */
-	type sockproto	= int64	/* socket protocol */
-	type sockfam	= uint16	/* socket family */
-
-	type whence	= uint64
-	type filemode	= uint32
-
-	type epollflags	= uint32
-	type epollop	= uint32
-	type epollevttype	= uint32
-
-	type pollevt	= uint16
-
-	type clock = union
-		`Clockrealtime
-		`Clockmonotonic
-		`Clockproccpu
-		`Clockthreadcpu
-		`Clockmonotonicraw
-		`Clockrealtimecoarse
-		`Clockmonotoniccoarse
-		`Clockboottime
-		`Clockrealtimealarm
-		`Clockboottimealarm
-	;;
-
-	type timespec = struct
-		sec	: uint64
-		nsec	: uint64
-	;;
-
-	type timeval = struct
-		sec	: uint64
-		usec	: uint64
-	;;
-
-	type rusage = struct
-		utime	: timeval	/* user time */
-		stime	: timeval	/* system time */
-		_opaque	: uint64[14]	/* padding (darwin-specific data) */
-	;;
-
-	type statbuf = struct
-		 dev	: uint64
-		 ino	: uint64
-		 nlink	: uint64
-		 mode	: filemode
-		 uid	: uint32
-		 gid	: uint32
-		 __pad0	: uint32
-		 rdev	: uint64
-		 size	: uint64
-		 blksz	: uint32
-		 blocks	: uint64
-		 atime	: timespec
-		 mtime	: timespec
-		 ctime	: timespec
-		 __pad1	: uint64[3]
-	;;
-
-	type dirent64 = struct
-		ino	: uint64
-		off	: uint64
-		reclen	: uint16
-		etype	: byte
-		name	: byte[0]
-	;;
-
-	type utsname = struct
-		system	: byte[65]
-		node	: byte[65]
-		release	: byte[65]
-		version	: byte[65]
-		machine	: byte[65]
-		domain	: byte[65]
-	;;
-
-	type sockaddr = struct
-		fam	: sockfam
-		data	: byte[14]
-	;;
-
-	type sockaddr_in = struct
-		fam	: sockfam
-		port	: uint16
-		addr	: byte[4]
-		zero	: byte[8]
-	;;
-
-	type sockaddr_storage = struct
-		fam	: sockfam
-		__align	: uint32
-		__pad	: byte[112]
-	;;
-
-	type epollevt = struct
-		events	: epollevttype
-		data	: byte[8]
-	;;
-
-	type pollfd = struct
-		fd	: fd
-		events	: pollevt
-		revents	: pollevt
-	;;
-
-
-	/* open options */
-	const Ordonly  	: fdopt = 0x0
-	const Owronly  	: fdopt = 0x1
-	const Ordwr    	: fdopt = 0x2
-	const Ocreat   	: fdopt = 0x40
-	const Oexcl  	: fdopt = 0x80
-	const Otrunc   	: fdopt = 0x200
-	const Oappend  	: fdopt = 0x400
-	const Ondelay  	: fdopt = 0x800
-	const Odirect	: fdopt = 0x4000
-	const Odir	: fdopt = 0x10000
-	const Onofollow	: fdopt = 0x20000
-
-	/* stat modes */
-	const Sifmt	: filemode = 0xf000
-	const Sififo	: filemode = 0x1000
-	const Sifchr	: filemode = 0x2000
-	const Sifdir	: filemode = 0x4000
-	const Sifblk	: filemode = 0x6000
-	const Sifreg	: filemode = 0x8000
-	const Siflnk	: filemode = 0xa000
-	const Sifsock	: filemode = 0xc000
-
-	/* mmap protection */
-	const Mprotnone	: mprot = 0x0
-	const Mprotrd	: mprot = 0x1
-	const Mprotwr	: mprot = 0x2
-	const Mprotexec	: mprot = 0x4
-	const Mprotrw	: mprot = 0x3 /* convenience */
-	
-	/* mmap options */
-	const Mshared	: mopt = 0x1
-	const Mpriv	: mopt = 0x2
-	const Mfixed	: mopt = 0x10
-	const Mfile	: mopt = 0x0
-	const Manon	: mopt = 0x20
-	const M32bit	: mopt = 0x40
-
-	/* socket families. INCOMPLETE. */
-	const Afunspec	: sockfam = 0
-	const Afunix	: sockfam = 1
-	const Afinet	: sockfam = 2
-	const Afinet6	: sockfam = 10
-
-	/* socket types. */
-	const Sockstream	: socktype = 1	/* sequenced, reliable byte stream */
-	const Sockdgram		: socktype = 2	/* datagrams */
-	const Sockraw		: socktype = 3	/* raw proto */
-	const Sockrdm		: socktype = 4	/* reliably delivered messages */
-	const Sockseqpacket	: socktype = 5	/* sequenced, reliable packets */
-	const Sockdccp		: socktype = 6	/* data congestion control protocol */
-	const Sockpack		: socktype = 10	/* linux specific packet */
-
-	/* network protocols */
-	const Ipproto_ip	: sockproto = 0
-	const Ipproto_icmp	: sockproto = 1
-	const Ipproto_tcp	: sockproto = 6
-	const Ipproto_udp	: sockproto = 17
-	const Ipproto_raw	: sockproto = 255
-
-	/* epoll flags */
-	const Epollcloexec	: epollflags	= 0o2000000
-
-	/* epoll ops */
-	const Epollctladd	: epollop	= 0
-	const Epollctlmod	: epollop	= 1
-	const Epollctldel	: epollop	= 1
-
-	/* epoll events */
-	const Epollin	: epollevttype = 0x001
-	const Epollpri	: epollevttype = 0x002
-	const Epollout	: epollevttype = 0x004
-	const Epollerr	: epollevttype = 0x008
-	const Epollhup	: epollevttype = 0x010
-	const Epollrdnorm	: epollevttype = 0x040
-	const Epollrdband	: epollevttype = 0x080
-	const Epollwrnorm	: epollevttype = 0x100
-	const Epollwrband	: epollevttype = 0x200
-	const Epollmsg		: epollevttype = 0x400
-	const Epollrdhup	: epollevttype = 0x2000
-	const Epollwakeup	: epollevttype = 1 << 29
-	const Epolloneshot	: epollevttype = 1 << 30
-	const Epolledge	: epollevttype = 1 << 31
-
-	/* poll events : posix */
-	const Pollin	: pollevt = 0x001	/* There is data to read.  */
-	const Pollpri	: pollevt = 0x002	/* There is urgent data to read.  */
-	const Pollout	: pollevt = 0x004	/* Writing now will not block.  */
-
-	/* poll events: xopen */
-	const Pollrdnorm	: pollevt = 0x040	/* Normal data may be read.  */
-	const Pollrdband	: pollevt = 0x080	/* Priority data may be read.  */
-	const Pollwrnorm	: pollevt = 0x100	/* Writing now will not block.  */
-	const Pollwrband	: pollevt = 0x200	/* Priority data may be written.  */
-
-	/* poll events: linux */
-	const Pollmsg		: pollevt = 0x400
-	const Pollremove	: pollevt = 0x1000
-	const Pollrdhup		: pollevt = 0x2000
-
-	const Seekset	: whence = 0
-	const Seekcur	: whence = 1
-	const Seekend	: whence = 2
-
-	/* return value for a failed mapping */
-	const Mapbad	: byte# = -1 castto(byte#)
-
-	/* syscalls */
-	const Sysread			: scno = 0
-	const Syswrite			: scno = 1
-	const Sysopen			: scno = 2
-	const Sysclose			: scno = 3
-	const Sysstat			: scno = 4
-	const Sysfstat			: scno = 5
-	const Syslstat			: scno = 6
-	const Syspoll			: scno = 7
-	const Syslseek			: scno = 8
-	const Sysmmap			: scno = 9
-	const Sysmprotect		: scno = 10
-	const Sysmunmap			: scno = 11
-	const Sysbrk			: scno = 12
-	const Sysrt_sigaction		: scno = 13
-	const Sysrt_sigprocmask		: scno = 14
-	const Sysrt_sigreturn		: scno = 15
-	const Sysioctl			: scno = 16
-	const Syspread64		: scno = 17
-	const Syspwrite64		: scno = 18
-	const Sysreadv			: scno = 19
-	const Syswritev			: scno = 20
-	const Sysaccess			: scno = 21
-	const Syspipe			: scno = 22
-	const Sysselect			: scno = 23
-	const Syssched_yield		: scno = 24
-	const Sysmremap			: scno = 25
-	const Sysmsync			: scno = 26
-	const Sysmincore		: scno = 27
-	const Sysmadvise		: scno = 28
-	const Sysshmget			: scno = 29
-	const Sysshmat			: scno = 30
-	const Sysshmctl			: scno = 31
-	const Sysdup			: scno = 32
-	const Sysdup2			: scno = 33
-	const Syspause			: scno = 34
-	const Sysnanosleep		: scno = 35
-	const Sysgetitimer		: scno = 36
-	const Sysalarm			: scno = 37
-	const Syssetitimer		: scno = 38
-	const Sysgetpid			: scno = 39
-	const Syssendfile		: scno = 40
-	const Syssocket			: scno = 41
-	const Sysconnect		: scno = 42
-	const Sysaccept			: scno = 43
-	const Syssendto			: scno = 44
-	const Sysrecvfrom		: scno = 45
-	const Syssendmsg		: scno = 46
-	const Sysrecvmsg		: scno = 47
-	const Sysshutdown		: scno = 48
-	const Sysbind			: scno = 49
-	const Syslisten			: scno = 50
-	const Sysgetsockname		: scno = 51
-	const Sysgetpeername		: scno = 52
-	const Syssocketpair		: scno = 53
-	const Syssetsockopt		: scno = 54
-	const Sysgetsockopt		: scno = 55
-	const Sysclone			: scno = 56
-	const Sysfork			: scno = 57
-	const Sysvfork			: scno = 58
-	const Sysexecve			: scno = 59
-	const Sysexit			: scno = 60
-	const Syswait4			: scno = 61
-	const Syskill			: scno = 62
-	const Sysuname			: scno = 63
-	const Syssemget			: scno = 64
-	const Syssemop			: scno = 65
-	const Syssemctl			: scno = 66
-	const Sysshmdt			: scno = 67
-	const Sysmsgget			: scno = 68
-	const Sysmsgsnd			: scno = 69
-	const Sysmsgrcv			: scno = 70
-	const Sysmsgctl			: scno = 71
-	const Sysfcntl			: scno = 72
-	const Sysflock			: scno = 73
-	const Sysfsync			: scno = 74
-	const Sysfdatasync		: scno = 75
-	const Systruncate		: scno = 76
-	const Sysftruncate		: scno = 77
-	const Sysgetdents		: scno = 78
-	const Sysgetcwd			: scno = 79
-	const Syschdir			: scno = 80
-	const Sysfchdir			: scno = 81
-	const Sysrename			: scno = 82
-	const Sysmkdir			: scno = 83
-	const Sysrmdir			: scno = 84
-	const Syscreat			: scno = 85
-	const Syslink			: scno = 86
-	const Sysunlink			: scno = 87
-	const Syssymlink		: scno = 88
-	const Sysreadlink		: scno = 89
-	const Syschmod			: scno = 90
-	const Sysfchmod			: scno = 91
-	const Syschown			: scno = 92
-	const Sysfchown			: scno = 93
-	const Syslchown			: scno = 94
-	const Sysumask			: scno = 95
-	const Sysgettimeofday		: scno = 96
-	const Sysgetrlimit		: scno = 97
-	const Sysgetrusage		: scno = 98
-	const Syssysinfo		: scno = 99
-	const Systimes			: scno = 100
-	const Sysptrace			: scno = 101
-	const Sysgetuid			: scno = 102
-	const Syssyslog			: scno = 103
-	const Sysgetgid			: scno = 104
-	const Syssetuid			: scno = 105
-	const Syssetgid			: scno = 106
-	const Sysgeteuid		: scno = 107
-	const Sysgetegid		: scno = 108
-	const Syssetpgid		: scno = 109
-	const Sysgetppid		: scno = 110
-	const Sysgetpgrp		: scno = 111
-	const Syssetsid			: scno = 112
-	const Syssetreuid		: scno = 113
-	const Syssetregid		: scno = 114
-	const Sysgetgroups		: scno = 115
-	const Syssetgroups		: scno = 116
-	const Syssetresuid		: scno = 117
-	const Sysgetresuid		: scno = 118
-	const Syssetresgid		: scno = 119
-	const Sysgetresgid		: scno = 120
-	const Sysgetpgid		: scno = 121
-	const Syssetfsuid		: scno = 122
-	const Syssetfsgid		: scno = 123
-	const Sysgetsid			: scno = 124
-	const Syscapget			: scno = 125
-	const Syscapset			: scno = 126
-	const Sysrt_sigpending		: scno = 127
-	const Sysrt_sigtimedwait	: scno = 128
-	const Sysrt_sigqueueinfo	: scno = 129
-	const Sysrt_sigsuspend		: scno = 130
-	const Syssigaltstack		: scno = 131
-	const Sysutime			: scno = 132
-	const Sysmknod			: scno = 133
-	const Sysuselib			: scno = 134
-	const Syspersonality		: scno = 135
-	const Sysustat			: scno = 136
-	const Sysstatfs			: scno = 137
-	const Sysfstatfs		: scno = 138
-	const Syssysfs			: scno = 139
-	const Sysgetpriority		: scno = 140
-	const Syssetpriority		: scno = 141
-	const Syssched_setparam		: scno = 142
-	const Syssched_getparam		: scno = 143
-	const Syssched_setscheduler	: scno = 144
-	const Syssched_getscheduler	: scno = 145
-	const Syssched_get_priority_max	: scno = 146
-	const Syssched_get_priority_min	: scno = 147
-	const Syssched_rr_get_interval	: scno = 148
-	const Sysmlock			: scno = 149
-	const Sysmunlock		: scno = 150
-	const Sysmlockall		: scno = 151
-	const Sysmunlockall		: scno = 152
-	const Sysvhangup		: scno = 153
-	const Sysmodify_ldt		: scno = 154
-	const Syspivot_root		: scno = 155
-	const Sys_sysctl		: scno = 156
-	const Sysprctl			: scno = 157
-	const Sysarch_prctl		: scno = 158
-	const Sysadjtimex		: scno = 159
-	const Syssetrlimit		: scno = 160
-	const Syschroot			: scno = 161
-	const Syssync			: scno = 162
-	const Sysacct			: scno = 163
-	const Syssettimeofday		: scno = 164
-	const Sysmount			: scno = 165
-	const Sysumount2		: scno = 166
-	const Sysswapon			: scno = 167
-	const Sysswapoff		: scno = 168
-	const Sysreboot			: scno = 169
-	const Syssethostname		: scno = 170
-	const Syssetdomainname		: scno = 171
-	const Sysiopl			: scno = 172
-	const Sysioperm			: scno = 173
-	const Syscreate_module		: scno = 174
-	const Sysinit_module		: scno = 175
-	const Sysdelete_module		: scno = 176
-	const Sysget_kernel_syms	: scno = 177
-	const Sysquery_module		: scno = 178
-	const Sysquotactl		: scno = 179
-	const Sysnfsservctl		: scno = 180
-	const Sysgetpmsg		: scno = 181
-	const Sysputpmsg		: scno = 182
-	const Sysafs_syscall		: scno = 183
-	const Systuxcall		: scno = 184
-	const Syssecurity		: scno = 185
-	const Sysgettid			: scno = 186
-	const Sysreadahead		: scno = 187
-	const Syssetxattr		: scno = 188
-	const Syslsetxattr		: scno = 189
-	const Sysfsetxattr		: scno = 190
-	const Sysgetxattr		: scno = 191
-	const Syslgetxattr		: scno = 192
-	const Sysfgetxattr		: scno = 193
-	const Syslistxattr		: scno = 194
-	const Sysllistxattr		: scno = 195
-	const Sysflistxattr		: scno = 196
-	const Sysremovexattr		: scno = 197
-	const Syslremovexattr		: scno = 198
-	const Sysfremovexattr		: scno = 199
-	const Systkill			: scno = 200
-	const Systime			: scno = 201
-	const Sysfutex			: scno = 202
-	const Syssched_setaffinity	: scno = 203
-	const Syssched_getaffinity	: scno = 204
-	const Sysset_thread_area	: scno = 205
-	const Sysio_setup		: scno = 206
-	const Sysio_destroy		: scno = 207
-	const Sysio_getevents		: scno = 208
-	const Sysio_submit		: scno = 209
-	const Sysio_cancel		: scno = 210
-	const Sysget_thread_area	: scno = 211
-	const Syslookup_dcookie		: scno = 212
-	const Sysepoll_create		: scno = 213
-	const Sysepoll_ctl_old		: scno = 214
-	const Sysepoll_wait_old		: scno = 215
-	const Sysremap_file_pages	: scno = 216
-	const Sysgetdents64		: scno = 217
-	const Sysset_tid_address	: scno = 218
-	const Sysrestart_syscall	: scno = 219
-	const Syssemtimedop		: scno = 220
-	const Sysfadvise64		: scno = 221
-	const Systimer_create		: scno = 222
-	const Systimer_settime		: scno = 223
-	const Systimer_gettime		: scno = 224
-	const Systimer_getoverrun	: scno = 225
-	const Systimer_delete		: scno = 226
-	const Sysclock_settime		: scno = 227
-	const Sysclock_gettime		: scno = 228
-	const Sysclock_getres		: scno = 229
-	const Sysclock_nanosleep	: scno = 230
-	const Sysexit_group		: scno = 231
-	const Sysepoll_wait		: scno = 232
-	const Sysepoll_ctl		: scno = 233
-	const Systgkill			: scno = 234
-	const Sysutimes			: scno = 235
-	const Sysvserver		: scno = 236
-	const Sysmbind			: scno = 237
-	const Sysset_mempolicy		: scno = 238
-	const Sysget_mempolicy		: scno = 239
-	const Sysmq_open		: scno = 240
-	const Sysmq_unlink		: scno = 241
-	const Sysmq_timedsend		: scno = 242
-	const Sysmq_timedreceive	: scno = 243
-	const Sysmq_notify		: scno = 244
-	const Sysmq_getsetattr		: scno = 245
-	const Syskexec_load		: scno = 246
-	const Syswaitid			: scno = 247
-	const Sysadd_key		: scno = 248
-	const Sysrequest_key		: scno = 249
-	const Syskeyctl			: scno = 250
-	const Sysioprio_set		: scno = 251
-	const Sysioprio_get		: scno = 252
-	const Sysinotify_init		: scno = 253
-	const Sysinotify_add_watch	: scno = 254
-	const Sysinotify_rm_watch	: scno = 255
-	const Sysmigrate_pages		: scno = 256
-	const Sysopenat			: scno = 257
-	const Sysmkdirat		: scno = 258
-	const Sysmknodat		: scno = 259
-	const Sysfchownat		: scno = 260
-	const Sysfutimesat		: scno = 261
-	const Sysnewfstatat		: scno = 262
-	const Sysunlinkat		: scno = 263
-	const Sysrenameat		: scno = 264
-	const Syslinkat			: scno = 265
-	const Syssymlinkat		: scno = 266
-	const Sysreadlinkat		: scno = 267
-	const Sysfchmodat		: scno = 268
-	const Sysfaccessat		: scno = 269
-	const Syspselect6		: scno = 270
-	const Sysppoll			: scno = 271
-	const Sysunshare		: scno = 272
-	const Sysset_robust_list	: scno = 273
-	const Sysget_robust_list	: scno = 274
-	const Syssplice			: scno = 275
-	const Systee			: scno = 276
-	const Syssync_file_range	: scno = 277
-	const Sysvmsplice		: scno = 278
-	const Sysmove_pages		: scno = 279
-	const Sysutimensat		: scno = 280
-	const Sysepoll_pwait		: scno = 281
-	const Syssignalfd		: scno = 282
-	const Systimerfd_create		: scno = 283
-	const Syseventfd		: scno = 284
-	const Sysfallocate		: scno = 285
-	const Systimerfd_settime	: scno = 286
-	const Systimerfd_gettime	: scno = 287
-	const Sysaccept4		: scno = 288
-	const Syssignalfd4		: scno = 289
-	const Syseventfd2		: scno = 290
-	const Sysepoll_create1		: scno = 291
-	const Sysdup3			: scno = 292
-	const Syspipe2			: scno = 293
-	const Sysinotify_init1		: scno = 294
-	const Syspreadv			: scno = 295
-	const Syspwritev		: scno = 296
-	const Sysrt_tgsigqueueinfo	: scno = 297
-	const Sysperf_event_open	: scno = 298
-	const Sysrecvmmsg		: scno = 299
-	const Sysfanotify_init		: scno = 300
-	const Sysfanotify_mark		: scno = 301
-	const Sysprlimit64		: scno = 302
-	const Sysname_to_handle_at	: scno = 303
-	const Sysopen_by_handle_at	: scno = 304
-	const Sysclock_adjtime		: scno = 305
-	const Syssyncfs			: scno = 306
-	const Syssendmmsg		: scno = 307
-	const Syssetns			: scno = 308
-	const Sysgetcpu			: scno = 309
-	const Sysprocess_vm_readv	: scno = 310
-	const Sysprocess_vm_writev	: scno = 311
-
-	/* getting to the os */
-	extern const syscall	: (sc:scno, args:... -> int64)
-
-	/* process management */
-	const exit	: (status:int -> void)
-	const getpid	: ( -> pid)
-	const kill	: (pid:pid, sig:int64 -> int64)
-	const fork	: (-> pid)
-	const clone	: (flags : uint64, stk : void#, ptid : void#, ctid : void#, ptreg : void# -> pid)
-	const wait4	: (pid:pid, loc:int32#, opt : int64, usage:rusage#	-> int64)
-	const waitpid	: (pid:pid, loc:int32#, opt : int64	-> int64)
-	const execv	: (cmd : byte[:], args : byte[:][:] -> int64)
-	const execve	: (cmd : byte[:], args : byte[:][:], env : byte[:][:] -> int64)
-
-
-	/* file manipulation */
-	const open	: (path:byte[:], opts:fdopt -> fd)
-	const openmode	: (path:byte[:], opts:fdopt, mode:int64 -> fd)
-	const close	: (fd:fd -> int64)
-	const creat	: (path:byte[:], mode:int64 -> fd)
-	const unlink	: (path:byte[:] -> int)
-	const read	: (fd:fd, buf:byte[:] -> size)
-	const write	: (fd:fd, buf:byte[:] -> size)
-	const lseek	: (fd:fd, off:uint64, whence:int64 -> int64)
-	const stat	: (path:byte[:], sb:statbuf# -> int64)
-	const lstat	: (path:byte[:], sb:statbuf# -> int64)
-	const fstat	: (fd:fd, sb:statbuf# -> int64)
-	const mkdir	: (path : byte[:], mode : int64	-> int64)
-	const ioctl	: (fd:fd, req : int64, args:... -> int64)
-	const getdents64	: (fd:fd, buf : byte[:] -> int64)
-	const chdir	: (p : byte[:] -> int64)
-
-	/* fd stuff */
-	const pipe	: (fds : fd[:] -> int64)
-	const dup	: (fd : fd -> fd)
-	const dup2	: (src : fd, dst : fd -> fd)
-
-	/* polling */
-	const epollcreate	: (flg : epollflags	-> fd)	/* actually epoll_create1 */
-	const epollctl	: (epfd : fd, op : int, fd : fd, evt : epollevt# -> int)
-	const epollwait	: (epfd : fd, evts : epollevt[:], timeout : int -> int)
-	const poll	: (pfd	: pollfd[:], timeout : int	-> int)
-
-	/* networking */
-	const socket	: (dom : sockfam, stype : socktype, proto : sockproto	-> fd)
-	const connect	: (sock	: fd, addr : sockaddr#, len : size -> int)
-	const accept	: (sock : fd, addr : sockaddr#, len : size# -> fd)
-	const listen	: (sock : fd, backlog : int	-> int)
-	const bind	: (sock : fd, addr : sockaddr#, len : size -> int)
-
-	/* memory mapping */
-	const munmap	: (addr:byte#, len:size -> int64)
-	const mmap	: (addr:byte#, len:size, prot:mprot, flags:mopt, fd:fd, off:off -> byte#)
-
-	/* time */
-	const clock_getres	: (clk : clock, ts : timespec# -> int32)
-	const clock_gettime	: (clk : clock, ts : timespec# -> int32)
-	const clock_settime	: (clk : clock, ts : timespec# -> int32)
-	const sleep	: (time : uint64 -> int32)
-	const nanosleep	: (req : timespec#, rem : timespec# -> int32)
-
-	/* system information */
-	const uname 	: (buf : utsname# -> int)
-;;
-
-/* 
-wraps a syscall argument, converting it to 64 bits for the syscall function. This is
-the same as casting, but more concise than writing castto(int64)
-*/
-generic a = {x : @t
-	-> x castto(uint64)
-}
-
-extern const cstring	: (str : byte[:] -> byte#)
-extern const alloca	: (sz : size	-> byte#)
-extern const __cenvp : byte##
-
-/* process management */
-const exit	= {status;		syscall(Sysexit, a(status))}
-const getpid	= {;			-> syscall(Sysgetpid) castto(pid)}
-const kill	= {pid, sig;		-> syscall(Syskill, a(pid), a(sig))}
-const fork	= {;			-> syscall(Sysfork) castto(pid)}
-const clone	= {flags, stk, ptid, ctid, ptreg;	-> syscall(Sysclone, a(flags), a(stk), a(ptid), a(ctid), a(ptreg)) castto(pid)}
-const wait4	= {pid, loc, opt, usage;	-> syscall(Syswait4, a(pid), a(loc), a(opt), a(usage))}
-const waitpid	= {pid, loc, opt;
-	var rusage
-	-> wait4(pid, loc, opt, &rusage)
-}
-
-const execv	= {cmd, args
-	var p, cargs, i
-
-	/* of course we fucking have to duplicate this code everywhere,
-	* since we want to stack allocate... */
-	p = alloca((args.len + 1)*sizeof(byte#))
-	cargs = (p castto(byte##))[:args.len + 1]
-	for i = 0; i < args.len; i++
-		cargs[i] = cstring(args[i])
-	;;
-	cargs[args.len] = 0 castto(byte#)
-	-> syscall(Sysexecve, cstring(cmd), a(p), a(__cenvp))
-}
-
-const execve	= {cmd, args, env
-	var cargs, cenv, i
-	var p
-
-	/* copy the args */
-	p = alloca((args.len + 1)*sizeof(byte#))
-	cargs = (p castto(byte##))[:args.len + 1]
-	for i = 0; i < args.len; i++
-		cargs[i] = cstring(args[i])
-	;;
-	cargs[args.len] = 0 castto(byte#)
-
-	/*
-	 copy the env.
-	 of course we fucking have to duplicate this code everywhere,
-	 since we want to stack allocate... 
-	*/
-	p = alloca((env.len + 1)*sizeof(byte#))
-	cenv = (p castto(byte##))[:env.len]
-	for i = 0; i < env.len; i++
-		cenv[i] = cstring(env[i])
-	;;
-	cenv[env.len] = 0 castto(byte#)
-
-	-> syscall(Sysexecve, cstring(cmd), a(p), a(cenv))
-}
-
-/* file manipulation */
-const open	= {path, opts;		-> syscall(Sysopen, cstring(path), a(opts), a(0o777)) castto(fd)}
-const openmode	= {path, opts, mode;	-> syscall(Sysopen, cstring(path), a(opts), a(mode)) castto(fd)}
-const close	= {fd;			-> syscall(Sysclose, a(fd))}
-const creat	= {path, mode;		-> syscall(Syscreat, cstring(path), a(mode)) castto(fd)}
-const unlink	= {path;		-> syscall(Sysunlink, cstring(path)) castto(int)}
-const read	= {fd, buf;		-> syscall(Sysread, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
-const write	= {fd, buf;		-> syscall(Syswrite, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
-const lseek	= {fd, off, whence;	-> syscall(Syslseek, a(fd), a(off), a(whence))}
-const stat	= {path, sb;		-> syscall(Sysstat, cstring(path), a(sb))}
-const lstat	= {path, sb;		-> syscall(Syslstat, cstring(path), a(sb))}
-const fstat	= {fd, sb;		-> syscall(Sysfstat, a(fd), a(sb))}
-const mkdir	= {path, mode;		-> syscall(Sysmkdir, cstring(path), a(mode)) castto(int64)}
-const ioctl	= {fd, req, args
-	var arg : byte#
-	var ap
-
-	ap = vastart(&args)
-	(arg, ap) = vanext(ap)
-	-> syscall(Sysioctl, a(fd), a(req), a(arg)) castto(int64)
-}
-const getdents64	= {fd, buf;	-> syscall(Sysgetdents64, a(fd), buf castto(byte#), a(buf.len))}
-const chdir	= {dir;	-> syscall(Syschdir, dir)}
-
-/* file stuff */
-const pipe	= {fds;	-> syscall(Syspipe, fds castto(fd#))}
-const dup 	= {fd;	-> syscall(Sysdup, a(fd)) castto(fd)}
-const dup2 	= {src, dst;	-> syscall(Sysdup2, a(src), a(dst)) castto(fd)}
-
-/* epoll */
-const poll	= {pfd, timeout;	-> syscall(Syspoll, pfd castto(pollfd#), a(pfd.len), a(timeout)) castto(int)}
-const epollctl	= {epfd, op, fd, evt;
-	-> syscall(Sysepoll_ctl, a(epfd), a(op), a(fd), a(evt)) castto(int)}
-const epollwait	= {epfd, evts, timeout;
-	-> syscall(Sysepoll_wait, a(epfd), evts castto(epollevt#), a(evts.len), a(timeout)) castto(int)}
-const epollcreate	= {flg;	-> syscall(Sysepoll_create1, a(flg)) castto(fd)}
-
-/* networking */
-const socket	= {dom, stype, proto;	-> syscall(Syssocket, a(dom), a(stype), a(proto)) castto(fd)}
-const connect	= {sock, addr, len;	-> syscall(Sysconnect, a(sock), a(addr), a(len)) castto(int)}
-const bind	= {sock, addr, len;	-> syscall(Sysbind, a(sock), a(addr), a(len)) castto(int)}
-const listen	= {sock, backlog;	-> syscall(Syslisten, a(sock), a(backlog)) castto(int)}
-const accept	= {sock, addr, lenp;	-> syscall(Sysaccept, a(sock), a(addr), a(lenp)) castto(fd)}
-
-/* memory mapping */
-const munmap	= {addr, len;		-> syscall(Sysmunmap, a(addr), a(len))}
-const mmap	= {addr, len, prot, flags, fd, off;
-	-> syscall(Sysmmap, a(addr), a(len), a(prot), a(flags), a(fd), a(off)) castto(byte#)
-}
-
-/* time */
-const clock_getres = {clk, ts;	-> syscall(Sysclock_getres, clockid(clk), a(ts)) castto(int32)}
-const clock_gettime = {clk, ts;	-> syscall(Sysclock_gettime, clockid(clk), a(ts)) castto(int32)}
-const clock_settime = {clk, ts;	-> syscall(Sysclock_settime, clockid(clk), a(ts)) castto(int32)}
-
-const sleep = {time
-	var req, rem
-	req = [.sec = time, .nsec = 0]
-	-> nanosleep(&req, &rem)
-}
-
-const nanosleep	= {req, rem;	-> syscall(Sysnanosleep, a(req), a(rem)) castto(int32)}
-
-/* system information */
-const uname	= {buf;	-> syscall(Sysuname, buf) castto(int)}
-
-const clockid = {clk
-	match clk
-	| `Clockrealtime:	-> 0
-	| `Clockmonotonic:	-> 1
-	| `Clockproccpu:	-> 2
-	| `Clockthreadcpu:	-> 3
-	| `Clockmonotonicraw:	-> 4
-	| `Clockrealtimecoarse:	-> 5
-	| `Clockmonotoniccoarse:-> 6
-	| `Clockboottime:	-> 7
-	| `Clockrealtimealarm:	-> 8
-	| `Clockboottimealarm:	-> 9
-	;;
-	-> -1
-}
-
--- a/libstd/sys-osx.myr
+++ /dev/null
@@ -1,865 +1,0 @@
-use "types.use"
-use "varargs.use"
-
-pkg std =
-	type scno 	= int64	/* syscall */
-	type fdopt	= int64	/* fd options */
-	type fd		= int32	/* fd */
-	type pid	= int64	/* pid */
-	type mprot	= int64	/* memory protection */
-	type mopt	= int64	/* memory mapping options */
-	type socktype	= int64	/* socket type */
-	type sockproto	= int64	/* socket protocol */
-	type sockfam	= uint8	/* socket family */
-	type filemode	= uint16	/* file permission bits */
-	type kflags	= uint16	/* kqueue flags */
-
-	type timespec = struct
-		sec	: uint64
-		nsec	: uint32
-	;;
-
-	type timeval = struct
-		sec	: uint64
-		usec	: uint32
-	;;
-
-	type timezone = struct
-		minwest	: int32 /* of greenwich */
-		dsttime	: int32	/* nonzero if DST applies */
-	;;
-
-	type clock = union
-		`Clockrealtime
-		`Clockmonotonic
-	;;
-
-	type statbuf = struct
-		dev	: int32
-		mode	: filemode
-		nlink	: uint16
-		ino	: uint64
-		uid	: uint32
-		gid	: uint32
-		rdev	: uint32
-		atime	: timespec
-		mtime	: timespec
-		ctime	: timespec
-		birthtimespec	: timespec
-		size	: off
-		blocks	: int64
-		blksize	: int32
-		flags	: uint32
-		gen	: uint32
-		_spare	: uint32
-		_qspare	: uint64[2]
-	;;
-
-	type rusage = struct
-		utime	: timeval	/* user time */
-		stime	: timeval	/* system time */
-		_opaque	: uint64[14]	/* padding (darwin-specific data) */
-	;;
-
-	type utsname = struct
-		system	: byte[256]
-		node	: byte[256]
-		release	: byte[256]
-		version	: byte[256]
-		machine	: byte[256]
-	;;
-
-	type sockaddr = struct
-		len	: byte
-		fam	: sockfam
-		data	: byte[14] /* what is the *actual* length? */
-	;;
-
-	type sockaddr_in = struct
-		len	: byte
-		fam	: sockfam
-		port	: uint16
-		addr	: byte[4]
-		zero	: byte[8]
-	;;
-
-	type sockaddr_storage = struct
-		len	: byte
-		fam	: sockfam
-		__pad1	: byte[6]
-		__align	: uint64
-		__pad2	: byte[112]
-	;;
-
-	type dirent64 = struct
-		ino	: uint64
-		seekoff	: uint64	/* seek offset (optional, used by servers) */
-		reclen	: uint16	/* length of this record */
-		namlen	: uint16	/* length of string in d_name */
-		typeid  : uint8		/* file type, see below */
-		name	: byte[0]
-	;;
-
-	type kevent = struct
-		ident	: intptr	/* identifier for this event */
-		filter	: int16		/* filter for event */
-		flags	: uint16	/* general flags */
-		fflags	: uint32	/* filter-specific flags */
-		data	: intptr	/* filter-specific data */
-		udata	: byte#		/* opaque user data identifier */
-	;;
-
-	type kevent64 = struct
-		ident	: uint64	/* identifier for this event */
-		filter	: int16		/* filter for event */
-		flags	: kflags	/* general flags */
-		fflags	: uint32	/* filter-specific flags */
-		data	: int64		/* filter-specific data */
-		udata	: uint64	/* opaque user data identifier */
-		ext	: uint64[2]	/* filter-specific extensions */
-	;;
-
-	/* kqueue events */
-	const Kevadd		: kflags = 0x0001	/* add event to kq (implies enable) */
-	const Kevdelete		: kflags = 0x0002	/* delete event from kq */
-	const Kevenable		: kflags = 0x0004	/* enable event */
-	const Kevdisable	: kflags = 0x0008	/* disable event (not reported) */
-	const Kevreceipt	: kflags = 0x0040	/* force EV_ERROR on success, data == 0 */
-
-	/* kqueue flags */
-	const Kevoneshot	: kflags = 0x0010	/* only report one occurrence */
-	const Kevclear		: kflags = 0x0020	/* clear event state after reporting */
-	const Kevdispatch	: kflags = 0x0080	/* disable event after reporting */
-
-	const Kevsysflags	: kflags = 0xf000	/* reserved by system */
-	const Kevflag0		: kflags = 0x1000	/* filter-specific flag */
-	const Kevflag1		: kflags = 0x2000	/* filter-specific flag */
-
-	/* kqueue returned values */
-	const Keveof		: kflags = 0x8000	/* eof detected */
-	const Keverror		: kflags = 0x4000	/* error, data contains errno */
-
-	/* open options */
-	const Ordonly  	: fdopt = 0x0
-	const Owronly  	: fdopt = 0x1
-	const Ordwr    	: fdopt = 0x2
-	const Ondelay  	: fdopt = 0x4
-	const Oappend  	: fdopt = 0x8
-	const Ocreat   	: fdopt = 0x200
-	const Onofollow	: fdopt = 0x100
-	const Otrunc   	: fdopt = 0x400
-	const Odir	: fdopt = 0x100000
-
-	/* stat modes */
-	const Sifmt	: filemode = 0xf000
-	const Sififo	: filemode = 0x1000
-	const Sifchr	: filemode = 0x2000
-	const Sifdir	: filemode = 0x4000
-	const Sifblk	: filemode = 0x6000
-	const Sifreg	: filemode = 0x8000
-	const Siflnk	: filemode = 0xa000
-	const Sifsock	: filemode = 0xc000
-
-	/* mmap protection */
-	const Mprotnone	: mprot = 0x0
-	const Mprotrd	: mprot = 0x1
-	const Mprotwr	: mprot = 0x2
-	const Mprotexec	: mprot = 0x4
-	const Mprotrw	: mprot = 0x3
-
-	/* mmap options */
-	const Mshared	: mopt = 0x1
-	const Mpriv	: mopt = 0x2
-	const Mfixed	: mopt = 0x10
-	const Mfile	: mopt = 0x0
-	const Manon	: mopt = 0x1000
-	/* Only on Linux
-	const M32bit	: mopt = 0x40
-	*/
-
-	/* socket families. INCOMPLETE. */
-	const Afunspec	: sockfam = 0
-	const Afunix	: sockfam = 1
-	const Afinet	: sockfam = 2
-	const Afinet6	: sockfam = 30
-
-	/* socket types. */
-	const Sockstream	: socktype = 1
-	const Sockdgram		: socktype = 2
-	const Sockraw		: socktype = 3
-	const Sockrdm		: socktype = 4
-	const Sockseqpacket	: socktype = 5
-
-	/* network protocols */
-	const Ipproto_ip	: sockproto = 0
-	const Ipproto_icmp	: sockproto = 1
-	const Ipproto_tcp	: sockproto = 6
-	const Ipproto_udp	: sockproto = 17
-	const Ipproto_raw	: sockproto = 255
-
-	/* return value for a failed mapping */
-	const Mapbad	: byte# = -1 castto(byte#)
-
-	/* syscalls.
-	note, creat() implemented as open(path, Creat|Trunc|Wronly) */
-	const Syssyscall	: scno = 0x2000000
-	const Sysexit		: scno = 0x2000001
-	const Sysfork		: scno = 0x2000002
-	const Sysread		: scno = 0x2000003
-	const Syswrite		: scno = 0x2000004
-	const Sysopen		: scno = 0x2000005
-	const Sysclose		: scno = 0x2000006
-	const Syswait4		: scno = 0x2000007
-	const Syslink		: scno = 0x2000009
-	const Sysunlink		: scno = 0x200000a
-	const Syschdir		: scno = 0x200000c
-	const Sysfchdir		: scno = 0x200000d
-	const Sysmknod		: scno = 0x200000e
-	const Syschmod		: scno = 0x200000f
-	const Syschown		: scno = 0x2000010
-	const Sysgetfsstat	: scno = 0x2000012
-	const Sysgetpid		: scno = 0x2000014
-	const Syssetuid		: scno = 0x2000017
-	const Sysgetuid		: scno = 0x2000018
-	const Sysgeteuid	: scno = 0x2000019
-	const Sysptrace		: scno = 0x200001a
-	const Sysrecvmsg	: scno = 0x200001b
-	const Syssendmsg	: scno = 0x200001c
-	const Sysrecvfrom	: scno = 0x200001d
-	const Sysaccept		: scno = 0x200001e
-	const Sysgetpeername	: scno = 0x200001f
-	const Sysgetsockname	: scno = 0x2000020
-	const Sysaccess		: scno = 0x2000021
-	const Syschflags	: scno = 0x2000022
-	const Sysfchflags	: scno = 0x2000023
-	const Syssync		: scno = 0x2000024
-	const Syskill		: scno = 0x2000025
-	const Sysgetppid	: scno = 0x2000027
-	const Sysdup		: scno = 0x2000029
-	const Syspipe		: scno = 0x200002a
-	const Sysgetegid	: scno = 0x200002b
-	const Sysprofil		: scno = 0x200002c
-	const Syssigaction	: scno = 0x200002e
-	const Sysgetgid		: scno = 0x200002f
-	const Syssigprocmask	: scno = 0x2000030
-	const Sysgetlogin	: scno = 0x2000031
-	const Syssetlogin	: scno = 0x2000032
-	const Sysacct		: scno = 0x2000033
-	const Syssigpending	: scno = 0x2000034
-	const Syssigaltstack	: scno = 0x2000035
-	const Sysioctl		: scno = 0x2000036
-	const Sysreboot		: scno = 0x2000037
-	const Sysrevoke		: scno = 0x2000038
-	const Syssymlink	: scno = 0x2000039
-	const Sysreadlink	: scno = 0x200003a
-	const Sysexecve		: scno = 0x200003b
-	const Sysumask		: scno = 0x200003c
-	const Syschroot		: scno = 0x200003d
-	const Sysmsync		: scno = 0x2000041
-	const Sysvfork		: scno = 0x2000042
-	const Sysmunmap		: scno = 0x2000049
-	const Sysmprotect	: scno = 0x200004a
-	const Sysmadvise	: scno = 0x200004b
-	const Sysmincore	: scno = 0x200004e
-	const Sysgetgroups	: scno = 0x200004f
-	const Syssetgroups	: scno = 0x2000050
-	const Sysgetpgrp	: scno = 0x2000051
-	const Syssetpgid	: scno = 0x2000052
-	const Syssetitimer	: scno = 0x2000053
-	const Sysswapon		: scno = 0x2000055
-	const Sysgetitimer	: scno = 0x2000056
-	const Sysgetdtablesize	: scno = 0x2000059
-	const Sysdup2		: scno = 0x200005a
-	const Sysfcntl		: scno = 0x200005c
-	const Sysselect		: scno = 0x200005d
-	const Sysfsync		: scno = 0x200005f
-	const Syssetpriority	: scno = 0x2000060
-	const Syssocket		: scno = 0x2000061
-	const Sysconnect	: scno = 0x2000062
-	const Sysgetpriority	: scno = 0x2000064
-	const Sysbind		: scno = 0x2000068
-	const Syssetsockopt	: scno = 0x2000069
-	const Syslisten		: scno = 0x200006a
-	const Syssigsuspend	: scno = 0x200006f
-	const Sysgettimeofday	: scno = 0x2000074
-	const Sysgetrusage	: scno = 0x2000075
-	const Sysgetsockopt	: scno = 0x2000076
-	const Sysreadv		: scno = 0x2000078
-	const Syswritev		: scno = 0x2000079
-	const Syssettimeofday	: scno = 0x200007a
-	const Sysfchown		: scno = 0x200007b
-	const Sysfchmod		: scno = 0x200007c
-	const Syssetreuid	: scno = 0x200007e
-	const Syssetregid	: scno = 0x200007f
-	const Sysrename		: scno = 0x2000080
-	const Sysflock		: scno = 0x2000083
-	const Sysmkfifo		: scno = 0x2000084
-	const Syssendto		: scno = 0x2000085
-	const Sysshutdown	: scno = 0x2000086
-	const Syssocketpair	: scno = 0x2000087
-	const Sysmkdir		: scno = 0x2000088
-	const Sysrmdir		: scno = 0x2000089
-	const Sysutimes		: scno = 0x200008a
-	const Sysfutimes	: scno = 0x200008b
-	const Sysadjtime	: scno = 0x200008c
-	const Sysgethostuuid	: scno = 0x200008e
-	const Syssetsid		: scno = 0x2000093
-	const Sysgetpgid	: scno = 0x2000097
-	const Syssetprivexec	: scno = 0x2000098
-	const Syspread		: scno = 0x2000099
-	const Syspwrite		: scno = 0x200009a
-	const Sysnfssvc		: scno = 0x200009b
-	const Sysstatfs		: scno = 0x200009d
-	const Sysfstatfs	: scno = 0x200009e
-	const Sysunmount	: scno = 0x200009f
-	const Sysgetfh		: scno = 0x20000a1
-	const Sysquotactl	: scno = 0x20000a5
-	const Sysmount		: scno = 0x20000a7
-	const Syscsops		: scno = 0x20000a9
-	const Syswaitid		: scno = 0x20000ad
-	const Sysadd_profil	: scno = 0x20000b0
-	const Syskdebug_trace	: scno = 0x20000b4
-	const Syssetgid		: scno = 0x20000b5
-	const Syssetegid	: scno = 0x20000b6
-	const Sysseteuid	: scno = 0x20000b7
-	const Syssigreturn	: scno = 0x20000b8
-	const Syschud		: scno = 0x20000b9
-	const Sysfdatasync	: scno = 0x20000bb
-	const Sysstat		: scno = 0x20000bc
-	const Sysfstat		: scno = 0x20000bd
-	const Syslstat		: scno = 0x20000be
-	const Syspathconf	: scno = 0x20000bf
-	const Sysfpathconf	: scno = 0x20000c0
-	const Sysgetrlimit	: scno = 0x20000c2
-	const Syssetrlimit	: scno = 0x20000c3
-	const Sysgetdirentries	: scno = 0x20000c4
-	const Sysmmap		: scno = 0x20000c5
-	const Syslseek		: scno = 0x20000c7
-	const Systruncate	: scno = 0x20000c8
-	const Sysftruncate	: scno = 0x20000c9
-	const Sys__sysctl	: scno = 0x20000ca
-	const Sysmlock		: scno = 0x20000cb
-	const Sysmunlock	: scno = 0x20000cc
-	const Sysundelete	: scno = 0x20000cd
-	const SysATsocket	: scno = 0x20000ce
-	const SysATgetmsg	: scno = 0x20000cf
-	const SysATputmsg	: scno = 0x20000d0
-	const SysATPsndreq	: scno = 0x20000d1
-	const SysATPsndrsp	: scno = 0x20000d2
-	const SysATPgetreq	: scno = 0x20000d3
-	const SysATPgetrsp	: scno = 0x20000d4
-	const Sysmkcomplex	: scno = 0x20000d8
-	const Sysstatv		: scno = 0x20000d9
-	const Syslstatv		: scno = 0x20000da
-	const Sysfstatv		: scno = 0x20000db
-	const Sysgetattrlist	: scno = 0x20000dc
-	const Syssetattrlist	: scno = 0x20000dd
-	const Sysgetdirentriesattr	: scno = 0x20000de
-	const Sysexchangedata	: scno = 0x20000df
-	const Syssearchfs	: scno = 0x20000e1
-	const Sysdelete		: scno = 0x20000e2
-	const Syscopyfile	: scno = 0x20000e3
-	const Sysfgetattrlist	: scno = 0x20000e4
-	const Sysfsetattrlist	: scno = 0x20000e5
-	const Syspoll		: scno = 0x20000e6
-	const Syswatchevent	: scno = 0x20000e7
-	const Syswaitevent	: scno = 0x20000e8
-	const Sysmodwatch	: scno = 0x20000e9
-	const Sysgetxattr	: scno = 0x20000ea
-	const Sysfgetxattr	: scno = 0x20000eb
-	const Syssetxattr	: scno = 0x20000ec
-	const Sysfsetxattr	: scno = 0x20000ed
-	const Sysremovexattr	: scno = 0x20000ee
-	const Sysfremovexattr	: scno = 0x20000ef
-	const Syslistxattr	: scno = 0x20000f0
-	const Sysflistxattr	: scno = 0x20000f1
-	const Sysfsctl		: scno = 0x20000f2
-	const Sysinitgroups	: scno = 0x20000f3
-	const Sysposix_spawn	: scno = 0x20000f4
-	const Sysffsctl		: scno = 0x20000f5
-	const Sysnfsclnt	: scno = 0x20000f7
-	const Sysfhopen		: scno = 0x20000f8
-	const Sysminherit	: scno = 0x20000fa
-	const Syssemsys		: scno = 0x20000fb
-	const Sysmsgsys		: scno = 0x20000fc
-	const Sysshmsys		: scno = 0x20000fd
-	const Syssemctl		: scno = 0x20000fe
-	const Syssemget		: scno = 0x20000ff
-	const Syssemop		: scno = 0x2000100
-	const Sysmsgctl		: scno = 0x2000102
-	const Sysmsgget		: scno = 0x2000103
-	const Sysmsgsnd		: scno = 0x2000104
-	const Sysmsgrcv		: scno = 0x2000105
-	const Sysshmat		: scno = 0x2000106
-	const Sysshmctl		: scno = 0x2000107
-	const Sysshmdt		: scno = 0x2000108
-	const Sysshmget		: scno = 0x2000109
-	const Sysshm_open	: scno = 0x200010a
-	const Sysshm_unlink	: scno = 0x200010b
-	const Syssem_open	: scno = 0x200010c
-	const Syssem_close	: scno = 0x200010d
-	const Syssem_unlink	: scno = 0x200010e
-	const Syssem_wait	: scno = 0x200010f
-	const Syssem_trywait	: scno = 0x2000110
-	const Syssem_post	: scno = 0x2000111
-	const Syssem_getvalue	: scno = 0x2000112
-	const Syssem_init	: scno = 0x2000113
-	const Syssem_destroy	: scno = 0x2000114
-	const Sysopen_extended	: scno = 0x2000115
-	const Sysumask_extended	: scno = 0x2000116
-	const Sysstat_extended	: scno = 0x2000117
-	const Syslstat_extended	: scno = 0x2000118
-	const Sysfstat_extended	: scno = 0x2000119
-	const Syschmod_extended	: scno = 0x200011a
-	const Sysfchmod_extended	: scno = 0x200011b
-	const Sysaccess_extended	: scno = 0x200011c
-	const Syssettid		: scno = 0x200011d
-	const Sysgettid		: scno = 0x200011e
-	const Syssetsgroups	: scno = 0x200011f
-	const Sysgetsgroups	: scno = 0x2000120
-	const Syssetwgroups	: scno = 0x2000121
-	const Sysgetwgroups	: scno = 0x2000122
-	const Sysmkfifo_extended	: scno = 0x2000123
-	const Sysmkdir_extended	: scno = 0x2000124
-	const Sysidentitysvc	: scno = 0x2000125
-	const Sysshared_region_check_np	: scno = 0x2000126
-	const Sysshared_region_map_np	: scno = 0x2000127
-	const Sysvm_pressure_monitor	: scno = 0x2000128
-	const Syspsynch_rw_longrdlock	: scno = 0x2000129
-	const Syspsynch_rw_yieldwrlock	: scno = 0x200012a
-	const Syspsynch_rw_downgrade	: scno = 0x200012b
-	const Syspsynch_rw_upgrade	: scno = 0x200012c
-	const Syspsynch_mutexwait	: scno = 0x200012d
-	const Syspsynch_mutexdrop	: scno = 0x200012e
-	const Syspsynch_cvbroad	: scno = 0x200012f
-	const Syspsynch_cvsignal	: scno = 0x2000130
-	const Syspsynch_cvwait	: scno = 0x2000131
-	const Syspsynch_rw_rdlock	: scno = 0x2000132
-	const Syspsynch_rw_wrlock	: scno = 0x2000133
-	const Syspsynch_rw_unlock	: scno = 0x2000134
-	const Syspsynch_rw_unlock2	: scno = 0x2000135
-	const Sysgetsid		: scno = 0x2000136
-	const Syssettid_with_pid	: scno = 0x2000137
-	const Sysaio_fsync	: scno = 0x2000139
-	const Sysaio_return	: scno = 0x200013a
-	const Sysaio_suspend	: scno = 0x200013b
-	const Sysaio_cancel	: scno = 0x200013c
-	const Sysaio_error	: scno = 0x200013d
-	const Sysaio_read	: scno = 0x200013e
-	const Sysaio_write	: scno = 0x200013f
-	const Syslio_listio	: scno = 0x2000140
-	const Sysiopolicysys	: scno = 0x2000142
-	const Sysmlockall	: scno = 0x2000144
-	const Sysmunlockall	: scno = 0x2000145
-	const Sysissetugid	: scno = 0x2000147
-	const Sys__pthread_kill	: scno = 0x2000148
-	const Sys__pthread_sigmask	: scno = 0x2000149
-	const Sys__sigwait	: scno = 0x200014a
-	const Sys__disable_threadsignal	: scno = 0x200014b
-	const Sys__pthread_markcancel	: scno = 0x200014c
-	const Sys__pthread_canceled	: scno = 0x200014d
-	const Sys__semwait_signal	: scno = 0x200014e
-	const Sysproc_info	: scno = 0x2000150
-	const Syssendfile	: scno = 0x2000151
-	const Sysstat64		: scno = 0x2000152
-	const Sysfstat64	: scno = 0x2000153
-	const Syslstat64	: scno = 0x2000154
-	const Sysstat64_extended	: scno = 0x2000155
-	const Syslstat64_extended	: scno = 0x2000156
-	const Sysfstat64_extended	: scno = 0x2000157
-	const Sysgetdirentries64	: scno = 0x2000158
-	const Sysstatfs64	: scno = 0x2000159
-	const Sysfstatfs64	: scno = 0x200015a
-	const Sysgetfsstat64	: scno = 0x200015b
-	const Sys__pthread_chdir	: scno = 0x200015c
-	const Sys__pthread_fchdir	: scno = 0x200015d
-	const Sysaudit		: scno = 0x200015e
-	const Sysauditon	: scno = 0x200015f
-	const Sysgetauid	: scno = 0x2000161
-	const Syssetauid	: scno = 0x2000162
-	const Sysgetaudit	: scno = 0x2000163
-	const Syssetaudit	: scno = 0x2000164
-	const Sysgetaudit_addr	: scno = 0x2000165
-	const Syssetaudit_addr	: scno = 0x2000166
-	const Sysauditctl	: scno = 0x2000167
-	const Sysbsdthread_create	: scno = 0x2000168
-	const Sysbsdthread_terminate	: scno = 0x2000169
-	const Syskqueue		: scno = 0x200016a
-	const Syskevent		: scno = 0x200016b
-	const Syslchown		: scno = 0x200016c
-	const Sysstack_snapshot	: scno = 0x200016d
-	const Sysbsdthread_register	: scno = 0x200016e
-	const Sysworkq_open	: scno = 0x200016f
-	const Sysworkq_kernreturn	: scno = 0x2000170
-	const Syskevent64	: scno = 0x2000171
-	const Sys__old_semwait_signal	: scno = 0x2000172
-	const Sys__old_semwait_signal_nocancel	: scno = 0x2000173
-	const Systhread_selfid	: scno = 0x2000174
-	const Sys__mac_execve	: scno = 0x200017c
-	const Sys__mac_syscall	: scno = 0x200017d
-	const Sys__mac_get_file	: scno = 0x200017e
-	const Sys__mac_set_file	: scno = 0x200017f
-	const Sys__mac_get_link	: scno = 0x2000180
-	const Sys__mac_set_link	: scno = 0x2000181
-	const Sys__mac_get_proc	: scno = 0x2000182
-	const Sys__mac_set_proc	: scno = 0x2000183
-	const Sys__mac_get_fd	: scno = 0x2000184
-	const Sys__mac_set_fd	: scno = 0x2000185
-	const Sys__mac_get_pid	: scno = 0x2000186
-	const Sys__mac_get_lcid	: scno = 0x2000187
-	const Sys__mac_get_lctx	: scno = 0x2000188
-	const Sys__mac_set_lctx	: scno = 0x2000189
-	const Syssetlcid	: scno = 0x200018a
-	const Sysgetlcid	: scno = 0x200018b
-	const Sysread_nocancel	: scno = 0x200018c
-	const Syswrite_nocancel	: scno = 0x200018d
-	const Sysopen_nocancel	: scno = 0x200018e
-	const Sysclose_nocancel	: scno = 0x200018f
-	const Syswait4_nocancel	: scno = 0x2000190
-	const Sysrecvmsg_nocancel	: scno = 0x2000191
-	const Syssendmsg_nocancel	: scno = 0x2000192
-	const Sysrecvfrom_nocancel	: scno = 0x2000193
-	const Sysaccept_nocancel	: scno = 0x2000194
-	const Sysmsync_nocancel		: scno = 0x2000195
-	const Sysfcntl_nocancel		: scno = 0x2000196
-	const Sysselect_nocancel	: scno = 0x2000197
-	const Sysfsync_nocancel		: scno = 0x2000198
-	const Sysconnect_nocancel	: scno = 0x2000199
-	const Syssigsuspend_nocancel	: scno = 0x200019a
-	const Sysreadv_nocancel		: scno = 0x200019b
-	const Syswritev_nocancel	: scno = 0x200019c
-	const Syssendto_nocancel	: scno = 0x200019d
-	const Syspread_nocancel		: scno = 0x200019e
-	const Syspwrite_nocancel	: scno = 0x200019f
-	const Syswaitid_nocancel	: scno = 0x20001a0
-	const Syspoll_nocancel		: scno = 0x20001a1
-	const Sysmsgsnd_nocancel	: scno = 0x20001a2
-	const Sysmsgrcv_nocancel	: scno = 0x20001a3
-	const Syssem_wait_nocancel	: scno = 0x20001a4
-	const Sysaio_suspend_nocancel	: scno = 0x20001a5
-	const Sys__sigwait_nocancel	: scno = 0x20001a6
-	const Sys__semwait_signal_nocancel	: scno = 0x20001a7
-	const Sys__mac_mount		: scno = 0x20001a8
-	const Sys__mac_get_mount	: scno = 0x20001a9
-	const Sys__mac_getfsstat	: scno = 0x20001aa
-	const Sysfsgetpath		: scno = 0x20001ab
-	const Sysaudit_session_self	: scno = 0x20001ac
-	const Sysaudit_session_join	: scno = 0x20001ad
-	const Syspid_suspend		: scno = 0x20001ae
-	const Syspid_resume		: scno = 0x20001af
-	const Sysfileport_makeport	: scno = 0x20001b0
-	const Sysfileport_makefd	: scno = 0x20001b1
-
-	extern const syscall : (sc:scno, args:... -> int64)
-
-	/* process control */
-	const exit	: (status:int -> void)
-	const getpid	: ( -> pid)
-	const kill	: (pid : pid, sig:int64 -> int64)
-	const fork	: (-> pid)
-	const wait4	: (pid : pid, loc:int32#, opt : int64, rusage:rusage#	-> int64)
-	const waitpid	: (pid : pid, loc:int32#, opt : int64	-> int64)
-	const execv	: (cmd : byte[:], args : byte[:][:] -> int64)
-	const execve	: (cmd : byte[:], args : byte[:][:], env : byte[:][:] -> int64)
-
-	/* file manipulation */
-	const open	: (path:byte[:], opts:fdopt -> fd)
-	const openmode	: (path:byte[:], opts:fdopt, mode:int64 -> fd)
-	const close	: (fd:fd -> int64)
-	const creat	: (path:byte[:], mode:int64 -> fd)
-	const unlink	: (path:byte[:] -> int)
-	const read	: (fd:fd, buf:byte[:] -> size)
-	const write	: (fd:fd, buf:byte[:] -> size)
-	const lseek	: (fd:fd, off:uint64, whence:int64 -> int64)
-	const stat	: (path:byte[:], sb:statbuf# -> int64)
-	const lstat	: (path:byte[:], sb:statbuf# -> int64)
-	const fstat	: (fd:fd, sb:statbuf# -> int64)
-	const mkdir	: (path : byte[:], mode : int64	-> int64)
-	const ioctl	: (fd:fd, req : int64, args:... -> int64)
-	const getdirentries64	: (fd : fd, buf : byte[:], basep : int64# -> int64)
-	const chdir	: (p : byte[:] -> int64)
-
-	/* fd stuff */
-	const pipe	: (fd : fd[:] -> int64)
-	const dup	: (fd : fd -> fd)
-	const dup2	: (src : fd, dst : fd -> fd)
-
-	/* kqueue */
-	const kqueue	: (-> fd)
-	const kevent	: (q : fd, cl : kevent[:], el : kevent[:], flg : kflags, timeout : timespec# -> int64)
-	const kevent64	: (q : fd, cl : kevent64[:], el : kevent64[:], flg : kflags, timeout : timespec# -> int64)
-
-
-
-	/* networking */
-	const socket	: (dom : sockfam, stype : socktype, proto : sockproto	-> fd)
-	const connect	: (sock	: fd, addr : sockaddr#, len : size -> int)
-	const accept	: (sock : fd, addr : sockaddr#, len : size# -> fd)
-	const listen	: (sock : fd, backlog : int	-> int)
-	const bind	: (sock : fd, addr : sockaddr#, len : size -> int)
-
-
-	/* memory mapping */
-	const munmap	: (addr:byte#, len:size -> int64)
-	const mmap	: (addr:byte#, len:size, prot:mprot, flags:mopt, fd:fd, off:off -> byte#)
-
-	/* time */
-	const gettimeofday	: (tv : timeval#, tz : timezone# -> int)
-	const settimeofday	: (tv : timeval#, tz : timezone# -> int)
-	/* faked with gettimeofday */
-	const clock_getres	: (clk : clock, ts : timespec# -> int)
-	const clock_gettime	: (clk : clock, ts : timespec# -> int)
-	const clock_settime	: (clk : clock, ts : timespec# -> int)
-
-	/* system information */
-	const uname 	: (buf : utsname# -> int)
-	const sysctl	: (mib : int[:], old : byte[:]#, new : byte[:] -> int)
-;;
-
-/*
-wraps a syscall argument, converting it to 64 bits for the syscall function. This is
-the same as casting, but more concise than writing castto(int64)
-*/
-generic a = {x : @t
-	-> x castto(uint64)
-}
-
-/* OSX has a number of funky syscalls */
-extern const __osx_fork	: (-> pid)
-extern const __osx_pipe : (fd : fd# -> int64)
-extern const __osx_getpid	: (-> pid)
-extern const __osx_lseek	: (fd:fd, off:uint64, whence:int64 -> int64)
-extern const __osx_gettimeofday	: (tv : timeval#, tz : timezone# -> int)
-/*
-extern const __osx_ptrace
-extern const __osx_signalstack
-extern const __osx_sigreturn
-extern const __osx_thread_selfid
-extern const __osx_vfork
-*/
-
-extern const cstring : (str : byte[:] -> byte#)
-extern const alloca : (sz : size -> byte#)
-extern const __cenvp : byte##
-
-/* process control */
-const exit	= {status;		syscall(Sysexit, a(status))}
-const getpid	= {;			-> syscall(Sysgetpid) castto(pid)}
-const kill	= {pid, sig;		-> syscall(Syskill, a(pid), a(sig))}
-const fork	= {;			-> __osx_fork()}
-const wait4	= {pid, loc, opt, rusage;	-> syscall(Syswait4, a(pid), a(loc), a(opt), a(rusage))}
-const waitpid	= {pid, loc, opt;
-	-> wait4(pid, loc, opt, 0 castto(rusage#))
-}
-
-const execv	= {cmd, args
-	var p, cargs, i
-
-	/* doesn't just call execve() for efficiency's sake. */
-	p = alloca((args.len + 1)*sizeof(byte#))
-	cargs = (p castto(byte##))[:args.len + 1]
-	for i = 0; i < args.len; i++
-		cargs[i] = cstring(args[i])
-	;;
-	cargs[args.len] = 0 castto(byte#)
-	-> syscall(Sysexecve, cstring(cmd), a(p), a(__cenvp))
-}
-
-const execve	= {cmd, args, env
-	var cargs, cenv, i
-	var p
-
-	/* copy the args */
-	p = alloca((args.len + 1)*sizeof(byte#))
-	cargs = (p castto(byte##))[:args.len + 1]
-	for i = 0; i < args.len; i++
-		cargs[i] = cstring(args[i])
-	;;
-	cargs[args.len] = 0 castto(byte#)
-
-	/*
-	 copy the env.
-	 of course we fucking have to duplicate this code everywhere,
-	 since we want to stack allocate...
-	*/
-	p = alloca((env.len + 1)*sizeof(byte#))
-	cenv = (p castto(byte##))[:env.len]
-	for i = 0; i < env.len; i++
-		cenv[i] = cstring(env[i])
-	;;
-	cenv[env.len] = 0 castto(byte#)
-
-	-> syscall(Sysexecve, cstring(cmd), a(p), a(cenv))
-}
-
-
-/* fd manipulation */
-const open	= {path, opts;		-> syscall(Sysopen, cstring(path), a(opts), a(0o777)) castto(fd)}
-const openmode	= {path, opts, mode;	-> syscall(Sysopen, cstring(path), a(opts), a(mode)) castto(fd)}
-const close	= {fd;			-> syscall(Sysclose, a(fd))}
-const creat	= {path, mode;		-> openmode(path, Ocreat | Otrunc | Owronly, mode) castto(fd)}
-const unlink	= {path;		-> syscall(Sysunlink, cstring(path)) castto(int)}
-const read	= {fd, buf;		-> syscall(Sysread, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
-const write	= {fd, buf;		-> syscall(Syswrite, a(fd), buf castto(byte#), a(buf.len)) castto(size)}
-const lseek	= {fd, off, whence;	-> syscall(Syslseek, a(fd), a(off), a(whence))}
-const stat	= {path, sb;		-> syscall(Sysstat64, cstring(path), a(sb))}
-const lstat	= {path, sb;		-> syscall(Syslstat64, cstring(path), a(sb))}
-const fstat	= {fd, sb;		-> syscall(Sysfstat64, a(fd), a(sb))}
-const mkdir	= {path, mode;		-> syscall(Sysmkdir, cstring(path), a(mode)) castto(int64)}
-const ioctl	= {fd, req, args
-	var arg : byte#
-	var ap
-
-	ap = vastart(&args)
-	(arg, ap) = vanext(ap)
-	-> syscall(Sysioctl, a(fd), a(req), a(arg)) castto(int64)
-}
-const getdirentries64	= {fd, buf, basep;	-> syscall(Sysgetdirentries64, a(fd), buf castto(byte#), a(buf.len), a(basep))}
-const chdir	= {dir;	-> syscall(Syschdir, dir)}
-
-/* fd stuff */
-const pipe	= {fd;	-> __osx_pipe(fd castto(fd#))}
-const dup 	= {fd;	-> syscall(Sysdup, a(fd)) castto(fd)}
-const dup2 	= {src, dst;	-> syscall(Sysdup2, a(src), a(dst)) castto(fd)}
-
-/* kqueueueueueueue */
-const kqueue	= {;	-> syscall(Syskqueue) castto(fd)}
-const kevent	= {q, cl, el, flg, timeout
-	-> syscall(Syskevent, a(q), \
-		cl castto(kevent#), a(cl.len), \
-		el castto(kevent#), a(el.len), \
-		a(flg), \
-		timeout)
-}
-
-const kevent64	= {q, cl, el, flg, timeout
-	-> syscall(Syskevent, a(q), \
-		cl castto(kevent#), a(cl.len), \
-		el castto(kevent#), a(el.len), \
-		a(flg), \
-		timeout)
-}
-
-/* networking */
-const socket	= {dom, stype, proto;	-> syscall(Syssocket, a(dom), a(stype), a(proto)) castto(fd) }
-const connect	= {sock, addr, len;	-> syscall(Sysconnect, a(sock), a(addr), a(len)) castto(int)}
-const accept	= {sock, addr, len;	-> syscall(Sysaccept, a(sock), a(addr), a(len)) castto(fd)}
-const listen	= {sock, backlog;	-> syscall(Syslisten, a(sock), a(backlog)) castto(int)}
-const bind	= {sock, addr, len;	-> syscall(Sysbind, a(sock), a(addr), a(len)) castto(int)}
-
-/* memory management */
-const munmap	= {addr, len;		-> syscall(Sysmunmap, a(addr), a(len))}
-const mmap	= {addr, len, prot, flags, fd, off;
-	-> syscall(Sysmmap, a(addr), a(len), a(prot), a(flags), a(fd), a(off)) castto(byte#)}
-
-/* time */
-const gettimeofday = {tv, tz;	-> __osx_gettimeofday(tv, tz) castto(int)}
-const settimeofday = {tv, tz;	-> syscall(Syssettimeofday, a(tv), a(tz)) castto(int)}
-
-/* faked  with gettimeofday */
-const clock_getres = {clk, ts
-	ts.sec = 0
-	ts.nsec = 1000*10 /* 10ms is reasonable resolution */
-	-> 0
-}
-
-const clock_gettime = {clk, ts
-	var tv
-	var ret
-
-	ret = gettimeofday(&tv, 0 castto(timezone#))
-	ts.sec = tv.sec
-	ts.nsec = tv.usec * 1000
-	-> ret
-}
-
-const clock_settime = {clk, ts
-	var tv
-
-	tv.sec = ts.sec
-	tv.usec = ts.nsec / 1000
-	-> settimeofday(&tv, 0 castto(timezone#))
-}
-
-/* system information */
-const uname	= {buf;
-	var mib : int[2]
-	var ret
-	var sys
-	var nod
-	var rel
-	var ver
-	var mach
-
-	ret = 0
-	mib[0] = 1 /* CTL_KERN */
-	mib[1] = 1 /* KERN_OSTYPE */
-	sys = buf.system[:]
-	ret = sysctl(mib[:], &sys, [][:])
-	if ret < 0
-		-> ret
-	;;
-
-	mib[0] = 1 /* CTL_KERN */
-	mib[1] = 10 /* KERN_HOSTNAME */
-	nod = buf.node[:]
-	ret = sysctl(mib[:], &nod, [][:])
-	if ret < 0
-		-> ret
-	;;
-
-	mib[0] = 1 /* CTL_KERN */
-	mib[1] = 2 /* KERN_OSRELEASE */
-	rel = buf.release[:]
-	ret = sysctl(mib[:], &rel, [][:])
-	if ret < 0
-		-> ret
-	;;
-
-	mib[0] = 1 /* CTL_KERN */
-	mib[1] = 4 /* KERN_VERSION */
-	ver = buf.version[:]
-	ret = sysctl(mib[:], &ver, [][:])
-	if ret < 0
-		-> ret
-	;;
-
-	mib[0] = 6 /* CTL_HW */
-	mib[1] = 1 /* HW_MACHINE */
-	mach = buf.machine[:]
-	ret = sysctl(mib[:], &mach, [][:])
-	if ret < 0
-		-> ret
-	;;
-
-	-> 0
-}
-
-const sysctl = {mib, old, new
-	var mibp
-	var mibsz
-	var o
-	var oldp
-	var oldsz
-	var newp
-	var newsz
-	var ret
-
-	mibp = mib castto(byte#)
-	mibsz = mib.len castto(uint64)
-	o = old#
-	oldp = o castto(byte#)
-	oldsz = (o.len castto(uint64))
-	if new.len > 0
-		newp = new castto(byte#)
-		newsz = new.len castto(uint64)
-	else
-		newp = 0 castto(byte#)
-		newsz = 0
-	;;
-
-	ret = syscall(Sys__sysctl, a(mibp), a(mibsz), a(oldp), a(&oldsz), a(newp), a(newsz)) castto(int)
-
-	old# = o[:oldsz]
-	-> ret
-}
--- /dev/null
+++ b/libstd/syscall+freebsd.s
@@ -1,0 +1,39 @@
+.globl std$syscall
+std$syscall:
+	pushq %rbp 
+	pushq %rdi 
+	pushq %rsi 
+	pushq %rdx 
+	pushq %r10 
+	pushq %r8
+	pushq %r9
+	pushq %rcx 
+	pushq %r11 
+	/*
+	hack: We load 6 args regardless of
+	how many we actually have. This may
+	load junk values, but if the syscall
+	doesn't use them, it's going to be
+	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
+
+	syscall
+
+	popq %r11
+	popq %rcx
+	popq %r9
+	popq %r8
+	popq %r10
+	popq %rdx
+	popq %rsi
+	popq %rdi
+	popq %rbp
+	ret
+
--- /dev/null
+++ b/libstd/syscall+linux.s
@@ -1,0 +1,39 @@
+.globl std$syscall
+std$syscall:
+	pushq %rbp 
+	pushq %rdi 
+	pushq %rsi 
+	pushq %rdx 
+	pushq %r10 
+	pushq %r8
+	pushq %r9
+	pushq %rcx 
+	pushq %r11 
+	/*
+	hack: We load 6 args regardless of
+	how many we actually have. This may
+	load junk values, but if the syscall
+	doesn't use them, it's going to be
+	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
+
+	syscall
+
+	popq %r11
+	popq %rcx
+	popq %r9
+	popq %r8
+	popq %r10
+	popq %rdx
+	popq %rsi
+	popq %rdi
+	popq %rbp
+	ret
+
--- /dev/null
+++ b/libstd/syscall+osx.s
@@ -1,0 +1,160 @@
+.globl _std$syscall
+_std$syscall:
+	pushq %rbp 
+	pushq %rdi 
+	pushq %rsi 
+	pushq %rdx 
+	pushq %r10 
+	pushq %r8
+	pushq %r9
+	pushq %rcx 
+	pushq %r11 
+	/*
+	hack: We load 6 args regardless of
+	how many we actually have. This may
+	load junk values, but if the syscall
+	doesn't use them, it's going to be
+	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
+
+	syscall
+	jae .success
+	negq %rax
+
+.success:
+	popq %r11
+	popq %rcx
+	popq %r9
+	popq %r8
+	popq %r10
+	popq %rdx
+	popq %rsi
+	popq %rdi
+	popq %rbp
+	ret
+
+/*
+ * OSX is strange about fork, and needs an assembly wrapper.
+ * The fork() syscall, when called directly, returns the pid in both
+ * processes, which means that both parent and child think they're
+ * the parent.
+ *
+ * checking this involves peeking in %edx, so we need to do this in asm.
+ */
+.globl _std$__osx_fork
+_std$__osx_fork:
+	pushq %rbp
+	pushq %rdi 
+	pushq %rsi 
+	pushq %rdx 
+	pushq %r10 
+	pushq %r8
+	pushq %r9
+	pushq %rcx 
+	pushq %r11 
+
+	movq $0x2000002,%rax
+	syscall
+
+	jae .forksuccess
+	negq %rax
+
+.forksuccess:
+	testl %edx,%edx
+	jz .isparent
+	xorq %rax,%rax
+.isparent:
+
+	popq %r11 
+	popq %rcx 
+	popq %r9
+	popq %r8
+	popq %r10 
+	popq %rdx 
+	popq %rsi 
+	popq %rdi 
+	popq %rbp
+	ret
+
+/*
+ * OSX is strange about pipe, and needs an assembly wrapper.
+ * The pipe() syscall returns the pipes created in eax:edx, and
+ * needs to copy them to the destination locations manually.
+ */
+.globl _std$__osx_pipe
+_std$__osx_pipe:
+	pushq %rbp
+	pushq %rdi 
+	pushq %rsi 
+	pushq %rdx 
+	pushq %r10 
+	pushq %r8
+	pushq %r9
+	pushq %rcx 
+	pushq %r11 
+
+	movq $0x200002a,%rax
+	syscall
+
+	jae .pipesuccess
+	negq %rax
+
+.pipesuccess:
+	movq 80(%rsp),%rdi
+	movl %eax,(%rdi)
+	movl %edx,4(%rdi)
+	xorq %rax,%rax
+
+	popq %r11 
+	popq %rcx 
+	popq %r9
+	popq %r8
+	popq %r10 
+	popq %rdx 
+	popq %rsi 
+	popq %rdi 
+	popq %rbp
+	ret
+
+.globl _std$__osx_gettimeofday
+_std$__osx_gettimeofday:
+	pushq %rbp
+	pushq %rdi 
+	pushq %rsi 
+	pushq %rdx 
+	pushq %r10 
+	pushq %r8
+	pushq %r9
+	pushq %rcx 
+	pushq %r11 
+
+	movq $0x2000074,%rax
+	syscall
+
+	jae .gettimeofdaysuccess
+	negq %rax
+
+.gettimeofdaysuccess:
+	movq 80(%rsp),%rdi
+	movq %rax, (%rdi)
+	movl %edx,8(%rdi)
+	xorq %rax,%rax
+
+	popq %r11 
+	popq %rcx 
+	popq %r9
+	popq %r8
+	popq %r10 
+	popq %rdx 
+	popq %rsi 
+	popq %rdi 
+	popq %rbp
+	ret
+
--- a/libstd/syscall-freebsd.s
+++ /dev/null
@@ -1,39 +1,0 @@
-.globl std$syscall
-std$syscall:
-	pushq %rbp 
-	pushq %rdi 
-	pushq %rsi 
-	pushq %rdx 
-	pushq %r10 
-	pushq %r8
-	pushq %r9
-	pushq %rcx 
-	pushq %r11 
-	/*
-	hack: We load 6 args regardless of
-	how many we actually have. This may
-	load junk values, but if the syscall
-	doesn't use them, it's going to be
-	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
-
-	syscall
-
-	popq %r11
-	popq %rcx
-	popq %r9
-	popq %r8
-	popq %r10
-	popq %rdx
-	popq %rsi
-	popq %rdi
-	popq %rbp
-	ret
-
--- a/libstd/syscall-linux.s
+++ /dev/null
@@ -1,39 +1,0 @@
-.globl std$syscall
-std$syscall:
-	pushq %rbp 
-	pushq %rdi 
-	pushq %rsi 
-	pushq %rdx 
-	pushq %r10 
-	pushq %r8
-	pushq %r9
-	pushq %rcx 
-	pushq %r11 
-	/*
-	hack: We load 6 args regardless of
-	how many we actually have. This may
-	load junk values, but if the syscall
-	doesn't use them, it's going to be
-	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
-
-	syscall
-
-	popq %r11
-	popq %rcx
-	popq %r9
-	popq %r8
-	popq %r10
-	popq %rdx
-	popq %rsi
-	popq %rdi
-	popq %rbp
-	ret
-
--- a/libstd/syscall-osx.s
+++ /dev/null
@@ -1,160 +1,0 @@
-.globl _std$syscall
-_std$syscall:
-	pushq %rbp 
-	pushq %rdi 
-	pushq %rsi 
-	pushq %rdx 
-	pushq %r10 
-	pushq %r8
-	pushq %r9
-	pushq %rcx 
-	pushq %r11 
-	/*
-	hack: We load 6 args regardless of
-	how many we actually have. This may
-	load junk values, but if the syscall
-	doesn't use them, it's going to be
-	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
-
-	syscall
-	jae .success
-	negq %rax
-
-.success:
-	popq %r11
-	popq %rcx
-	popq %r9
-	popq %r8
-	popq %r10
-	popq %rdx
-	popq %rsi
-	popq %rdi
-	popq %rbp
-	ret
-
-/*
- * OSX is strange about fork, and needs an assembly wrapper.
- * The fork() syscall, when called directly, returns the pid in both
- * processes, which means that both parent and child think they're
- * the parent.
- *
- * checking this involves peeking in %edx, so we need to do this in asm.
- */
-.globl _std$__osx_fork
-_std$__osx_fork:
-	pushq %rbp
-	pushq %rdi 
-	pushq %rsi 
-	pushq %rdx 
-	pushq %r10 
-	pushq %r8
-	pushq %r9
-	pushq %rcx 
-	pushq %r11 
-
-	movq $0x2000002,%rax
-	syscall
-
-	jae .forksuccess
-	negq %rax
-
-.forksuccess:
-	testl %edx,%edx
-	jz .isparent
-	xorq %rax,%rax
-.isparent:
-
-	popq %r11 
-	popq %rcx 
-	popq %r9
-	popq %r8
-	popq %r10 
-	popq %rdx 
-	popq %rsi 
-	popq %rdi 
-	popq %rbp
-	ret
-
-/*
- * OSX is strange about pipe, and needs an assembly wrapper.
- * The pipe() syscall returns the pipes created in eax:edx, and
- * needs to copy them to the destination locations manually.
- */
-.globl _std$__osx_pipe
-_std$__osx_pipe:
-	pushq %rbp
-	pushq %rdi 
-	pushq %rsi 
-	pushq %rdx 
-	pushq %r10 
-	pushq %r8
-	pushq %r9
-	pushq %rcx 
-	pushq %r11 
-
-	movq $0x200002a,%rax
-	syscall
-
-	jae .pipesuccess
-	negq %rax
-
-.pipesuccess:
-	movq 80(%rsp),%rdi
-	movl %eax,(%rdi)
-	movl %edx,4(%rdi)
-	xorq %rax,%rax
-
-	popq %r11 
-	popq %rcx 
-	popq %r9
-	popq %r8
-	popq %r10 
-	popq %rdx 
-	popq %rsi 
-	popq %rdi 
-	popq %rbp
-	ret
-
-.globl _std$__osx_gettimeofday
-_std$__osx_gettimeofday:
-	pushq %rbp
-	pushq %rdi 
-	pushq %rsi 
-	pushq %rdx 
-	pushq %r10 
-	pushq %r8
-	pushq %r9
-	pushq %rcx 
-	pushq %r11 
-
-	movq $0x2000074,%rax
-	syscall
-
-	jae .gettimeofdaysuccess
-	negq %rax
-
-.gettimeofdaysuccess:
-	movq 80(%rsp),%rdi
-	movq %rax, (%rdi)
-	movl %edx,8(%rdi)
-	xorq %rax,%rax
-
-	popq %r11 
-	popq %rcx 
-	popq %r9
-	popq %r8
-	popq %r10 
-	popq %rdx 
-	popq %rsi 
-	popq %rdi 
-	popq %rbp
-	ret
-
--- /dev/null
+++ b/libstd/waitstatus+freebsd.myr
@@ -1,0 +1,20 @@
+use "die.use"
+
+pkg std =
+	type waitstatus = union
+		`Waitexit int32
+		`Waitsig  int32
+		`Waitstop int32
+	;;
+
+	const waitstatus	: (st : int32 -> waitstatus)
+;;
+
+const waitstatus = {st
+	match st & 0o177
+	| 0:	-> `Waitexit (st >> 8)
+	| 0x7f:-> `Waitstop (st >> 8)
+	| sig: 	-> `Waitsig sig
+	;;
+	die("unreachable")
+}
--- /dev/null
+++ b/libstd/waitstatus+linux.myr
@@ -1,0 +1,22 @@
+use "die.use"
+pkg std =
+	type waitstatus = union
+		`Waitexit int32
+		`Waitsig  int32
+		`Waitstop int32
+	;;
+
+	const waitstatus	: (st : int32 -> waitstatus)
+;;
+
+const waitstatus = {st
+	if st & 0x7f == 0 /* if exited */
+		-> `Waitexit ((st & 0xff00) >> 8)
+	elif ((st & 0xffff)-1) < 0xff /* if signaled */
+		-> `Waitsig ((st) & 0x7f)
+	elif (((st & 0xffff)*0x10001)>>8) > 0x7f00
+		-> `Waitstop ((st & 0xff00) >> 8)
+	;;
+	die("unreachable")
+}
+
--- /dev/null
+++ b/libstd/waitstatus+osx.myr
@@ -1,0 +1,19 @@
+use "die.use"
+pkg std =
+	type waitstatus = union
+		`Waitexit int32
+		`Waitsig  int32
+		`Waitstop int32
+	;;
+
+	const waitstatus	: (st : int32 -> waitstatus)
+;;
+
+const waitstatus = {st
+	match st & 0o177
+	| 0:	-> `Waitexit (st >> 8)
+	| 0o177:-> `Waitstop (st >> 8)
+	| sig: 	-> `Waitsig sig
+	;;
+	die("unreachable")
+}
--- a/libstd/waitstatus-freebsd.myr
+++ /dev/null
@@ -1,20 +1,0 @@
-use "die.use"
-
-pkg std =
-	type waitstatus = union
-		`Waitexit int32
-		`Waitsig  int32
-		`Waitstop int32
-	;;
-
-	const waitstatus	: (st : int32 -> waitstatus)
-;;
-
-const waitstatus = {st
-	match st & 0o177
-	| 0:	-> `Waitexit (st >> 8)
-	| 0x7f:-> `Waitstop (st >> 8)
-	| sig: 	-> `Waitsig sig
-	;;
-	die("unreachable")
-}
--- a/libstd/waitstatus-linux.myr
+++ /dev/null
@@ -1,22 +1,0 @@
-use "die.use"
-pkg std =
-	type waitstatus = union
-		`Waitexit int32
-		`Waitsig  int32
-		`Waitstop int32
-	;;
-
-	const waitstatus	: (st : int32 -> waitstatus)
-;;
-
-const waitstatus = {st
-	if st & 0x7f == 0 /* if exited */
-		-> `Waitexit ((st & 0xff00) >> 8)
-	elif ((st & 0xffff)-1) < 0xff /* if signaled */
-		-> `Waitsig ((st) & 0x7f)
-	elif (((st & 0xffff)*0x10001)>>8) > 0x7f00
-		-> `Waitstop ((st & 0xff00) >> 8)
-	;;
-	die("unreachable")
-}
-
--- a/libstd/waitstatus-osx.myr
+++ /dev/null
@@ -1,19 +1,0 @@
-use "die.use"
-pkg std =
-	type waitstatus = union
-		`Waitexit int32
-		`Waitsig  int32
-		`Waitstop int32
-	;;
-
-	const waitstatus	: (st : int32 -> waitstatus)
-;;
-
-const waitstatus = {st
-	match st & 0o177
-	| 0:	-> `Waitexit (st >> 8)
-	| 0o177:-> `Waitstop (st >> 8)
-	| sig: 	-> `Waitsig sig
-	;;
-	die("unreachable")
-}