move src/syscall to src/lib/syscall.
enforce rule: all kernel data structures and constants
	go in syscall module.
move things that should be in syscall out of net.
make net a single package.

R=r
OCL=15985
CL=15994
diff --git a/src/lib/syscall/Makefile b/src/lib/syscall/Makefile
new file mode 100644
index 0000000..8564854
--- /dev/null
+++ b/src/lib/syscall/Makefile
@@ -0,0 +1,58 @@
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+# DO NOT EDIT.  Automatically generated by gobuild.
+# gobuild -m syscall errstr_darwin.go file_darwin.go socket_darwin.go\
+#    syscall_amd64_darwin.go time_amd64_darwin.go types_amd64_darwin.go\
+#    asm_amd64_darwin.s cast_amd64.s syscall.go
+O=6
+GC=$(O)g
+CC=$(O)c -w
+AS=$(O)a
+AR=$(O)ar
+
+PKG=$(GOROOT)/pkg/syscall.a
+
+install: $(PKG)
+
+nuke: clean
+	rm -f $(PKG)
+
+clean:
+	rm -f *.$O *.a
+
+%.$O: %.go
+	$(GC) $*.go
+
+%.$O: %.c
+	$(CC) $*.c
+
+%.$O: %.s
+	$(AS) $*.s
+
+
+O1=\
+	errstr_$(GOOS).$O\
+	syscall_$(GOARCH)_$(GOOS).$O\
+	types_$(GOARCH)_$(GOOS).$O\
+	asm_$(GOARCH)_$(GOOS).$O\
+	cast_$(GOARCH).$O\
+	syscall.$O\
+
+O2=\
+	file_$(GOOS).$O\
+	socket_$(GOOS).$O\
+	time_$(GOARCH)_$(GOOS).$O\
+
+$(PKG): a1 a2
+a1:	$(O1)
+	$(AR) grc $(PKG) $(O1)
+	rm -f $(O1)
+a2:	$(O2)
+	$(AR) grc $(PKG) $(O2)
+	rm -f $(O2)
+
+$(O1): nuke
+$(O2): a1
+
diff --git a/src/lib/syscall/asm_amd64_darwin.s b/src/lib/syscall/asm_amd64_darwin.s
new file mode 100644
index 0000000..64b74db
--- /dev/null
+++ b/src/lib/syscall/asm_amd64_darwin.s
@@ -0,0 +1,48 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//
+// System call support for AMD64, Darwin
+//
+
+// func Syscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64);
+// func Syscall6(trap int64, a1, a2, a3, a4, a5, a6 int64) (r1, r2, err int64);
+// Trap # in AX, args in DI SI DX, return in AX DX
+
+TEXT	syscall·Syscall(SB),7,$0
+	MOVQ	16(SP), DI
+	MOVQ	24(SP), SI
+	MOVQ	32(SP), DX
+	MOVQ	8(SP), AX	// syscall entry
+	ADDQ	$0x2000000, AX
+	SYSCALL
+	JCC	5(PC)
+	MOVQ	$-1, 40(SP)	// r1
+	MOVQ	$0, 48(SP)	// r2
+	MOVQ	AX, 56(SP)  // errno
+	RET
+	MOVQ	AX, 40(SP)	// r1
+	MOVQ	DX, 48(SP)	// r2
+	MOVQ	$0, 56(SP)	// errno
+	RET
+
+TEXT	syscall·Syscall6(SB),7,$0
+	MOVQ	16(SP), DI
+	MOVQ	24(SP), SI
+	MOVQ	32(SP), DX
+	MOVQ	40(SP), R10
+	MOVQ	48(SP), R8
+	MOVQ	56(SP), R9
+	MOVQ	8(SP), AX	// syscall entry
+	ADDQ	$0x2000000, AX
+	SYSCALL
+	JCC	5(PC)
+	MOVQ	$-1, 64(SP)	// r1
+	MOVQ	$0, 72(SP)	// r2
+	MOVQ	AX, 80(SP)  // errno
+	RET
+	MOVQ	AX, 64(SP)	// r1
+	MOVQ	DX, 72(SP)	// r2
+	MOVQ	$0, 80(SP)	// errno
+	RET
diff --git a/src/lib/syscall/asm_amd64_linux.s b/src/lib/syscall/asm_amd64_linux.s
new file mode 100644
index 0000000..4863033
--- /dev/null
+++ b/src/lib/syscall/asm_amd64_linux.s
@@ -0,0 +1,50 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//
+// System calls for AMD64, Linux
+//
+
+// func Syscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64);
+// Trap # in AX, args in DI SI DX R10 R8 R9, return in AX DX
+// Note that this differs from "standard" ABI convention, which
+// would pass 4th arg in CX, not R10.
+
+TEXT	syscall·Syscall(SB),7,$-8
+	MOVQ	16(SP), DI
+	MOVQ	24(SP), SI
+	MOVQ	32(SP), DX
+	MOVQ	8(SP), AX	// syscall entry
+	SYSCALL
+	CMPQ	AX, $0xfffffffffffff001
+	JLS	6(PC)
+	MOVQ	$-1, 40(SP)	// r1
+	MOVQ	$0, 48(SP)	// r2
+	NEGQ	AX
+	MOVQ	AX, 56(SP)  // errno
+	RET
+	MOVQ	AX, 40(SP)	// r1
+	MOVQ	DX, 48(SP)	// r2
+	MOVQ	$0, 56(SP)	// errno
+	RET
+
+TEXT syscall·Syscall6(SB),7,$-8
+	MOVQ	16(SP), DI
+	MOVQ	24(SP), SI
+	MOVQ	32(SP), DX
+	MOVQ	40(SP), R10
+	MOVQ	48(SP), R8
+	MOVQ	56(SP), R9
+	MOVQ	8(SP), AX	// syscall entry
+	SYSCALL
+	JLS	6(PC)
+	MOVQ	$-1, 64(SP)	// r1
+	MOVQ	$0, 72(SP)	// r2
+	NEGQ	AX
+	MOVQ	AX, 80(SP)  // errno
+	RET
+	MOVQ	AX, 64(SP)	// r1
+	MOVQ	DX, 72(SP)	// r2
+	MOVQ	$0, 80(SP)	// errno
+	RET
diff --git a/src/lib/syscall/cast_amd64.s b/src/lib/syscall/cast_amd64.s
new file mode 100644
index 0000000..d0447d6
--- /dev/null
+++ b/src/lib/syscall/cast_amd64.s
@@ -0,0 +1,70 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// conversion operators - really just casts
+TEXT	syscall·BytePtr(SB),7,$-8
+	MOVQ	8(SP), AX
+	MOVQ	AX, 16(SP)
+	RET
+
+TEXT	syscall·Int32Ptr(SB),7,$-8
+	MOVQ	8(SP), AX
+	MOVQ	AX, 16(SP)
+	RET
+
+TEXT	syscall·Int64Ptr(SB),7,$-8
+	MOVQ	8(SP), AX
+	MOVQ	AX, 16(SP)
+	RET
+
+TEXT	syscall·KeventPtr(SB),7,$-8
+	MOVQ	8(SP), AX
+	MOVQ	AX, 16(SP)
+	RET
+
+TEXT	syscall·LingerPtr(SB),7,$-8
+	MOVQ	8(SP), AX
+	MOVQ	AX, 16(SP)
+	RET
+
+TEXT	syscall·SockaddrPtr(SB),7,$-8
+	MOVQ	8(SP), AX
+	MOVQ	AX, 16(SP)
+	RET
+
+TEXT	syscall·StatPtr(SB),7,$-8
+	MOVQ	8(SP), AX
+	MOVQ	AX, 16(SP)
+	RET
+
+TEXT	syscall·TimespecPtr(SB),7,$-8
+	MOVQ	8(SP), AX
+	MOVQ	AX, 16(SP)
+	RET
+
+TEXT	syscall·TimevalPtr(SB),7,$-8
+	MOVQ	8(SP), AX
+	MOVQ	AX, 16(SP)
+	RET
+
+TEXT	syscall·SockaddrToSockaddrInet4(SB),7,$-8
+	MOVQ	8(SP), AX
+	MOVQ	AX, 16(SP)
+	RET
+
+TEXT	syscall·SockaddrToSockaddrInet6(SB),7,$-8
+	MOVQ	8(SP), AX
+	MOVQ	AX, 16(SP)
+	RET
+
+TEXT	syscall·SockaddrInet4ToSockaddr(SB),7,$-8
+	MOVQ	8(SP), AX
+	MOVQ	AX, 16(SP)
+	RET
+
+TEXT	syscall·SockaddrInet6ToSockaddr(SB),7,$-8
+	MOVQ	8(SP), AX
+	MOVQ	AX, 16(SP)
+	RET
+
diff --git a/src/lib/syscall/errstr_darwin.go b/src/lib/syscall/errstr_darwin.go
new file mode 100644
index 0000000..65c5255
--- /dev/null
+++ b/src/lib/syscall/errstr_darwin.go
@@ -0,0 +1,242 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+export const (
+	ENONE=0;
+	EPERM=1;
+	ENOENT=2;
+	ESRCH=3;
+	EINTR=4;
+	EIO=5;
+	ENXIO=6;
+	E2BIG=7;
+	ENOEXEC=8;
+	EBADF=9;
+	ECHILD=10;
+	EDEADLK=11;
+	ENOMEM=12;
+	EACCES=13;
+	EFAULT=14;
+	ENOTBLK=15;
+	EBUSY=16;
+	EEXIST=17;
+	EXDEV=18;
+	ENODEV=19;
+	ENOTDIR=20;
+	EISDIR=21;
+	EINVAL=22;
+	ENFILE=23;
+	EMFILE=24;
+	ENOTTY=25;
+	ETXTBSY=26;
+	EFBIG=27;
+	ENOSPC=28;
+	ESPIPE=29;
+	EROFS=30;
+	EMLINK=31;
+	EPIPE=32;
+	EDOM=33;
+	ERANGE=34;
+	EAGAIN=35;
+	EINPROGRESS=36;
+	EALREADY=37;
+	ENOTSOCK=38;
+	EDESTADDRREQ=39;
+	EMSGSIZE=40;
+	EPROTOTYPE=41;
+	ENOPROTOOPT=42;
+	EPROTONOSUPPORT=43;
+	ESOCKTNOSUPPORT=44;
+	ENOTSUP=45;
+	EPFNOSUPPORT=46;
+	EAFNOSUPPORT=47;
+	EADDRINUSE=48;
+	EADDRNOTAVAIL=49;
+	ENETDOWN=50;
+	ENETUNREACH=51;
+	ENETRESET=52;
+	ECONNABORTED=53;
+	ECONNRESET=54;
+	ENOBUFS=55;
+	EISCONN=56;
+	ENOTCONN=57;
+	ESHUTDOWN=58;
+	ETOOMANYREFS=59;
+	ETIMEDOUT=60;
+	ECONNREFUSED=61;
+	ELOOP=62;
+	ENAMETOOLONG=63;
+	EHOSTDOWN=64;
+	EHOSTUNREACH=65;
+	ENOTEMPTY=66;
+	EPROCLIM=67;
+	EUSERS=68;
+	EDQUOT=69;
+	ESTALE=70;
+	EREMOTE=71;
+	EBADRPC=72;
+	ERPCMISMATCH=73;
+	EPROGUNAVAIL=74;
+	EPROGMISMATCH=75;
+	EPROCUNAVAIL=76;
+	ENOLCK=77;
+	ENOSYS=78;
+	EFTYPE=79;
+	EAUTH=80;
+	ENEEDAUTH=81;
+	EPWROFF=82;
+	EDEVERR=83;
+	EOVERFLOW=84;
+	EBADEXEC=85;
+	EBADARCH=86;
+	ESHLIBVERS=87;
+	EBADMACHO=88;
+	ECANCELED=89;
+	EIDRM=90;
+	ENOMSG=91;
+	EILSEQ=92;
+	ENOATTR=93;
+	EBADMSG=94;
+	EMULTIHOP=95;
+	ENODATA=96;
+	ENOLINK=97;
+	ENOSR=98;
+	ENOSTR=99;
+	EPROTO=100;
+	ETIME=101;
+	EOPNOTSUPP=102;
+	ELAST=103;
+)
+
+var error [ELAST]string;
+
+func init(){
+	error[ENONE] = "No error"; 
+	error[EPERM] = "Operation not permitted"; 
+	error[ENOENT] = "No such file or directory"; 
+	error[ESRCH] = "No such process"; 
+	error[EINTR] = "Interrupted system call"; 
+	error[EIO] = "Input/output error"; 
+	error[ENXIO] = "Device not configured"; 
+	error[E2BIG] = "Argument list too long"; 
+	error[ENOEXEC] = "Exec format error"; 
+	error[EBADF] = "Bad file descriptor"; 
+	error[ECHILD] = "No child processes"; 
+	error[EDEADLK] = "Resource deadlock avoided"; 
+	error[ENOMEM] = "Cannot allocate memory"; 
+	error[EACCES] = "Permission denied"; 
+	error[EFAULT] = "Bad address"; 
+	error[ENOTBLK] = "Block device required"; 
+	error[EBUSY] = "Device / Resource busy"; 
+	error[EEXIST] = "File exists"; 
+	error[EXDEV] = "Cross-device link"; 
+	error[ENODEV] = "Operation not supported by device"; 
+	error[ENOTDIR] = "Not a directory"; 
+	error[EISDIR] = "Is a directory"; 
+	error[EINVAL] = "Invalid argument"; 
+	error[ENFILE] = "Too many open files in system"; 
+	error[EMFILE] = "Too many open files"; 
+	error[ENOTTY] = "Inappropriate ioctl for device"; 
+	error[ETXTBSY] = "Text file busy"; 
+	error[EFBIG] = "File too large"; 
+	error[ENOSPC] = "No space left on device"; 
+	error[ESPIPE] = "Illegal seek"; 
+	error[EROFS] = "Read-only file system"; 
+	error[EMLINK] = "Too many links"; 
+	error[EPIPE] = "Broken pipe"; 
+	error[EDOM] = "Numerical argument out of domain"; 
+	error[ERANGE] = "Result too large"; 
+	error[EAGAIN] = "Resource temporarily unavailable"; 
+	error[EINPROGRESS] = "Operation now in progress"; 
+	error[EALREADY] = "Operation already in progress"; 
+	error[ENOTSOCK] = "Socket operation on non-socket"; 
+	error[EDESTADDRREQ] = "Destination address required"; 
+	error[EMSGSIZE] = "Message too long"; 
+	error[EPROTOTYPE] = "Protocol wrong type for socket"; 
+	error[ENOPROTOOPT] = "Protocol not available"; 
+	error[EPROTONOSUPPORT] = "Protocol not supported"; 
+	error[ESOCKTNOSUPPORT] = "Socket type not supported"; 
+	error[ENOTSUP] = "Operation not supported"; 
+	error[EPFNOSUPPORT] = "Protocol family not supported"; 
+	error[EAFNOSUPPORT] = "Address family not supported by protocol family"; 
+	error[EADDRINUSE] = "Address already in use"; 
+	error[EADDRNOTAVAIL] = "Can't assign requested address"; 
+	error[ENETDOWN] = "Network is down"; 
+	error[ENETUNREACH] = "Network is unreachable"; 
+	error[ENETRESET] = "Network dropped connection on reset"; 
+	error[ECONNABORTED] = "Software caused connection abort"; 
+	error[ECONNRESET] = "Connection reset by peer"; 
+	error[ENOBUFS] = "No buffer space available"; 
+	error[EISCONN] = "Socket is already connected"; 
+	error[ENOTCONN] = "Socket is not connected"; 
+	error[ESHUTDOWN] = "Can't send after socket shutdown"; 
+	error[ETOOMANYREFS] = "Too many references: can't splice"; 
+	error[ETIMEDOUT] = "Operation timed out"; 
+	error[ECONNREFUSED] = "Connection refused"; 
+	error[ELOOP] = "Too many levels of symbolic links"; 
+	error[ENAMETOOLONG] = "File name too long"; 
+	error[EHOSTDOWN] = "Host is down"; 
+	error[EHOSTUNREACH] = "No route to host"; 
+	error[ENOTEMPTY] = "Directory not empty"; 
+	error[EPROCLIM] = "Too many processes"; 
+	error[EUSERS] = "Too many users"; 
+	error[EDQUOT] = "Disc quota exceeded"; 
+	error[ESTALE] = "Stale NFS file handle"; 
+	error[EREMOTE] = "Too many levels of remote in path"; 
+	error[EBADRPC] = "RPC struct is bad"; 
+	error[ERPCMISMATCH] = "RPC version wrong"; 
+	error[EPROGUNAVAIL] = "RPC prog. not avail"; 
+	error[EPROGMISMATCH] = "Program version wrong"; 
+	error[EPROCUNAVAIL] = "Bad procedure for program"; 
+	error[ENOLCK] = "No locks available"; 
+	error[ENOSYS] = "Function not implemented"; 
+	error[EFTYPE] = "Inappropriate file type or format"; 
+	error[EAUTH] = "Authentication error"; 
+	error[ENEEDAUTH] = "Need authenticator"; 
+	error[EPWROFF] = "Device power is off"; 
+	error[EDEVERR] = "Device error, e.g. paper out"; 
+	error[EOVERFLOW] = "Value too large to be stored in data type"; 
+	error[EBADEXEC] = "Bad executable"; 
+	error[EBADARCH] = "Bad CPU type in executable"; 
+	error[ESHLIBVERS] = "Shared library version mismatch"; 
+	error[EBADMACHO] = "Malformed Macho file"; 
+	error[ECANCELED] = "Operation canceled"; 
+	error[EIDRM] = "Identifier removed"; 
+	error[ENOMSG] = "No message of desired type"; 
+	error[EILSEQ] = "Illegal byte sequence"; 
+	error[ENOATTR] = "Attribute not found"; 
+	error[EBADMSG] = "Bad message"; 
+	error[EMULTIHOP] = "Reserved"; 
+	error[ENODATA] = "No message available on STREAM"; 
+	error[ENOLINK] = "Reserved"; 
+	error[ENOSR] = "No STREAM resources"; 
+	error[ENOSTR] = "Not a STREAM"; 
+	error[EPROTO] = "Protocol error"; 
+	error[ETIME] = "STREAM ioctl timeout"; 
+	error[EOPNOTSUPP] = "Operation not supported on socket"; 
+}
+
+func str(val int64) string {  // do it here rather than with fmt to avoid dependency
+	if val < 0 {
+		return "-" + str(-val);
+	}
+	var buf [32]byte;  // big enough for int64
+	i := len(buf)-1;
+	for val >= 10 {
+		buf[i] = byte(val%10 + '0');
+		i--;
+		val /= 10;
+	}
+	buf[i] = byte(val + '0');
+	return string(buf)[i:len(buf)];
+}
+
+export func errstr(errno int64) string {
+	if errno < 0 || errno >= len(error) {
+		return "Error " + str(errno)
+	}
+	return error[errno]
+}
diff --git a/src/lib/syscall/errstr_linux.go b/src/lib/syscall/errstr_linux.go
new file mode 100644
index 0000000..20b46f2
--- /dev/null
+++ b/src/lib/syscall/errstr_linux.go
@@ -0,0 +1,292 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+export const (
+	ENONE=0;
+	EPERM=1;
+	ENOENT=2;
+	ESRCH=3;
+	EINTR=4;
+	EIO=5;
+	ENXIO=6;
+	E2BIG=7;
+	ENOEXEC=8;
+	EBADF=9;
+	ECHILD=10;
+	EAGAIN=11;
+	ENOMEM=12;
+	EACCES=13;
+	EFAULT=14;
+	ENOTBLK=15;
+	EBUSY=16;
+	EEXIST=17;
+	EXDEV=18;
+	ENODEV=19;
+	ENOTDIR=20;
+	EISDIR=21;
+	EINVAL=22;
+	ENFILE=23;
+	EMFILE=24;
+	ENOTTY=25;
+	ETXTBSY=26;
+	EFBIG=27;
+	ENOSPC=28;
+	ESPIPE=29;
+	EROFS=30;
+	EMLINK=31;
+	EPIPE=32;
+	EDOM=33;
+	ERANGE=34;
+	EDEADLK=35;
+	ENAMETOOLONG=36;
+	ENOLCK=37;
+	ENOSYS=38;
+	ENOTEMPTY=39;
+	ELOOP=40;
+	ENOMSG=42;
+	EIDRM=43;
+	ECHRNG=44;
+	EL2NSYNC=45;
+	EL3HLT=46;
+	EL3RST=47;
+	ELNRNG=48;
+	EUNATCH=49;
+	ENOCSI=50;
+	EL2HLT=51;
+	EBADE=52;
+	EBADR=53;
+	EXFULL=54;
+	ENOANO=55;
+	EBADRQC=56;
+	EBADSLT=57;
+	EBFONT=59;
+	ENOSTR=60;
+	ENODATA=61;
+	ETIME=62;
+	ENOSR=63;
+	ENONET=64;
+	ENOPKG=65;
+	EREMOTE=66;
+	ENOLINK=67;
+	EADV=68;
+	ESRMNT=69;
+	ECOMM=70;
+	EPROTO=71;
+	EMULTIHOP=72;
+	EDOTDOT=73;
+	EBADMSG=74;
+	EOVERFLOW=75;
+	ENOTUNIQ=76;
+	EBADFD=77;
+	EREMCHG=78;
+	ELIBACC=79;
+	ELIBBAD=80;
+	ELIBSCN=81;
+	ELIBMAX=82;
+	ELIBEXEC=83;
+	EILSEQ=84;
+	ERESTART=85;
+	ESTRPIPE=86;
+	EUSERS=87;
+	ENOTSOCK=88;
+	EDESTADDRREQ=89;
+	EMSGSIZE=90;
+	EPROTOTYPE=91;
+	ENOPROTOOPT=92;
+	EPROTONOSUPPORT=93;
+	ESOCKTNOSUPPORT=94;
+	EOPNOTSUPP=95;
+	EPFNOSUPPORT=96;
+	EAFNOSUPPORT=97;
+	EADDRINUSE=98;
+	EADDRNOTAVAIL=99;
+	ENETDOWN=100;
+	ENETUNREACH=101;
+	ENETRESET=102;
+	ECONNABORTED=103;
+	ECONNRESET=104;
+	ENOBUFS=105;
+	EISCONN=106;
+	ENOTCONN=107;
+	ESHUTDOWN=108;
+	ETOOMANYREFS=109;
+	ETIMEDOUT=110;
+	ECONNREFUSED=111;
+	EHOSTDOWN=112;
+	EHOSTUNREACH=113;
+	EALREADY=114;
+	EINPROGRESS=115;
+	ESTALE=116;
+	EUCLEAN=117;
+	ENOTNAM=118;
+	ENAVAIL=119;
+	EISNAM=120;
+	EREMOTEIO=121;
+	EDQUOT=122;
+	ENOMEDIUM=123;
+	EMEDIUMTYPE=124;
+	ECANCELED=125;
+	ENOKEY=126;
+	EKEYEXPIRED=127;
+	EKEYREVOKED=128;
+	EKEYREJECTED=129;
+	ELAST=130;
+)
+
+var error [ELAST]string;
+
+func init(){
+	error[ENONE] = "No error";
+	error[EPERM] = "Operation not permitted";
+	error[ENOENT] = "No such file or directory";
+	error[ESRCH] = "No such process";
+	error[EINTR] = "Interrupted system call";
+	error[EIO] = "I/O error";
+	error[ENXIO] = "No such device or address";
+	error[E2BIG] = "Argument list too long";
+	error[ENOEXEC] = "Exec format error";
+	error[EBADF] = "Bad file number";
+	error[ECHILD] = "No child processes";
+	error[EAGAIN] = "Try again";
+	error[ENOMEM] = "Out of memory";
+	error[EACCES] = "Permission denied";
+	error[EFAULT] = "Bad address";
+	error[ENOTBLK] = "Block device required";
+	error[EBUSY] = "Device or resource busy";
+	error[EEXIST] = "File exists";
+	error[EXDEV] = "Cross-device link";
+	error[ENODEV] = "No such device";
+	error[ENOTDIR] = "Not a directory";
+	error[EISDIR] = "Is a directory";
+	error[EINVAL] = "Invalid argument";
+	error[ENFILE] = "File table overflow";
+	error[EMFILE] = "Too many open files";
+	error[ENOTTY] = "Not a typewriter";
+	error[ETXTBSY] = "Text file busy";
+	error[EFBIG] = "File too large";
+	error[ENOSPC] = "No space left on device";
+	error[ESPIPE] = "Illegal seek";
+	error[EROFS] = "Read-only file system";
+	error[EMLINK] = "Too many links";
+	error[EPIPE] = "Broken pipe";
+	error[EDOM] = "Math argument out of domain of func";
+	error[ERANGE] = "Math result not representable";
+	error[EDEADLK] = "Resource deadlock would occur";
+	error[ENAMETOOLONG] = "File name too long";
+	error[ENOLCK] = "No record locks available";
+	error[ENOSYS] = "Function not implemented";
+	error[ENOTEMPTY] = "Directory not empty";
+	error[ELOOP] = "Too many symbolic links encountered";
+	error[ENOMSG] = "No message of desired type";
+	error[EIDRM] = "Identifier removed";
+	error[ECHRNG] = "Channel number out of range";
+	error[EL2NSYNC] = "Level 2 not synchronized";
+	error[EL3HLT] = "Level 3 halted";
+	error[EL3RST] = "Level 3 reset";
+	error[ELNRNG] = "Link number out of range";
+	error[EUNATCH] = "Protocol driver not attached";
+	error[ENOCSI] = "No CSI structure available";
+	error[EL2HLT] = "Level 2 halted";
+	error[EBADE] = "Invalid exchange";
+	error[EBADR] = "Invalid request descriptor";
+	error[EXFULL] = "Exchange full";
+	error[ENOANO] = "No anode";
+	error[EBADRQC] = "Invalid request code";
+	error[EBADSLT] = "Invalid slot";
+	error[EBFONT] = "Bad font file format";
+	error[ENOSTR] = "Device not a stream";
+	error[ENODATA] = "No data available";
+	error[ETIME] = "Timer expired";
+	error[ENOSR] = "Out of streams resources";
+	error[ENONET] = "Machine is not on the network";
+	error[ENOPKG] = "Package not installed";
+	error[EREMOTE] = "Object is remote";
+	error[ENOLINK] = "Link has been severed";
+	error[EADV] = "Advertise error";
+	error[ESRMNT] = "Srmount error";
+	error[ECOMM] = "Communication error on send";
+	error[EPROTO] = "Protocol error";
+	error[EMULTIHOP] = "Multihop attempted";
+	error[EDOTDOT] = "RFS specific error";
+	error[EBADMSG] = "Not a data message";
+	error[EOVERFLOW] = "Value too large for defined data type";
+	error[ENOTUNIQ] = "Name not unique on network";
+	error[EBADFD] = "File descriptor in bad state";
+	error[EREMCHG] = "Remote address changed";
+	error[ELIBACC] = "Can not access a needed shared library";
+	error[ELIBBAD] = "Accessing a corrupted shared library";
+	error[ELIBSCN] = ".lib section in a.out corrupted";
+	error[ELIBMAX] = "Attempting to link in too many shared libraries";
+	error[ELIBEXEC] = "Cannot exec a shared library directly";
+	error[EILSEQ] = "Illegal byte sequence";
+	error[ERESTART] = "Interrupted system call should be restarted";
+	error[ESTRPIPE] = "Streams pipe error";
+	error[EUSERS] = "Too many users";
+	error[ENOTSOCK] = "Socket operation on non-socket";
+	error[EDESTADDRREQ] = "Destination address required";
+	error[EMSGSIZE] = "Message too long";
+	error[EPROTOTYPE] = "Protocol wrong type for socket";
+	error[ENOPROTOOPT] = "Protocol not available";
+	error[EPROTONOSUPPORT] = "Protocol not supported";
+	error[ESOCKTNOSUPPORT] = "Socket type not supported";
+	error[EOPNOTSUPP] = "Operation not supported on transport endpoint";
+	error[EPFNOSUPPORT] = "Protocol family not supported";
+	error[EAFNOSUPPORT] = "Address family not supported by protocol";
+	error[EADDRINUSE] = "Address already in use";
+	error[EADDRNOTAVAIL] = "Cannot assign requested address";
+	error[ENETDOWN] = "Network is down";
+	error[ENETUNREACH] = "Network is unreachable";
+	error[ENETRESET] = "Network dropped connection because of reset";
+	error[ECONNABORTED] = "Software caused connection abort";
+	error[ECONNRESET] = "Connection reset by peer";
+	error[ENOBUFS] = "No buffer space available";
+	error[EISCONN] = "Transport endpoint is already connected";
+	error[ENOTCONN] = "Transport endpoint is not connected";
+	error[ESHUTDOWN] = "Cannot send after transport endpoint shutdown";
+	error[ETOOMANYREFS] = "Too many references: cannot splice";
+	error[ETIMEDOUT] = "Connection timed out";
+	error[ECONNREFUSED] = "Connection refused";
+	error[EHOSTDOWN] = "Host is down";
+	error[EHOSTUNREACH] = "No route to host";
+	error[EALREADY] = "Operation already in progress";
+	error[EINPROGRESS] = "Operation now in progress";
+	error[ESTALE] = "Stale NFS file handle";
+	error[EUCLEAN] = "Structure needs cleaning";
+	error[ENOTNAM] = "Not a XENIX named type file";
+	error[ENAVAIL] = "No XENIX semaphores available";
+	error[EISNAM] = "Is a named type file";
+	error[EREMOTEIO] = "Remote I/O error";
+	error[EDQUOT] = "Quota exceeded";
+	error[ENOMEDIUM] = "No medium found";
+	error[EMEDIUMTYPE] = "Wrong medium type";
+	error[ECANCELED] = "Operation Canceled";
+	error[ENOKEY] = "Required key not available";
+	error[EKEYEXPIRED] = "Key has expired";
+	error[EKEYREVOKED] = "Key has been revoked";
+	error[EKEYREJECTED] = "Key was rejected by service";
+}
+
+func str(val int64) string {  // do it here rather than with fmt to avoid dependency
+	if val < 0 {
+		return "-" + str(-val);
+	}
+	var buf [32]byte;  // big enough for int64
+	i := len(buf)-1;
+	for val >= 10 {
+		buf[i] = byte(val%10 + '0');
+		i--;
+		val /= 10;
+	}
+	buf[i] = byte(val + '0');
+	return string(buf)[i:len(buf)];
+}
+
+export func errstr(errno int64) string {
+	if errno < 0 || errno >= len(error) {
+		return "Error " + str(errno)
+	}
+	return error[errno]
+}
diff --git a/src/lib/syscall/file_darwin.go b/src/lib/syscall/file_darwin.go
new file mode 100644
index 0000000..c481b0d
--- /dev/null
+++ b/src/lib/syscall/file_darwin.go
@@ -0,0 +1,88 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+// File operations for Darwin
+
+import syscall "syscall"
+
+const NameBufsize = 512
+
+export func open(name string, mode int64, perm int64) (ret int64, errno int64) {
+	var namebuf [NameBufsize]byte;
+	if !StringToBytes(&namebuf, name) {
+		return -1, ENAMETOOLONG
+	}
+	r1, r2, err := Syscall(SYS_OPEN, BytePtr(&namebuf[0]), mode, perm);
+	return r1, err;
+}
+
+export func creat(name string, perm int64) (ret int64, errno int64) {
+	var namebuf [NameBufsize]byte;
+	if !StringToBytes(&namebuf, name) {
+		return -1, ENAMETOOLONG
+	}
+	r1, r2, err := Syscall(SYS_OPEN, BytePtr(&namebuf[0]), O_CREAT|O_WRONLY|O_TRUNC, perm);
+	return r1, err;
+}
+
+export func close(fd int64) (ret int64, errno int64) {
+	r1, r2, err := Syscall(SYS_CLOSE, fd, 0, 0);
+	return r1, err;
+}
+
+export func read(fd int64, buf *byte, nbytes int64) (ret int64, errno int64) {
+	r1, r2, err := Syscall(SYS_READ, fd, BytePtr(buf), nbytes);
+	return r1, err;
+}
+
+export func write(fd int64, buf *byte, nbytes int64) (ret int64, errno int64) {
+	r1, r2, err := Syscall(SYS_WRITE, fd, BytePtr(buf), nbytes);
+	return r1, err;
+}
+
+export func pipe(fds *[2]int64) (ret int64, errno int64) {
+	r1, r2, err := Syscall(SYS_PIPE, 0, 0, 0);
+	if r1 < 0 {
+		return r1, err;
+	}
+	fds[0] = r1;
+	fds[1] = r2;
+	return 0, 0;
+}
+
+export func stat(name string, buf *Stat) (ret int64, errno int64) {
+	var namebuf [NameBufsize]byte;
+	if !StringToBytes(&namebuf, name) {
+		return -1, ENAMETOOLONG
+	}
+	r1, r2, err := Syscall(SYS_STAT, BytePtr(&namebuf[0]), StatPtr(buf), 0);
+	return r1, err;
+}
+
+export func lstat(name *byte, buf *Stat) (ret int64, errno int64) {
+	r1, r2, err := Syscall(SYS_LSTAT, BytePtr(name), StatPtr(buf), 0);
+	return r1, err;
+}
+
+export func fstat(fd int64, buf *Stat) (ret int64, errno int64) {
+	r1, r2, err := Syscall(SYS_FSTAT, fd, StatPtr(buf), 0);
+	return r1, err;
+}
+
+export func unlink(name string) (ret int64, errno int64) {
+	var namebuf [NameBufsize]byte;
+	if !StringToBytes(&namebuf, name) {
+		return -1, ENAMETOOLONG
+	}
+	r1, r2, err := Syscall(SYS_UNLINK, BytePtr(&namebuf[0]), 0, 0);
+	return r1, err;
+}
+
+export func fcntl(fd, cmd, arg int64) (ret int64, errno int64) {
+	r1, r2, err := Syscall(SYS_FCNTL, fd, cmd, arg)
+	return r1, err
+}
+
diff --git a/src/lib/syscall/file_linux.go b/src/lib/syscall/file_linux.go
new file mode 100644
index 0000000..fdf690f
--- /dev/null
+++ b/src/lib/syscall/file_linux.go
@@ -0,0 +1,84 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+// File operations for Linux
+
+import syscall "syscall"
+
+const NameBufsize = 512
+
+export func open(name string, mode int64, perm int64) (ret int64, errno int64) {
+	var namebuf [NameBufsize]byte;
+	if !StringToBytes(&namebuf, name) {
+		return -1, ENAMETOOLONG
+	}
+	r1, r2, err := Syscall(SYS_OPEN, BytePtr(&namebuf[0]), mode, perm);
+	return r1, err;
+}
+
+export func creat(name string, perm int64) (ret int64, errno int64) {
+	var namebuf [NameBufsize]byte;
+	if !StringToBytes(&namebuf, name) {
+		return -1, ENAMETOOLONG
+	}
+	r1, r2, err := Syscall(SYS_OPEN, BytePtr(&namebuf[0]),  O_CREAT|O_WRONLY|O_TRUNC, perm);
+	return r1, err;
+}
+
+export func close(fd int64) (ret int64, errno int64) {
+	r1, r2, err := Syscall(SYS_CLOSE, fd, 0, 0);
+	return r1, err;
+}
+
+export func read(fd int64, buf *byte, nbytes int64) (ret int64, errno int64) {
+	r1, r2, err := Syscall(SYS_READ, fd, BytePtr(buf), nbytes);
+	return r1, err;
+}
+
+export func write(fd int64, buf *byte, nbytes int64) (ret int64, errno int64) {
+	r1, r2, err := Syscall(SYS_WRITE, fd, BytePtr(buf), nbytes);
+	return r1, err;
+}
+
+export func pipe(fds *[2]int64) (ret int64, errno int64) {
+	var t [2] int32;
+	r1, r2, err := Syscall(SYS_PIPE, Int32Ptr(&t[0]), 0, 0);
+	if r1 < 0 {
+		return r1, err;
+	}
+	fds[0] = int64(t[0]);
+	fds[1] = int64(t[1]);
+	return 0, 0;
+}
+
+export func stat(name string, buf *Stat) (ret int64, errno int64) {
+	var namebuf [NameBufsize]byte;
+	if !StringToBytes(&namebuf, name) {
+		return -1, ENAMETOOLONG
+	}
+	r1, r2, err := Syscall(SYS_STAT, BytePtr(&namebuf[0]), StatPtr(buf), 0);
+	return r1, err;
+}
+
+export func lstat(name *byte, buf *Stat) (ret int64, errno int64) {
+	r1, r2, err := Syscall(SYS_LSTAT, BytePtr(name), StatPtr(buf), 0);
+	return r1, err;
+}
+
+export func fstat(fd int64, buf *Stat) (ret int64, errno int64) {
+	r1, r2, err := Syscall(SYS_FSTAT, fd, StatPtr(buf), 0);
+	return r1, err;
+}
+
+export func unlink(name string) (ret int64, errno int64) {
+	var namebuf [NameBufsize]byte;
+	if !StringToBytes(&namebuf, name) {
+		return -1, ENAMETOOLONG
+	}
+	const SYSUNLINK = 87;
+	r1, r2, err := Syscall(SYS_UNLINK, BytePtr(&namebuf[0]), 0, 0);
+	return r1, err;
+}
diff --git a/src/lib/syscall/mkdarwin b/src/lib/syscall/mkdarwin
new file mode 100755
index 0000000..ca521ba
--- /dev/null
+++ b/src/lib/syscall/mkdarwin
@@ -0,0 +1,34 @@
+# Copyright 2009 The Go Authors.  All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+my $command = "mkdarwin " . join(' ', @ARGV);
+
+print <<EOF;
+// Generated by mkdarwin; DO NOT EDIT.
+// $command
+
+package syscall
+
+export const (
+EOF
+
+while(<>){
+	if(/^([0-9]+)\s+ALL\s+({ \S+\s+(\w+).*})/){
+		my $num = $1;
+		my $proto = $2;
+		my $name = "SYS_$3";
+		$name =~ y/a-z/A-Z/;
+
+		# There are multiple entries for nosys(), so comment them out.
+		if($name eq "SYS_NOSYS"){
+			$name = "// $name";
+		}
+
+		print "	$name = $num;  // $proto\n";
+	}
+}
+
+print <<EOF;
+)
+EOF
diff --git a/src/lib/syscall/mklinux b/src/lib/syscall/mklinux
new file mode 100755
index 0000000..f1b02fa
--- /dev/null
+++ b/src/lib/syscall/mklinux
@@ -0,0 +1,28 @@
+#!/usr/bin/perl
+# Copyright 2009 The Go Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style
+# license that can be found in the LICENSE file.
+
+my $command = "mklinux ". join(' ', @ARGV);
+
+print <<EOF;
+// Generated by mklinux; DO NOT EDIT.
+// $command
+
+package syscall
+
+export const(
+EOF
+
+while(<>){
+	if(/^#define __NR_(\w+)\s+([0-9]+)/){
+		my $name = "SYS_$1";
+		my $num = $2;
+		$name =~ y/a-z/A-Z/;
+		print "	$name = $num;\n";
+	}
+}
+
+print <<EOF;
+)
+EOF
diff --git a/src/lib/syscall/socket_darwin.go b/src/lib/syscall/socket_darwin.go
new file mode 100644
index 0000000..c8104da
--- /dev/null
+++ b/src/lib/syscall/socket_darwin.go
@@ -0,0 +1,109 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Low-level socket interface.
+// Only for implementing net package.
+// DO NOT USE DIRECTLY.
+
+package syscall
+import "syscall"
+
+export func SockaddrToSockaddrInet4(s *Sockaddr) *SockaddrInet4;
+export func SockaddrToSockaddrInet6(s *Sockaddr) *SockaddrInet6;
+export func SockaddrInet4ToSockaddr(s *SockaddrInet4) *Sockaddr;
+export func SockaddrInet6ToSockaddr(s *SockaddrInet6) *Sockaddr;
+
+export func socket(domain, proto, typ int64) (ret int64, err int64) {
+	r1, r2, e := Syscall(SYS_SOCKET, domain, proto, typ);
+	return r1, e
+}
+
+export func connect(fd int64, sa *Sockaddr) (ret int64, err int64) {
+	r1, r2, e := Syscall(SYS_CONNECT, fd, SockaddrPtr(sa), int64(sa.len));
+	return r1, e
+}
+
+export func bind(fd int64, sa *Sockaddr) (ret int64, err int64) {
+	r1, r2, e := Syscall(SYS_BIND, fd, SockaddrPtr(sa), int64(sa.len));
+	return r1, e
+}
+
+export func listen(fd, n int64) (ret int64, err int64) {
+	r1, r2, e := Syscall(SYS_LISTEN, fd, n, 0);
+	return r1, e
+}
+
+export func accept(fd int64, sa *Sockaddr) (ret int64, err int64) {
+	n := SizeofSockaddr;
+	r1, r2, e := Syscall(SYS_ACCEPT, fd, SockaddrPtr(sa), Int32Ptr(&n));
+	return r1, e
+}
+
+export func setsockopt(fd, level, opt, valueptr, length int64) (ret int64, err int64) {
+	if fd < 0 {
+		return -1, EINVAL
+	}
+	r1, r2, e := Syscall6(SYS_SETSOCKOPT, fd, level, opt, valueptr, length, 0);
+	return r1, e
+}
+
+export func setsockopt_int(fd, level, opt int64, value int) int64 {
+	n := int32(opt);
+	r1, e := setsockopt(fd, level, opt, Int32Ptr(&n), 4)
+	return e
+}
+
+export func setsockopt_tv(fd, level, opt, nsec int64) int64 {
+	var tv Timeval;
+	nsec += 999;
+	tv.sec = int64(nsec/1000000000);
+	tv.usec = uint32(nsec%1000000000);
+	r1, e := setsockopt(fd, level, opt, TimevalPtr(&tv), 4)
+	return e
+}
+
+export func setsockopt_linger(fd, level, opt int64, sec int) int64 {
+	var l Linger;
+	if sec != 0 {
+		l.yes = 1;
+		l.sec = sec
+	} else {
+		l.yes = 0;
+		l.sec = 0
+	}
+	r1, err := setsockopt(fd, level, opt, LingerPtr(&l), 8)
+	return err
+}
+
+/*
+export func getsockopt(fd, level, opt, valueptr, lenptr int64) (ret int64, errno int64) {
+	r1, r2, err := Syscall6(SYS_GETSOCKOPT, fd, level, opt, valueptr, lenptr, 0);
+	return r1, err;
+}
+*/
+
+export func kqueue() (ret int64, errno int64) {
+	r1, r2, err := Syscall(SYS_KQUEUE, 0, 0, 0);
+	return r1, err
+}
+
+export func kevent(kq int64, changes, events *[]Kevent, timeout *Timespec) (ret int64, errno int64) {
+	var nchange, changeptr, nevent, eventptr int64;
+	nchange = 0;
+	changeptr = 0;
+	nevent = 0;
+	eventptr = 0;
+	if changes != nil && len(changes) > 0 {
+		changeptr = KeventPtr(&changes[0]);
+		nchange = int64(len(changes))
+	}
+	if events != nil && len(events) > 0 {
+		eventptr = KeventPtr(&events[0]);
+		nevent = int64(len(events))
+	}
+	r1, r2, err := Syscall6(SYS_KEVENT, kq, changeptr, nchange,
+		eventptr, nevent, TimespecPtr(timeout));
+	return r1, err
+}
+
diff --git a/src/lib/syscall/socket_linux.go b/src/lib/syscall/socket_linux.go
new file mode 100644
index 0000000..b690e81
--- /dev/null
+++ b/src/lib/syscall/socket_linux.go
@@ -0,0 +1,99 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Low-level socket interface.
+// Only for implementing net package.
+// DO NOT USE DIRECTLY.
+
+package syscall
+import "syscall"
+
+export func SockaddrToSockaddrInet4(s *Sockaddr) *SockaddrInet4;
+export func SockaddrToSockaddrInet6(s *Sockaddr) *SockaddrInet6;
+export func SockaddrInet4ToSockaddr(s *SockaddrInet4) *Sockaddr;
+export func SockaddrInet6ToSockaddr(s *SockaddrInet6) *Sockaddr;
+
+func Len(s *Sockaddr) int64 {
+	switch s.family {
+	case AF_UNIX:
+		return SizeofSockaddrUnix
+	case AF_INET:
+		return SizeofSockaddrInet4
+	case AF_INET6:
+		return SizeofSockaddrInet6
+	}
+	return 0
+}
+
+export func socket(domain, proto, typ int64) (ret int64, err int64) {
+	r1, r2, e := Syscall(SYS_SOCKET, domain, proto, typ);
+	return r1, e
+}
+
+export func connect(fd int64, sa *Sockaddr) (ret int64, err int64) {
+	r1, r2, e := Syscall(SYS_CONNECT, fd, SockaddrPtr(sa), Len(sa));
+	return r1, e
+}
+
+export func bind(fd int64, sa *Sockaddr) (ret int64, err int64) {
+	r1, r2, e := Syscall(SYS_BIND, fd, SockaddrPtr(sa), Len(sa));
+	return r1, e
+}
+
+export func listen(fd, n int64) (ret int64, err int64) {
+	r1, r2, e := Syscall(SYS_LISTEN, fd, n, 0);
+	return r1, e
+}
+
+export func accept(fd int64, sa *Sockaddr) (ret int64, err int64) {
+	n := SizeofSockaddr;
+	r1, r2, e := Syscall(SYS_ACCEPT, fd, SockaddrPtr(sa), Int32Ptr(&n));
+	return r1, e
+}
+
+export func setsockopt(fd, level, opt, valueptr, length int64) (ret int64, err int64) {
+	if fd < 0 {
+		return -1, EINVAL
+	}
+	r1, r2, e := Syscall6(SYS_SETSOCKOPT, fd, level, opt, valueptr, length, 0);
+	return r1, e
+}
+
+export func setsockopt_int(fd, level, opt int64, value int) int64 {
+	n := int32(opt);
+	r1, e := setsockopt(fd, level, opt, Int32Ptr(&n), 4)
+	return e
+}
+
+export func setsockopt_tv(fd, level, opt, nsec int64) int64 {
+	var tv Timeval;
+	nsec += 999;
+	tv.sec = int64(nsec/1000000000);
+	tv.usec = uint64(nsec%1000000000);
+	r1, e := setsockopt(fd, level, opt, TimevalPtr(&tv), 4)
+	return e
+}
+
+export func setsockopt_linger(fd, level, opt int64, sec int) int64 {
+	var l Linger;
+	if sec != 0 {
+		l.yes = 1;
+		l.sec = sec
+	} else {
+		l.yes = 0;
+		l.sec = 0
+	}
+	r1, err := setsockopt(fd, level, opt, LingerPtr(&l), 8)
+	return err
+}
+
+/*
+export func getsockopt(fd, level, opt, valueptr, lenptr int64) (ret int64, errno int64) {
+	r1, r2, err := Syscall6(GETSOCKOPT, fd, level, opt, valueptr, lenptr, 0);
+	return r1, err;
+}
+*/
+
+// TODO: epoll
+
diff --git a/src/lib/syscall/syscall.go b/src/lib/syscall/syscall.go
new file mode 100644
index 0000000..6420684
--- /dev/null
+++ b/src/lib/syscall/syscall.go
@@ -0,0 +1,31 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+/*
+ * Foundation of system call interface.
+ */
+
+export func Syscall(trap int64, a1, a2, a3 int64) (r1, r2, err int64);
+export func Syscall6(trap int64, a1, a2, a3, a4, a5, a6 int64) (r1, r2, err int64);
+
+export func BytePtr(b *byte) int64;
+export func Int32Ptr(p *int32) int64;
+export func Int64Ptr(p *int64) int64;
+
+/*
+ * Used to convert file names to byte arrays for passing to kernel,
+ * but useful elsewhere too.
+ */
+export func StringToBytes(b *[]byte, s string) bool {
+	if len(s) >= len(b) {
+		return false
+	}
+	for i := 0; i < len(s); i++ {
+		b[i] = s[i]
+	}
+	b[len(s)] = '\000';	// not necessary - memory is zeroed - but be explicit
+	return true
+}
diff --git a/src/lib/syscall/syscall_amd64_darwin.go b/src/lib/syscall/syscall_amd64_darwin.go
new file mode 100644
index 0000000..76d1c46
--- /dev/null
+++ b/src/lib/syscall/syscall_amd64_darwin.go
@@ -0,0 +1,489 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Generated by mkdarwin; DO NOT EDIT.
+// mkdarwin /home/rsc/pub/xnu-1228/bsd/kern/syscalls.master
+
+package syscall
+
+export const (
+	// SYS_NOSYS = 0;  // { int nosys(void); }   { indirect syscall }
+	SYS_EXIT = 1;  // { void exit(int rval); }
+	SYS_FORK = 2;  // { int fork(void); }
+	SYS_READ = 3;  // { user_ssize_t read(int fd, user_addr_t cbuf, user_size_t nbyte); }
+	SYS_WRITE = 4;  // { user_ssize_t write(int fd, user_addr_t cbuf, user_size_t nbyte); }
+	SYS_OPEN = 5;  // { int open(user_addr_t path, int flags, int mode); }
+	SYS_CLOSE = 6;  // { int close(int fd); }
+	SYS_WAIT4 = 7;  // { int wait4(int pid, user_addr_t status, int options, user_addr_t rusage); }
+	// SYS_NOSYS = 8;  // { int nosys(void); }   { old creat }
+	SYS_LINK = 9;  // { int link(user_addr_t path, user_addr_t link); }
+	SYS_UNLINK = 10;  // { int unlink(user_addr_t path); }
+	// SYS_NOSYS = 11;  // { int nosys(void); }   { old execv }
+	SYS_CHDIR = 12;  // { int chdir(user_addr_t path); }
+	SYS_FCHDIR = 13;  // { int fchdir(int fd); }
+	SYS_MKNOD = 14;  // { int mknod(user_addr_t path, int mode, int dev); }
+	SYS_CHMOD = 15;  // { int chmod(user_addr_t path, int mode); }
+	SYS_CHOWN = 16;  // { int chown(user_addr_t path, int uid, int gid); }
+	SYS_OGETFSSTAT = 18;  // { int ogetfsstat(user_addr_t buf, int bufsize, int flags); }
+	SYS_GETFSSTAT = 18;  // { int getfsstat(user_addr_t buf, int bufsize, int flags); }
+	// SYS_NOSYS = 19;  // { int nosys(void); }   { old lseek }
+	SYS_GETPID = 20;  // { int getpid(void); }
+	// SYS_NOSYS = 21;  // { int nosys(void); }   { old mount }
+	// SYS_NOSYS = 22;  // { int nosys(void); }   { old umount }
+	SYS_SETUID = 23;  // { int setuid(uid_t uid); }
+	SYS_GETUID = 24;  // { int getuid(void); }
+	SYS_GETEUID = 25;  // { int geteuid(void); }
+	SYS_PTRACE = 26;  // { int ptrace(int req, pid_t pid, caddr_t addr, int data); }
+	SYS_RECVMSG = 27;  // { int recvmsg(int s, struct msghdr *msg, int flags); }
+	SYS_SENDMSG = 28;  // { int sendmsg(int s, caddr_t msg, int flags); }
+	SYS_RECVFROM = 29;  // { int recvfrom(int s, void *buf, size_t len, int flags, struct sockaddr *from, int *fromlenaddr); }
+	SYS_ACCEPT = 30;  // { int accept(int s, caddr_t name, socklen_t	*anamelen); }
+	SYS_GETPEERNAME = 31;  // { int getpeername(int fdes, caddr_t asa, socklen_t *alen); }
+	SYS_GETSOCKNAME = 32;  // { int getsockname(int fdes, caddr_t asa, socklen_t *alen); }
+	// SYS_NOSYS = 27;  // { int nosys(void); }
+	// SYS_NOSYS = 28;  // { int nosys(void); }
+	// SYS_NOSYS = 29;  // { int nosys(void); }
+	// SYS_NOSYS = 30;  // { int nosys(void); }
+	// SYS_NOSYS = 31;  // { int nosys(void); }
+	// SYS_NOSYS = 32;  // { int nosys(void); }
+	SYS_ACCESS = 33;  // { int access(user_addr_t path, int flags); }
+	SYS_CHFLAGS = 34;  // { int chflags(char *path, int flags); }
+	SYS_FCHFLAGS = 35;  // { int fchflags(int fd, int flags); }
+	SYS_SYNC = 36;  // { int sync(void); }
+	SYS_KILL = 37;  // { int kill(int pid, int signum, int posix); }
+	// SYS_NOSYS = 38;  // { int nosys(void); }   { old stat  }
+	SYS_GETPPID = 39;  // { int getppid(void); }
+	// SYS_NOSYS = 40;  // { int nosys(void); }   { old lstat }
+	SYS_DUP = 41;  // { int dup(u_int fd); }
+	SYS_PIPE = 42;  // { int pipe(void); }
+	SYS_GETEGID = 43;  // { int getegid(void); }
+	SYS_PROFIL = 44;  // { int profil(short *bufbase, size_t bufsize, u_long pcoffset, u_int pcscale); }
+	// SYS_NOSYS = 45;  // { int nosys(void); } { old ktrace }
+	SYS_SIGACTION = 46;  // { int sigaction(int signum, struct __sigaction *nsa, struct sigaction *osa); }
+	SYS_GETGID = 47;  // { int getgid(void); }
+	SYS_SIGPROCMASK = 48;  // { int sigprocmask(int how, user_addr_t mask, user_addr_t omask); }
+	SYS_GETLOGIN = 49;  // { int getlogin(char *namebuf, u_int namelen); }
+	SYS_SETLOGIN = 50;  // { int setlogin(char *namebuf); }
+	SYS_ACCT = 51;  // { int acct(char *path); }
+	SYS_SIGPENDING = 52;  // { int sigpending(struct sigvec *osv); }
+	SYS_SIGALTSTACK = 53;  // { int sigaltstack(struct sigaltstack *nss, struct sigaltstack *oss); }
+	SYS_IOCTL = 54;  // { int ioctl(int fd, u_long com, caddr_t data); }
+	SYS_REBOOT = 55;  // { int reboot(int opt, char *command); }
+	SYS_REVOKE = 56;  // { int revoke(char *path); }
+	SYS_SYMLINK = 57;  // { int symlink(char *path, char *link); }
+	SYS_READLINK = 58;  // { int readlink(char *path, char *buf, int count); }
+	SYS_EXECVE = 59;  // { int execve(char *fname, char **argp, char **envp); }
+	SYS_UMASK = 60;  // { int umask(int newmask); }
+	SYS_CHROOT = 61;  // { int chroot(user_addr_t path); }
+	// SYS_NOSYS = 62;  // { int nosys(void); }   { old fstat }
+	// SYS_NOSYS = 63;  // { int nosys(void); }   { used internally, reserved }
+	// SYS_NOSYS = 64;  // { int nosys(void); }   { old getpagesize }
+	SYS_MSYNC = 65;  // { int msync(caddr_t addr, size_t len, int flags); }
+	SYS_VFORK = 66;  // { int vfork(void); }
+	// SYS_NOSYS = 67;  // { int nosys(void); }   { old vread }
+	// SYS_NOSYS = 68;  // { int nosys(void); }   { old vwrite }
+	SYS_SBRK = 69;  // { int sbrk(int incr) NO_SYSCALL_STUB; }
+	SYS_SSTK = 70;  // { int sstk(int incr) NO_SYSCALL_STUB; }
+	// SYS_NOSYS = 71;  // { int nosys(void); }   { old mmap }
+	SYS_OVADVISE = 72;  // { int ovadvise(void) NO_SYSCALL_STUB; }   { old vadvise }
+	SYS_MUNMAP = 73;  // { int munmap(caddr_t addr, size_t len); }
+	SYS_MPROTECT = 74;  // { int mprotect(caddr_t addr, size_t len, int prot); }
+	SYS_MADVISE = 75;  // { int madvise(caddr_t addr, size_t len, int behav); }
+	// SYS_NOSYS = 76;  // { int nosys(void); }   { old vhangup }
+	// SYS_NOSYS = 77;  // { int nosys(void); }   { old vlimit }
+	SYS_MINCORE = 78;  // { int mincore(user_addr_t addr, user_size_t len, user_addr_t vec); }
+	SYS_GETGROUPS = 79;  // { int getgroups(u_int gidsetsize, gid_t *gidset); }
+	SYS_SETGROUPS = 80;  // { int setgroups(u_int gidsetsize, gid_t *gidset); }
+	SYS_GETPGRP = 81;  // { int getpgrp(void); }
+	SYS_SETPGID = 82;  // { int setpgid(int pid, int pgid); }
+	SYS_SETITIMER = 83;  // { int setitimer(u_int which, struct itimerval *itv, struct itimerval *oitv); }
+	// SYS_NOSYS = 84;  // { int nosys(void); }   { old wait }
+	SYS_SWAPON = 85;  // { int swapon(void); }
+	SYS_GETITIMER = 86;  // { int getitimer(u_int which, struct itimerval *itv); }
+	// SYS_NOSYS = 87;  // { int nosys(void); }   { old gethostname }
+	// SYS_NOSYS = 88;  // { int nosys(void); }   { old sethostname }
+	SYS_GETDTABLESIZE = 89;  // { int getdtablesize(void); }
+	SYS_DUP2 = 90;  // { int dup2(u_int from, u_int to); }
+	// SYS_NOSYS = 91;  // { int nosys(void); }   { old getdopt }
+	SYS_FCNTL = 92;  // { int fcntl(int fd, int cmd, long arg); }
+	SYS_SELECT = 93;  // { int select(int nd, u_int32_t *in, u_int32_t *ou, u_int32_t *ex, struct timeval *tv); }
+	// SYS_NOSYS = 94;  // { int nosys(void); }   { old setdopt }
+	SYS_FSYNC = 95;  // { int fsync(int fd); }
+	SYS_SETPRIORITY = 96;  // { int setpriority(int which, id_t who, int prio); }
+	SYS_SOCKET = 97;  // { int socket(int domain, int type, int protocol); }
+	SYS_CONNECT = 98;  // { int connect(int s, caddr_t name, socklen_t namelen); }
+	// SYS_NOSYS = 97;  // { int nosys(void); }
+	// SYS_NOSYS = 98;  // { int nosys(void); }
+	// SYS_NOSYS = 99;  // { int nosys(void); }   { old accept }
+	SYS_GETPRIORITY = 100;  // { int getpriority(int which, id_t who); }
+	// SYS_NOSYS = 101;  // { int nosys(void); }   { old send }
+	// SYS_NOSYS = 102;  // { int nosys(void); }   { old recv }
+	// SYS_NOSYS = 103;  // { int nosys(void); }   { old sigreturn }
+	SYS_BIND = 104;  // { int bind(int s, caddr_t name, socklen_t namelen); }
+	SYS_SETSOCKOPT = 105;  // { int setsockopt(int s, int level, int name, caddr_t val, socklen_t valsize); }
+	SYS_LISTEN = 106;  // { int listen(int s, int backlog); }
+	// SYS_NOSYS = 104;  // { int nosys(void); }
+	// SYS_NOSYS = 105;  // { int nosys(void); }
+	// SYS_NOSYS = 106;  // { int nosys(void); }
+	// SYS_NOSYS = 107;  // { int nosys(void); }   { old vtimes }
+	// SYS_NOSYS = 108;  // { int nosys(void); }   { old sigvec }
+	// SYS_NOSYS = 109;  // { int nosys(void); }   { old sigblock }
+	// SYS_NOSYS = 110;  // { int nosys(void); }   { old sigsetmask }
+	SYS_SIGSUSPEND = 111;  // { int sigsuspend(sigset_t mask); }
+	// SYS_NOSYS = 112;  // { int nosys(void); }   { old sigstack }
+	// SYS_NOSYS = 113;  // { int nosys(void); }   { old recvmsg }
+	// SYS_NOSYS = 114;  // { int nosys(void); }   { old sendmsg }
+	// SYS_NOSYS = 113;  // { int nosys(void); }
+	// SYS_NOSYS = 114;  // { int nosys(void); }
+	// SYS_NOSYS = 115;  // { int nosys(void); }   { old vtrace }
+	SYS_GETTIMEOFDAY = 116;  // { int gettimeofday(struct timeval *tp, struct timezone *tzp); }
+	SYS_GETRUSAGE = 117;  // { int getrusage(int who, struct rusage *rusage); }
+	SYS_GETSOCKOPT = 118;  // { int getsockopt(int s, int level, int name, caddr_t val, socklen_t *avalsize); }
+	// SYS_NOSYS = 118;  // { int nosys(void); }
+	// SYS_NOSYS = 119;  // { int nosys(void); }   { old resuba }
+	SYS_READV = 120;  // { user_ssize_t readv(int fd, struct iovec *iovp, u_int iovcnt); }
+	SYS_WRITEV = 121;  // { user_ssize_t writev(int fd, struct iovec *iovp, u_int iovcnt); }
+	SYS_SETTIMEOFDAY = 122;  // { int settimeofday(struct timeval *tv, struct timezone *tzp); }
+	SYS_FCHOWN = 123;  // { int fchown(int fd, int uid, int gid); }
+	SYS_FCHMOD = 124;  // { int fchmod(int fd, int mode); }
+	// SYS_NOSYS = 125;  // { int nosys(void); }   { old recvfrom }
+	SYS_SETREUID = 126;  // { int setreuid(uid_t ruid, uid_t euid); }
+	SYS_SETREGID = 127;  // { int setregid(gid_t rgid, gid_t egid); }
+	SYS_RENAME = 128;  // { int rename(char *from, char *to); }
+	// SYS_NOSYS = 129;  // { int nosys(void); }   { old truncate }
+	// SYS_NOSYS = 130;  // { int nosys(void); }   { old ftruncate }
+	SYS_FLOCK = 131;  // { int flock(int fd, int how); }
+	SYS_MKFIFO = 132;  // { int mkfifo(user_addr_t path, int mode); }
+	SYS_SENDTO = 133;  // { int sendto(int s, caddr_t buf, size_t len, int flags, caddr_t to, socklen_t tolen); }
+	SYS_SHUTDOWN = 134;  // { int shutdown(int s, int how); }
+	SYS_SOCKETPAIR = 135;  // { int socketpair(int domain, int type, int protocol, int *rsv); }
+	// SYS_NOSYS = 133;  // { int nosys(void); }
+	// SYS_NOSYS = 134;  // { int nosys(void); }
+	// SYS_NOSYS = 135;  // { int nosys(void); }
+	SYS_MKDIR = 136;  // { int mkdir(user_addr_t path, int mode); }
+	SYS_RMDIR = 137;  // { int rmdir(char *path); }
+	SYS_UTIMES = 138;  // { int utimes(char *path, struct timeval *tptr); }
+	SYS_FUTIMES = 139;  // { int futimes(int fd, struct timeval *tptr); }
+	SYS_ADJTIME = 140;  // { int adjtime(struct timeval *delta, struct timeval *olddelta); }
+	// SYS_NOSYS = 141;  // { int nosys(void); }   { old getpeername }
+	SYS_GETHOSTUUID = 142;  // { int gethostuuid(unsigned char *uuid_buf, const struct timespec *timeoutp); }
+	// SYS_NOSYS = 143;  // { int nosys(void); }   { old sethostid 	}
+	// SYS_NOSYS = 144;  // { int nosys(void); }   { old getrlimit }
+	// SYS_NOSYS = 145;  // { int nosys(void); }   { old setrlimit }
+	// SYS_NOSYS = 146;  // { int nosys(void); }   { old killpg }
+	SYS_SETSID = 147;  // { int setsid(void); }
+	// SYS_NOSYS = 148;  // { int nosys(void); }   { old setquota }
+	// SYS_NOSYS = 149;  // { int nosys(void); }   { old qquota }
+	// SYS_NOSYS = 150;  // { int nosys(void); }   { old getsockname }
+	SYS_GETPGID = 151;  // { int getpgid(pid_t pid); }
+	SYS_SETPRIVEXEC = 152;  // { int setprivexec(int flag); }
+	SYS_PREAD = 153;  // { user_ssize_t pread(int fd, user_addr_t buf, user_size_t nbyte, off_t offset); }
+	SYS_PWRITE = 154;  // { user_ssize_t pwrite(int fd, user_addr_t buf, user_size_t nbyte, off_t offset); }
+	SYS_NFSSVC = 155;  // { int nfssvc(int flag, caddr_t argp); }
+	// SYS_NOSYS = 155;  // { int nosys(void); }
+	// SYS_NOSYS = 156;  // { int nosys(void); }   { old getdirentries }
+	SYS_STATFS = 157;  // { int statfs(char *path, struct statfs *buf); }
+	SYS_FSTATFS = 158;  // { int fstatfs(int fd, struct statfs *buf); }
+	SYS_UNMOUNT = 159;  // { int unmount(user_addr_t path, int flags); }
+	// SYS_NOSYS = 160;  // { int nosys(void); }   { old async_daemon }
+	SYS_GETFH = 161;  // { int getfh(char *fname, fhandle_t *fhp); }
+	// SYS_NOSYS = 161;  // { int nosys(void); }
+	// SYS_NOSYS = 162;  // { int nosys(void); }   { old getdomainname }
+	// SYS_NOSYS = 163;  // { int nosys(void); }   { old setdomainname }
+	// SYS_NOSYS = 164;  // { int nosys(void); }
+	SYS_QUOTACTL = 165;  // { int quotactl(const char *path, int cmd, int uid, caddr_t arg); }
+	// SYS_NOSYS = 166;  // { int nosys(void); }   { old exportfs }
+	SYS_MOUNT = 167;  // { int mount(char *type, char *path, int flags, caddr_t data); }
+	// SYS_NOSYS = 168;  // { int nosys(void); }   { old ustat }
+	SYS_CSOPS = 169;  // { int csops(pid_t pid, uint32_t ops, user_addr_t useraddr, user_size_t usersize); }
+	// SYS_NOSYS = 171;  // { int nosys(void); }   { old wait3 }
+	// SYS_NOSYS = 172;  // { int nosys(void); }   { old rpause	}
+	SYS_WAITID = 173;  // { int waitid(idtype_t idtype, id_t id, siginfo_t *infop, int options); }
+	// SYS_NOSYS = 174;  // { int nosys(void); }   { old getdents }
+	// SYS_NOSYS = 175;  // { int nosys(void); }   { old gc_control }
+	SYS_ADD_PROFIL = 176;  // { int add_profil(short *bufbase, size_t bufsize, u_long pcoffset, u_int pcscale); }
+	// SYS_NOSYS = 177;  // { int nosys(void); }
+	// SYS_NOSYS = 178;  // { int nosys(void); }
+	// SYS_NOSYS = 179;  // { int nosys(void); }
+	SYS_KDEBUG_TRACE = 180;  // { int kdebug_trace(int code, int arg1, int arg2, int arg3, int arg4, int arg5) NO_SYSCALL_STUB; }
+	SYS_SETGID = 181;  // { int setgid(gid_t gid); }
+	SYS_SETEGID = 182;  // { int setegid(gid_t egid); }
+	SYS_SETEUID = 183;  // { int seteuid(uid_t euid); }
+	SYS_SIGRETURN = 184;  // { int sigreturn(struct ucontext *uctx, int infostyle); }
+	// SYS_NOSYS = 186;  // { int nosys(void); }
+	// SYS_NOSYS = 187;  // { int nosys(void); }
+	SYS_STAT = 188;  // { int stat(user_addr_t path, user_addr_t ub); }
+	SYS_FSTAT = 189;  // { int fstat(int fd, user_addr_t ub); }
+	SYS_LSTAT = 190;  // { int lstat(user_addr_t path, user_addr_t ub); }
+	SYS_PATHCONF = 191;  // { int pathconf(char *path, int name); }
+	SYS_FPATHCONF = 192;  // { int fpathconf(int fd, int name); }
+	// SYS_NOSYS = 193;  // { int nosys(void); }
+	SYS_GETRLIMIT = 194;  // { int getrlimit(u_int which, struct rlimit *rlp); }
+	SYS_SETRLIMIT = 195;  // { int setrlimit(u_int which, struct rlimit *rlp); }
+	SYS_GETDIRENTRIES = 196;  // { int getdirentries(int fd, char *buf, u_int count, long *basep); }
+	SYS_MMAP = 197;  // { user_addr_t mmap(caddr_t addr, size_t len, int prot, int flags, int fd, off_t pos); }
+	// SYS_NOSYS = 198;  // { int nosys(void); } 	{ __syscall }
+	SYS_LSEEK = 199;  // { off_t lseek(int fd, off_t offset, int whence); }
+	SYS_TRUNCATE = 200;  // { int truncate(char *path, off_t length); }
+	SYS_FTRUNCATE = 201;  // { int ftruncate(int fd, off_t length); }
+	SYS___SYSCTL = 202;  // { int __sysctl(int *name, u_int namelen, void *old, size_t *oldlenp, void *new, size_t newlen); }
+	SYS_MLOCK = 203;  // { int mlock(caddr_t addr, size_t len); }
+	SYS_MUNLOCK = 204;  // { int munlock(caddr_t addr, size_t len); }
+	SYS_UNDELETE = 205;  // { int undelete(user_addr_t path); }
+	SYS_ATSOCKET = 206;  // { int ATsocket(int proto); }
+	// SYS_NOSYS = 213;  // { int nosys(void); } 	{ Reserved for AppleTalk }
+	// SYS_NOSYS = 206;  // { int nosys(void); }
+	// SYS_NOSYS = 207;  // { int nosys(void); }
+	// SYS_NOSYS = 208;  // { int nosys(void); }
+	// SYS_NOSYS = 209;  // { int nosys(void); }
+	// SYS_NOSYS = 210;  // { int nosys(void); }
+	// SYS_NOSYS = 211;  // { int nosys(void); }
+	// SYS_NOSYS = 212;  // { int nosys(void); }
+	// SYS_NOSYS = 213;  // { int nosys(void); } 	{ Reserved for AppleTalk }
+	SYS_KQUEUE_FROM_PORTSET_NP = 214;  // { int kqueue_from_portset_np(int portset); }
+	SYS_KQUEUE_PORTSET_NP = 215;  // { int kqueue_portset_np(int fd); }
+	SYS_GETATTRLIST = 220;  // { int getattrlist(const char *path, struct attrlist *alist, void *attributeBuffer, size_t bufferSize, u_long options); }
+	SYS_SETATTRLIST = 221;  // { int setattrlist(const char *path, struct attrlist *alist, void *attributeBuffer, size_t bufferSize, u_long options); }
+	SYS_GETDIRENTRIESATTR = 222;  // { int getdirentriesattr(int fd, struct attrlist *alist, void *buffer, size_t buffersize, u_long *count, u_long *basep, u_long *newstate, u_long options); }
+	SYS_EXCHANGEDATA = 223;  // { int exchangedata(const char *path1, const char *path2, u_long options); }
+	// SYS_NOSYS = 224;  // { int nosys(void); } { was checkuseraccess }
+	SYS_SEARCHFS = 225;  // { int searchfs(const char *path, struct fssearchblock *searchblock, u_long *nummatches, u_long scriptcode, u_long options, struct searchstate *state); }
+	SYS_DELETE = 226;  // { int delete(user_addr_t path) NO_SYSCALL_STUB; }       { private delete (Carbon semantics) }
+	SYS_COPYFILE = 227;  // { int copyfile(char *from, char *to, int mode, int flags) NO_SYSCALL_STUB; }
+	// SYS_NOSYS = 228;  // { int nosys(void); }
+	// SYS_NOSYS = 229;  // { int nosys(void); }
+	SYS_POLL = 230;  // { int poll(struct pollfd *fds, u_int nfds, int timeout); }
+	SYS_WATCHEVENT = 231;  // { int watchevent(struct eventreq *u_req, int u_eventmask); }
+	SYS_WAITEVENT = 232;  // { int waitevent(struct eventreq *u_req, struct timeval *tv); }
+	SYS_MODWATCH = 233;  // { int modwatch(struct eventreq *u_req, int u_eventmask); }
+	SYS_GETXATTR = 234;  // { user_ssize_t getxattr(user_addr_t path, user_addr_t attrname, user_addr_t value, size_t size, uint32_t position, int options); }
+	SYS_FGETXATTR = 235;  // { user_ssize_t fgetxattr(int fd, user_addr_t attrname, user_addr_t value, size_t size, uint32_t position, int options); }
+	SYS_SETXATTR = 236;  // { int setxattr(user_addr_t path, user_addr_t attrname, user_addr_t value, size_t size, uint32_t position, int options); }
+	SYS_FSETXATTR = 237;  // { int fsetxattr(int fd, user_addr_t attrname, user_addr_t value, size_t size, uint32_t position, int options); }
+	SYS_REMOVEXATTR = 238;  // { int removexattr(user_addr_t path, user_addr_t attrname, int options); }
+	SYS_FREMOVEXATTR = 239;  // { int fremovexattr(int fd, user_addr_t attrname, int options); }
+	SYS_LISTXATTR = 240;  // { user_ssize_t listxattr(user_addr_t path, user_addr_t namebuf, size_t bufsize, int options); }
+	SYS_FLISTXATTR = 241;  // { user_ssize_t flistxattr(int fd, user_addr_t namebuf, size_t bufsize, int options); }
+	SYS_FSCTL = 242;  // { int fsctl(const char *path, u_long cmd, caddr_t data, u_long options); }
+	SYS_INITGROUPS = 243;  // { int initgroups(u_int gidsetsize, gid_t *gidset, int gmuid); }
+	SYS_POSIX_SPAWN = 244;  // { int posix_spawn(pid_t *pid, const char *path, const struct _posix_spawn_args_desc *adesc, char **argv, char **envp); }
+	// SYS_NOSYS = 245;  // { int nosys(void); }
+	// SYS_NOSYS = 246;  // { int nosys(void); }
+	SYS_NFSCLNT = 247;  // { int nfsclnt(int flag, caddr_t argp); }
+	// SYS_NOSYS = 247;  // { int nosys(void); }
+	SYS_FHOPEN = 248;  // { int fhopen(const struct fhandle *u_fhp, int flags); }
+	// SYS_NOSYS = 248;  // { int nosys(void); }
+	// SYS_NOSYS = 249;  // { int nosys(void); }
+	SYS_MINHERIT = 250;  // { int minherit(void *addr, size_t len, int inherit); }
+	SYS_SEMSYS = 251;  // { int semsys(u_int which, int a2, int a3, int a4, int a5); }
+	// SYS_NOSYS = 251;  // { int nosys(void); }
+	SYS_MSGSYS = 252;  // { int msgsys(u_int which, int a2, int a3, int a4, int a5); }
+	// SYS_NOSYS = 252;  // { int nosys(void); }
+	SYS_SHMSYS = 253;  // { int shmsys(u_int which, int a2, int a3, int a4); }
+	// SYS_NOSYS = 253;  // { int nosys(void); }
+	SYS_SEMCTL = 254;  // { int semctl(int semid, int semnum, int cmd, semun_t arg); }
+	SYS_SEMGET = 255;  // { int semget(key_t key, int	nsems, int semflg); }
+	SYS_SEMOP = 256;  // { int semop(int semid, struct sembuf *sops, int nsops); }
+	// SYS_NOSYS = 257;  // { int nosys(void); }
+	// SYS_NOSYS = 254;  // { int nosys(void); }
+	// SYS_NOSYS = 255;  // { int nosys(void); }
+	// SYS_NOSYS = 256;  // { int nosys(void); }
+	// SYS_NOSYS = 257;  // { int nosys(void); }
+	SYS_MSGCTL = 258;  // { int msgctl(int msqid, int cmd, struct	msqid_ds *buf); }
+	SYS_MSGGET = 259;  // { int msgget(key_t key, int msgflg); }
+	SYS_MSGSND = 260;  // { int msgsnd(int msqid, void *msgp, size_t msgsz, int msgflg); }
+	SYS_MSGRCV = 261;  // { user_ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg); }
+	// SYS_NOSYS = 258;  // { int nosys(void); }
+	// SYS_NOSYS = 259;  // { int nosys(void); }
+	// SYS_NOSYS = 260;  // { int nosys(void); }
+	// SYS_NOSYS = 261;  // { int nosys(void); }
+	SYS_SHMAT = 262;  // { user_addr_t shmat(int shmid, void *shmaddr, int shmflg); }
+	SYS_SHMCTL = 263;  // { int shmctl(int shmid, int cmd, struct shmid_ds *buf); }
+	SYS_SHMDT = 264;  // { int shmdt(void *shmaddr); }
+	SYS_SHMGET = 265;  // { int shmget(key_t key, size_t size, int shmflg); }
+	// SYS_NOSYS = 262;  // { int nosys(void); }
+	// SYS_NOSYS = 263;  // { int nosys(void); }
+	// SYS_NOSYS = 264;  // { int nosys(void); }
+	// SYS_NOSYS = 265;  // { int nosys(void); }
+	SYS_SHM_OPEN = 266;  // { int shm_open(const char *name, int oflag, int mode); }
+	SYS_SHM_UNLINK = 267;  // { int shm_unlink(const char *name); }
+	SYS_SEM_OPEN = 268;  // { user_addr_t sem_open(const char *name, int oflag, int mode, int value); }
+	SYS_SEM_CLOSE = 269;  // { int sem_close(sem_t *sem); }
+	SYS_SEM_UNLINK = 270;  // { int sem_unlink(const char *name); }
+	SYS_SEM_WAIT = 271;  // { int sem_wait(sem_t *sem); }
+	SYS_SEM_TRYWAIT = 272;  // { int sem_trywait(sem_t *sem); }
+	SYS_SEM_POST = 273;  // { int sem_post(sem_t *sem); }
+	SYS_SEM_GETVALUE = 274;  // { int sem_getvalue(sem_t *sem, int *sval); }
+	SYS_SEM_INIT = 275;  // { int sem_init(sem_t *sem, int phsared, u_int value); }
+	SYS_SEM_DESTROY = 276;  // { int sem_destroy(sem_t *sem); }
+	SYS_OPEN_EXTENDED = 277;  // { int open_extended(user_addr_t path, int flags, uid_t uid, gid_t gid, int mode, user_addr_t xsecurity) NO_SYSCALL_STUB; }
+	SYS_UMASK_EXTENDED = 278;  // { int umask_extended(int newmask, user_addr_t xsecurity) NO_SYSCALL_STUB; }
+	SYS_STAT_EXTENDED = 279;  // { int stat_extended(user_addr_t path, user_addr_t ub, user_addr_t xsecurity, user_addr_t xsecurity_size) NO_SYSCALL_STUB; }
+	SYS_LSTAT_EXTENDED = 280;  // { int lstat_extended(user_addr_t path, user_addr_t ub, user_addr_t xsecurity, user_addr_t xsecurity_size) NO_SYSCALL_STUB; }
+	SYS_FSTAT_EXTENDED = 281;  // { int fstat_extended(int fd, user_addr_t ub, user_addr_t xsecurity, user_addr_t xsecurity_size) NO_SYSCALL_STUB; }
+	SYS_CHMOD_EXTENDED = 282;  // { int chmod_extended(user_addr_t path, uid_t uid, gid_t gid, int mode, user_addr_t xsecurity) NO_SYSCALL_STUB; }
+	SYS_FCHMOD_EXTENDED = 283;  // { int fchmod_extended(int fd, uid_t uid, gid_t gid, int mode, user_addr_t xsecurity) NO_SYSCALL_STUB; }
+	SYS_ACCESS_EXTENDED = 284;  // { int access_extended(user_addr_t entries, size_t size, user_addr_t results, uid_t uid) NO_SYSCALL_STUB; }
+	SYS_SETTID = 285;  // { int settid(uid_t uid, gid_t gid) NO_SYSCALL_STUB; }
+	SYS_GETTID = 286;  // { int gettid(uid_t *uidp, gid_t *gidp) NO_SYSCALL_STUB; }
+	SYS_SETSGROUPS = 287;  // { int setsgroups(int setlen, user_addr_t guidset) NO_SYSCALL_STUB; }
+	SYS_GETSGROUPS = 288;  // { int getsgroups(user_addr_t setlen, user_addr_t guidset) NO_SYSCALL_STUB; }
+	SYS_SETWGROUPS = 289;  // { int setwgroups(int setlen, user_addr_t guidset) NO_SYSCALL_STUB; }
+	SYS_GETWGROUPS = 290;  // { int getwgroups(user_addr_t setlen, user_addr_t guidset) NO_SYSCALL_STUB; }
+	SYS_MKFIFO_EXTENDED = 291;  // { int mkfifo_extended(user_addr_t path, uid_t uid, gid_t gid, int mode, user_addr_t xsecurity) NO_SYSCALL_STUB; }
+	SYS_MKDIR_EXTENDED = 292;  // { int mkdir_extended(user_addr_t path, uid_t uid, gid_t gid, int mode, user_addr_t xsecurity) NO_SYSCALL_STUB; }
+	SYS_IDENTITYSVC = 293;  // { int identitysvc(int opcode, user_addr_t message) NO_SYSCALL_STUB; }
+	SYS_SHARED_REGION_CHECK_NP = 294;  // { int shared_region_check_np(uint64_t *start_address) NO_SYSCALL_STUB; }
+	SYS_SHARED_REGION_MAP_NP = 295;  // { int shared_region_map_np(int fd, uint32_t count, const struct shared_file_mapping_np *mappings) NO_SYSCALL_STUB; }
+	// SYS_NOSYS = 296;  // { int nosys(void); } { old load_shared_file }
+	// SYS_NOSYS = 297;  // { int nosys(void); } { old reset_shared_file }
+	// SYS_NOSYS = 298;  // { int nosys(void); } { old new_system_shared_regions }
+	SYS_ENOSYS = 299;  // { int enosys(void); } { old shared_region_map_file_np }
+	SYS_ENOSYS = 300;  // { int enosys(void); } { old shared_region_make_private_np }
+	SYS___PTHREAD_MUTEX_DESTROY = 301;  // { int __pthread_mutex_destroy(int mutexid); }
+	SYS___PTHREAD_MUTEX_INIT = 302;  // { int __pthread_mutex_init(user_addr_t  mutex, user_addr_t attr); }
+	SYS___PTHREAD_MUTEX_LOCK = 303;  // { int __pthread_mutex_lock(int mutexid); }
+	SYS___PTHREAD_MUTEX_TRYLOCK = 304;  // { int __pthread_mutex_trylock(int mutexid); }
+	SYS___PTHREAD_MUTEX_UNLOCK = 305;  // { int __pthread_mutex_unlock(int mutexid); }
+	SYS___PTHREAD_COND_INIT = 306;  // { int __pthread_cond_init(user_addr_t cond, user_addr_t attr); }
+	SYS___PTHREAD_COND_DESTROY = 307;  // { int __pthread_cond_destroy(int condid); }
+	SYS___PTHREAD_COND_BROADCAST = 308;  // { int __pthread_cond_broadcast(int condid); }
+	SYS___PTHREAD_COND_SIGNAL = 309;  // { int __pthread_cond_signal(int condid); }
+	SYS_GETSID = 310;  // { int getsid(pid_t pid); }
+	SYS_SETTID_WITH_PID = 311;  // { int settid_with_pid(pid_t pid, int assume) NO_SYSCALL_STUB; }
+	SYS___PTHREAD_COND_TIMEDWAIT = 312;  // { int __pthread_cond_timedwait(int condid, int mutexid, user_addr_t abstime); }
+	SYS_AIO_FSYNC = 313;  // { int aio_fsync(int op, user_addr_t aiocbp); }
+	SYS_AIO_RETURN = 314;  // { user_ssize_t aio_return(user_addr_t aiocbp); }
+	SYS_AIO_SUSPEND = 315;  // { int aio_suspend(user_addr_t aiocblist, int nent, user_addr_t timeoutp); }
+	SYS_AIO_CANCEL = 316;  // { int aio_cancel(int fd, user_addr_t aiocbp); }
+	SYS_AIO_ERROR = 317;  // { int aio_error(user_addr_t aiocbp); }
+	SYS_AIO_READ = 318;  // { int aio_read(user_addr_t aiocbp); }
+	SYS_AIO_WRITE = 319;  // { int aio_write(user_addr_t aiocbp); }
+	SYS_LIO_LISTIO = 320;  // { int lio_listio(int mode, user_addr_t aiocblist, int nent, user_addr_t sigp); }
+	SYS___PTHREAD_COND_WAIT = 321;  // { int __pthread_cond_wait(int condid, int mutexid); }
+	SYS_IOPOLICYSYS = 322;  // { int iopolicysys(int cmd, void *arg) NO_SYSCALL_STUB; }
+	// SYS_NOSYS = 323;  // { int nosys(void); }
+	SYS_MLOCKALL = 324;  // { int mlockall(int how); }
+	SYS_MUNLOCKALL = 325;  // { int munlockall(int how); }
+	// SYS_NOSYS = 326;  // { int nosys(void); }
+	SYS_ISSETUGID = 327;  // { int issetugid(void); }
+	SYS___PTHREAD_KILL = 328;  // { int __pthread_kill(int thread_port, int sig); }
+	SYS___PTHREAD_SIGMASK = 329;  // { int __pthread_sigmask(int how, user_addr_t set, user_addr_t oset); }
+	SYS___SIGWAIT = 330;  // { int __sigwait(user_addr_t set, user_addr_t sig); }
+	SYS___DISABLE_THREADSIGNAL = 331;  // { int __disable_threadsignal(int value); }
+	SYS___PTHREAD_MARKCANCEL = 332;  // { int __pthread_markcancel(int thread_port); }
+	SYS___PTHREAD_CANCELED = 333;  // { int __pthread_canceled(int  action); }
+	SYS___SEMWAIT_SIGNAL = 334;  // { int __semwait_signal(int cond_sem, int mutex_sem, int timeout, int relative, time_t tv_sec, int32_t tv_nsec); }
+	// SYS_NOSYS = 335;  // { int nosys(void); }   { old utrace }
+	SYS_PROC_INFO = 336;  // { int proc_info(int32_t callnum,int32_t pid,uint32_t flavor, uint64_t arg,user_addr_t buffer,int32_t buffersize) NO_SYSCALL_STUB; }
+	SYS_SENDFILE = 337;  // { int sendfile(int fd, int s, off_t offset, off_t *nbytes, struct sf_hdtr *hdtr, int flags); }
+	// SYS_NOSYS = 337;  // { int nosys(void); }
+	SYS_STAT64 = 338;  // { int stat64(user_addr_t path, user_addr_t ub); }
+	SYS_FSTAT64 = 339;  // { int fstat64(int fd, user_addr_t ub); }
+	SYS_LSTAT64 = 340;  // { int lstat64(user_addr_t path, user_addr_t ub); }
+	SYS_STAT64_EXTENDED = 341;  // { int stat64_extended(user_addr_t path, user_addr_t ub, user_addr_t xsecurity, user_addr_t xsecurity_size) NO_SYSCALL_STUB; }
+	SYS_LSTAT64_EXTENDED = 342;  // { int lstat64_extended(user_addr_t path, user_addr_t ub, user_addr_t xsecurity, user_addr_t xsecurity_size) NO_SYSCALL_STUB; }
+	SYS_FSTAT64_EXTENDED = 343;  // { int fstat64_extended(int fd, user_addr_t ub, user_addr_t xsecurity, user_addr_t xsecurity_size) NO_SYSCALL_STUB; }
+	SYS_GETDIRENTRIES64 = 344;  // { user_ssize_t getdirentries64(int fd, void *buf, user_size_t bufsize, off_t *position) NO_SYSCALL_STUB; }
+	SYS_STATFS64 = 345;  // { int statfs64(char *path, struct statfs64 *buf); }
+	SYS_FSTATFS64 = 346;  // { int fstatfs64(int fd, struct statfs64 *buf); }
+	SYS_GETFSSTAT64 = 347;  // { int getfsstat64(user_addr_t buf, int bufsize, int flags); }
+	SYS___PTHREAD_CHDIR = 348;  // { int __pthread_chdir(user_addr_t path); }
+	SYS___PTHREAD_FCHDIR = 349;  // { int __pthread_fchdir(int fd); }
+	SYS_AUDIT = 350;  // { int audit(void *record, int length); }
+	SYS_AUDITON = 351;  // { int auditon(int cmd, void *data, int length); }
+	// SYS_NOSYS = 352;  // { int nosys(void); }
+	SYS_GETAUID = 353;  // { int getauid(au_id_t *auid); }
+	SYS_SETAUID = 354;  // { int setauid(au_id_t *auid); }
+	SYS_GETAUDIT = 355;  // { int getaudit(struct auditinfo *auditinfo); }
+	SYS_SETAUDIT = 356;  // { int setaudit(struct auditinfo *auditinfo); }
+	SYS_GETAUDIT_ADDR = 357;  // { int getaudit_addr(struct auditinfo_addr *auditinfo_addr, int length); }
+	SYS_SETAUDIT_ADDR = 358;  // { int setaudit_addr(struct auditinfo_addr *auditinfo_addr, int length); }
+	SYS_AUDITCTL = 359;  // { int auditctl(char *path); }
+	// SYS_NOSYS = 350;  // { int nosys(void); }
+	// SYS_NOSYS = 351;  // { int nosys(void); }
+	// SYS_NOSYS = 352;  // { int nosys(void); }
+	// SYS_NOSYS = 353;  // { int nosys(void); }
+	// SYS_NOSYS = 354;  // { int nosys(void); }
+	// SYS_NOSYS = 355;  // { int nosys(void); }
+	// SYS_NOSYS = 356;  // { int nosys(void); }
+	// SYS_NOSYS = 357;  // { int nosys(void); }
+	// SYS_NOSYS = 358;  // { int nosys(void); }
+	// SYS_NOSYS = 359;  // { int nosys(void); }
+	SYS_BSDTHREAD_CREATE = 360;  // { user_addr_t bsdthread_create(user_addr_t func, user_addr_t func_arg, user_addr_t stack, user_addr_t pthread, uint32_t flags) NO_SYSCALL_STUB; }
+	SYS_BSDTHREAD_TERMINATE = 361;  // { int bsdthread_terminate(user_addr_t stackaddr, size_t freesize, uint32_t port, uint32_t sem) NO_SYSCALL_STUB; }
+	SYS_KQUEUE = 362;  // { int kqueue(void); }
+	SYS_KEVENT = 363;  // { int kevent(int fd, const struct kevent *changelist, int nchanges, struct kevent *eventlist, int nevents, const struct timespec *timeout); }
+	SYS_LCHOWN = 364;  // { int lchown(user_addr_t path, uid_t owner, gid_t group); }
+	SYS_STACK_SNAPSHOT = 365;  // { int stack_snapshot(pid_t pid, user_addr_t tracebuf, uint32_t tracebuf_size, uint32_t options) NO_SYSCALL_STUB; }
+	SYS_BSDTHREAD_REGISTER = 366;  // { int bsdthread_register(user_addr_t threadstart, user_addr_t wqthread, int pthsize) NO_SYSCALL_STUB; }
+	SYS_WORKQ_OPEN = 367;  // { int workq_open(void) NO_SYSCALL_STUB; }
+	SYS_WORKQ_OPS = 368;  // { int workq_ops(int options, user_addr_t item, int prio) NO_SYSCALL_STUB; }
+	// SYS_NOSYS = 369;  // { int nosys(void); }
+	// SYS_NOSYS = 370;  // { int nosys(void); }
+	// SYS_NOSYS = 371;  // { int nosys(void); }
+	// SYS_NOSYS = 372;  // { int nosys(void); }
+	// SYS_NOSYS = 373;  // { int nosys(void); }
+	// SYS_NOSYS = 374;  // { int nosys(void); }
+	// SYS_NOSYS = 375;  // { int nosys(void); }
+	// SYS_NOSYS = 376;  // { int nosys(void); }
+	// SYS_NOSYS = 377;  // { int nosys(void); }
+	// SYS_NOSYS = 378;  // { int nosys(void); }
+	// SYS_NOSYS = 379;  // { int nosys(void); }
+	SYS___MAC_EXECVE = 380;  // { int __mac_execve(char *fname, char **argp, char **envp, struct mac *mac_p); }
+	SYS___MAC_SYSCALL = 381;  // { int __mac_syscall(char *policy, int call, user_addr_t arg); }
+	SYS___MAC_GET_FILE = 382;  // { int __mac_get_file(char *path_p, struct mac *mac_p); }
+	SYS___MAC_SET_FILE = 383;  // { int __mac_set_file(char *path_p, struct mac *mac_p); }
+	SYS___MAC_GET_LINK = 384;  // { int __mac_get_link(char *path_p, struct mac *mac_p); }
+	SYS___MAC_SET_LINK = 385;  // { int __mac_set_link(char *path_p, struct mac *mac_p); }
+	SYS___MAC_GET_PROC = 386;  // { int __mac_get_proc(struct mac *mac_p); }
+	SYS___MAC_SET_PROC = 387;  // { int __mac_set_proc(struct mac *mac_p); }
+	SYS___MAC_GET_FD = 388;  // { int __mac_get_fd(int fd, struct mac *mac_p); }
+	SYS___MAC_SET_FD = 389;  // { int __mac_set_fd(int fd, struct mac *mac_p); }
+	SYS___MAC_GET_PID = 390;  // { int __mac_get_pid(pid_t pid, struct mac *mac_p); }
+	SYS___MAC_GET_LCID = 391;  // { int __mac_get_lcid(pid_t lcid, struct mac *mac_p); }
+	SYS___MAC_GET_LCTX = 392;  // { int __mac_get_lctx(struct mac *mac_p); }
+	SYS___MAC_SET_LCTX = 393;  // { int __mac_set_lctx(struct mac *mac_p); }
+	SYS_SETLCID = 394;  // { int setlcid(pid_t pid, pid_t lcid) NO_SYSCALL_STUB; }
+	SYS_GETLCID = 395;  // { int getlcid(pid_t pid) NO_SYSCALL_STUB; }
+	SYS_READ_NOCANCEL = 396;  // { user_ssize_t read_nocancel(int fd, user_addr_t cbuf, user_size_t nbyte) NO_SYSCALL_STUB; }
+	SYS_WRITE_NOCANCEL = 397;  // { user_ssize_t write_nocancel(int fd, user_addr_t cbuf, user_size_t nbyte) NO_SYSCALL_STUB; }
+	SYS_OPEN_NOCANCEL = 398;  // { int open_nocancel(user_addr_t path, int flags, int mode) NO_SYSCALL_STUB; }
+	SYS_CLOSE_NOCANCEL = 399;  // { int close_nocancel(int fd) NO_SYSCALL_STUB; }
+	SYS_WAIT4_NOCANCEL = 400;  // { int wait4_nocancel(int pid, user_addr_t status, int options, user_addr_t rusage) NO_SYSCALL_STUB; }
+	SYS_RECVMSG_NOCANCEL = 401;  // { int recvmsg_nocancel(int s, struct msghdr *msg, int flags) NO_SYSCALL_STUB; }
+	SYS_SENDMSG_NOCANCEL = 402;  // { int sendmsg_nocancel(int s, caddr_t msg, int flags) NO_SYSCALL_STUB; }
+	SYS_RECVFROM_NOCANCEL = 403;  // { int recvfrom_nocancel(int s, void *buf, size_t len, int flags, struct sockaddr *from, int *fromlenaddr) NO_SYSCALL_STUB; }
+	SYS_ACCEPT_NOCANCEL = 404;  // { int accept_nocancel(int s, caddr_t name, socklen_t	*anamelen) NO_SYSCALL_STUB; }
+	// SYS_NOSYS = 401;  // { int nosys(void); }
+	// SYS_NOSYS = 402;  // { int nosys(void); }
+	// SYS_NOSYS = 403;  // { int nosys(void); }
+	// SYS_NOSYS = 404;  // { int nosys(void); }
+	SYS_MSYNC_NOCANCEL = 405;  // { int msync_nocancel(caddr_t addr, size_t len, int flags) NO_SYSCALL_STUB; }
+	SYS_FCNTL_NOCANCEL = 406;  // { int fcntl_nocancel(int fd, int cmd, long arg) NO_SYSCALL_STUB; }
+	SYS_SELECT_NOCANCEL = 407;  // { int select_nocancel(int nd, u_int32_t *in, u_int32_t *ou, u_int32_t *ex, struct timeval *tv) NO_SYSCALL_STUB; }
+	SYS_FSYNC_NOCANCEL = 408;  // { int fsync_nocancel(int fd) NO_SYSCALL_STUB; }
+	SYS_CONNECT_NOCANCEL = 409;  // { int connect_nocancel(int s, caddr_t name, socklen_t namelen) NO_SYSCALL_STUB; }
+	// SYS_NOSYS = 409;  // { int nosys(void); }
+	SYS_SIGSUSPEND_NOCANCEL = 410;  // { int sigsuspend_nocancel(sigset_t mask) NO_SYSCALL_STUB; }
+	SYS_READV_NOCANCEL = 411;  // { user_ssize_t readv_nocancel(int fd, struct iovec *iovp, u_int iovcnt) NO_SYSCALL_STUB; }
+	SYS_WRITEV_NOCANCEL = 412;  // { user_ssize_t writev_nocancel(int fd, struct iovec *iovp, u_int iovcnt) NO_SYSCALL_STUB; }
+	SYS_SENDTO_NOCANCEL = 413;  // { int sendto_nocancel(int s, caddr_t buf, size_t len, int flags, caddr_t to, socklen_t tolen) NO_SYSCALL_STUB; }
+	// SYS_NOSYS = 413;  // { int nosys(void); }
+	SYS_PREAD_NOCANCEL = 414;  // { user_ssize_t pread_nocancel(int fd, user_addr_t buf, user_size_t nbyte, off_t offset) NO_SYSCALL_STUB; }
+	SYS_PWRITE_NOCANCEL = 415;  // { user_ssize_t pwrite_nocancel(int fd, user_addr_t buf, user_size_t nbyte, off_t offset) NO_SYSCALL_STUB; }
+	SYS_WAITID_NOCANCEL = 416;  // { int waitid_nocancel(idtype_t idtype, id_t id, siginfo_t *infop, int options) NO_SYSCALL_STUB; }
+	SYS_POLL_NOCANCEL = 417;  // { int poll_nocancel(struct pollfd *fds, u_int nfds, int timeout) NO_SYSCALL_STUB; }
+	SYS_MSGSND_NOCANCEL = 418;  // { int msgsnd_nocancel(int msqid, void *msgp, size_t msgsz, int msgflg) NO_SYSCALL_STUB; }
+	SYS_MSGRCV_NOCANCEL = 419;  // { user_ssize_t msgrcv_nocancel(int msqid, void *msgp, size_t msgsz, long msgtyp, int msgflg) NO_SYSCALL_STUB; }
+	// SYS_NOSYS = 418;  // { int nosys(void); }
+	// SYS_NOSYS = 419;  // { int nosys(void); }
+	SYS_SEM_WAIT_NOCANCEL = 420;  // { int sem_wait_nocancel(sem_t *sem) NO_SYSCALL_STUB; }
+	SYS_AIO_SUSPEND_NOCANCEL = 421;  // { int aio_suspend_nocancel(user_addr_t aiocblist, int nent, user_addr_t timeoutp) NO_SYSCALL_STUB; }
+	SYS___SIGWAIT_NOCANCEL = 422;  // { int __sigwait_nocancel(user_addr_t set, user_addr_t sig) NO_SYSCALL_STUB; }
+	SYS___SEMWAIT_SIGNAL_NOCANCEL = 423;  // { int __semwait_signal_nocancel(int cond_sem, int mutex_sem, int timeout, int relative, time_t tv_sec, int32_t tv_nsec) NO_SYSCALL_STUB; }
+	SYS___MAC_MOUNT = 424;  // { int __mac_mount(char *type, char *path, int flags, caddr_t data, struct mac *mac_p); }
+	SYS___MAC_GET_MOUNT = 425;  // { int __mac_get_mount(char *path, struct mac *mac_p); }
+	SYS___MAC_GETFSSTAT = 426;  // { int __mac_getfsstat(user_addr_t buf, int bufsize, user_addr_t mac, int macsize, int flags); }
+)
diff --git a/src/lib/syscall/syscall_amd64_linux.go b/src/lib/syscall/syscall_amd64_linux.go
new file mode 100644
index 0000000..1e1f498
--- /dev/null
+++ b/src/lib/syscall/syscall_amd64_linux.go
@@ -0,0 +1,297 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Generated by mklinux; DO NOT EDIT.
+// mklinux /usr/include/asm/unistd_64.h
+
+package syscall
+
+export const(
+	SYS_READ = 0;
+	SYS_WRITE = 1;
+	SYS_OPEN = 2;
+	SYS_CLOSE = 3;
+	SYS_STAT = 4;
+	SYS_FSTAT = 5;
+	SYS_LSTAT = 6;
+	SYS_POLL = 7;
+	SYS_LSEEK = 8;
+	SYS_MMAP = 9;
+	SYS_MPROTECT = 10;
+	SYS_MUNMAP = 11;
+	SYS_BRK = 12;
+	SYS_RT_SIGACTION = 13;
+	SYS_RT_SIGPROCMASK = 14;
+	SYS_RT_SIGRETURN = 15;
+	SYS_IOCTL = 16;
+	SYS_PREAD64 = 17;
+	SYS_PWRITE64 = 18;
+	SYS_READV = 19;
+	SYS_WRITEV = 20;
+	SYS_ACCESS = 21;
+	SYS_PIPE = 22;
+	SYS_SELECT = 23;
+	SYS_SCHED_YIELD = 24;
+	SYS_MREMAP = 25;
+	SYS_MSYNC = 26;
+	SYS_MINCORE = 27;
+	SYS_MADVISE = 28;
+	SYS_SHMGET = 29;
+	SYS_SHMAT = 30;
+	SYS_SHMCTL = 31;
+	SYS_DUP = 32;
+	SYS_DUP2 = 33;
+	SYS_PAUSE = 34;
+	SYS_NANOSLEEP = 35;
+	SYS_GETITIMER = 36;
+	SYS_ALARM = 37;
+	SYS_SETITIMER = 38;
+	SYS_GETPID = 39;
+	SYS_SENDFILE = 40;
+	SYS_SOCKET = 41;
+	SYS_CONNECT = 42;
+	SYS_ACCEPT = 43;
+	SYS_SENDTO = 44;
+	SYS_RECVFROM = 45;
+	SYS_SENDMSG = 46;
+	SYS_RECVMSG = 47;
+	SYS_SHUTDOWN = 48;
+	SYS_BIND = 49;
+	SYS_LISTEN = 50;
+	SYS_GETSOCKNAME = 51;
+	SYS_GETPEERNAME = 52;
+	SYS_SOCKETPAIR = 53;
+	SYS_SETSOCKOPT = 54;
+	SYS_GETSOCKOPT = 55;
+	SYS_CLONE = 56;
+	SYS_FORK = 57;
+	SYS_VFORK = 58;
+	SYS_EXECVE = 59;
+	SYS_EXIT = 60;
+	SYS_WAIT4 = 61;
+	SYS_KILL = 62;
+	SYS_UNAME = 63;
+	SYS_SEMGET = 64;
+	SYS_SEMOP = 65;
+	SYS_SEMCTL = 66;
+	SYS_SHMDT = 67;
+	SYS_MSGGET = 68;
+	SYS_MSGSND = 69;
+	SYS_MSGRCV = 70;
+	SYS_MSGCTL = 71;
+	SYS_FCNTL = 72;
+	SYS_FLOCK = 73;
+	SYS_FSYNC = 74;
+	SYS_FDATASYNC = 75;
+	SYS_TRUNCATE = 76;
+	SYS_FTRUNCATE = 77;
+	SYS_GETDENTS = 78;
+	SYS_GETCWD = 79;
+	SYS_CHDIR = 80;
+	SYS_FCHDIR = 81;
+	SYS_RENAME = 82;
+	SYS_MKDIR = 83;
+	SYS_RMDIR = 84;
+	SYS_CREAT = 85;
+	SYS_LINK = 86;
+	SYS_UNLINK = 87;
+	SYS_SYMLINK = 88;
+	SYS_READLINK = 89;
+	SYS_CHMOD = 90;
+	SYS_FCHMOD = 91;
+	SYS_CHOWN = 92;
+	SYS_FCHOWN = 93;
+	SYS_LCHOWN = 94;
+	SYS_UMASK = 95;
+	SYS_GETTIMEOFDAY = 96;
+	SYS_GETRLIMIT = 97;
+	SYS_GETRUSAGE = 98;
+	SYS_SYSINFO = 99;
+	SYS_TIMES = 100;
+	SYS_PTRACE = 101;
+	SYS_GETUID = 102;
+	SYS_SYSLOG = 103;
+	SYS_GETGID = 104;
+	SYS_SETUID = 105;
+	SYS_SETGID = 106;
+	SYS_GETEUID = 107;
+	SYS_GETEGID = 108;
+	SYS_SETPGID = 109;
+	SYS_GETPPID = 110;
+	SYS_GETPGRP = 111;
+	SYS_SETSID = 112;
+	SYS_SETREUID = 113;
+	SYS_SETREGID = 114;
+	SYS_GETGROUPS = 115;
+	SYS_SETGROUPS = 116;
+	SYS_SETRESUID = 117;
+	SYS_GETRESUID = 118;
+	SYS_SETRESGID = 119;
+	SYS_GETRESGID = 120;
+	SYS_GETPGID = 121;
+	SYS_SETFSUID = 122;
+	SYS_SETFSGID = 123;
+	SYS_GETSID = 124;
+	SYS_CAPGET = 125;
+	SYS_CAPSET = 126;
+	SYS_RT_SIGPENDING = 127;
+	SYS_RT_SIGTIMEDWAIT = 128;
+	SYS_RT_SIGQUEUEINFO = 129;
+	SYS_RT_SIGSUSPEND = 130;
+	SYS_SIGALTSTACK = 131;
+	SYS_UTIME = 132;
+	SYS_MKNOD = 133;
+	SYS_USELIB = 134;
+	SYS_PERSONALITY = 135;
+	SYS_USTAT = 136;
+	SYS_STATFS = 137;
+	SYS_FSTATFS = 138;
+	SYS_SYSFS = 139;
+	SYS_GETPRIORITY = 140;
+	SYS_SETPRIORITY = 141;
+	SYS_SCHED_SETPARAM = 142;
+	SYS_SCHED_GETPARAM = 143;
+	SYS_SCHED_SETSCHEDULER = 144;
+	SYS_SCHED_GETSCHEDULER = 145;
+	SYS_SCHED_GET_PRIORITY_MAX = 146;
+	SYS_SCHED_GET_PRIORITY_MIN = 147;
+	SYS_SCHED_RR_GET_INTERVAL = 148;
+	SYS_MLOCK = 149;
+	SYS_MUNLOCK = 150;
+	SYS_MLOCKALL = 151;
+	SYS_MUNLOCKALL = 152;
+	SYS_VHANGUP = 153;
+	SYS_MODIFY_LDT = 154;
+	SYS_PIVOT_ROOT = 155;
+	SYS__SYSCTL = 156;
+	SYS_PRCTL = 157;
+	SYS_ARCH_PRCTL = 158;
+	SYS_ADJTIMEX = 159;
+	SYS_SETRLIMIT = 160;
+	SYS_CHROOT = 161;
+	SYS_SYNC = 162;
+	SYS_ACCT = 163;
+	SYS_SETTIMEOFDAY = 164;
+	SYS_MOUNT = 165;
+	SYS_UMOUNT2 = 166;
+	SYS_SWAPON = 167;
+	SYS_SWAPOFF = 168;
+	SYS_REBOOT = 169;
+	SYS_SETHOSTNAME = 170;
+	SYS_SETDOMAINNAME = 171;
+	SYS_IOPL = 172;
+	SYS_IOPERM = 173;
+	SYS_CREATE_MODULE = 174;
+	SYS_INIT_MODULE = 175;
+	SYS_DELETE_MODULE = 176;
+	SYS_GET_KERNEL_SYMS = 177;
+	SYS_QUERY_MODULE = 178;
+	SYS_QUOTACTL = 179;
+	SYS_NFSSERVCTL = 180;
+	SYS_GETPMSG = 181;
+	SYS_PUTPMSG = 182;
+	SYS_AFS_SYSCALL = 183;
+	SYS_TUXCALL = 184;
+	SYS_SECURITY = 185;
+	SYS_GETTID = 186;
+	SYS_READAHEAD = 187;
+	SYS_SETXATTR = 188;
+	SYS_LSETXATTR = 189;
+	SYS_FSETXATTR = 190;
+	SYS_GETXATTR = 191;
+	SYS_LGETXATTR = 192;
+	SYS_FGETXATTR = 193;
+	SYS_LISTXATTR = 194;
+	SYS_LLISTXATTR = 195;
+	SYS_FLISTXATTR = 196;
+	SYS_REMOVEXATTR = 197;
+	SYS_LREMOVEXATTR = 198;
+	SYS_FREMOVEXATTR = 199;
+	SYS_TKILL = 200;
+	SYS_TIME = 201;
+	SYS_FUTEX = 202;
+	SYS_SCHED_SETAFFINITY = 203;
+	SYS_SCHED_GETAFFINITY = 204;
+	SYS_SET_THREAD_AREA = 205;
+	SYS_IO_SETUP = 206;
+	SYS_IO_DESTROY = 207;
+	SYS_IO_GETEVENTS = 208;
+	SYS_IO_SUBMIT = 209;
+	SYS_IO_CANCEL = 210;
+	SYS_GET_THREAD_AREA = 211;
+	SYS_LOOKUP_DCOOKIE = 212;
+	SYS_EPOLL_CREATE = 213;
+	SYS_EPOLL_CTL_OLD = 214;
+	SYS_EPOLL_WAIT_OLD = 215;
+	SYS_REMAP_FILE_PAGES = 216;
+	SYS_GETDENTS64 = 217;
+	SYS_SET_TID_ADDRESS = 218;
+	SYS_RESTART_SYSCALL = 219;
+	SYS_SEMTIMEDOP = 220;
+	SYS_FADVISE64 = 221;
+	SYS_TIMER_CREATE = 222;
+	SYS_TIMER_SETTIME = 223;
+	SYS_TIMER_GETTIME = 224;
+	SYS_TIMER_GETOVERRUN = 225;
+	SYS_TIMER_DELETE = 226;
+	SYS_CLOCK_SETTIME = 227;
+	SYS_CLOCK_GETTIME = 228;
+	SYS_CLOCK_GETRES = 229;
+	SYS_CLOCK_NANOSLEEP = 230;
+	SYS_EXIT_GROUP = 231;
+	SYS_EPOLL_WAIT = 232;
+	SYS_EPOLL_CTL = 233;
+	SYS_TGKILL = 234;
+	SYS_UTIMES = 235;
+	SYS_VSERVER = 236;
+	SYS_MBIND = 237;
+	SYS_SET_MEMPOLICY = 238;
+	SYS_GET_MEMPOLICY = 239;
+	SYS_MQ_OPEN = 240;
+	SYS_MQ_UNLINK = 241;
+	SYS_MQ_TIMEDSEND = 242;
+	SYS_MQ_TIMEDRECEIVE = 243;
+	SYS_MQ_NOTIFY = 244;
+	SYS_MQ_GETSETATTR = 245;
+	SYS_KEXEC_LOAD = 246;
+	SYS_WAITID = 247;
+	SYS_ADD_KEY = 248;
+	SYS_REQUEST_KEY = 249;
+	SYS_KEYCTL = 250;
+	SYS_IOPRIO_SET = 251;
+	SYS_IOPRIO_GET = 252;
+	SYS_INOTIFY_INIT = 253;
+	SYS_INOTIFY_ADD_WATCH = 254;
+	SYS_INOTIFY_RM_WATCH = 255;
+	SYS_MIGRATE_PAGES = 256;
+	SYS_OPENAT = 257;
+	SYS_MKDIRAT = 258;
+	SYS_MKNODAT = 259;
+	SYS_FCHOWNAT = 260;
+	SYS_FUTIMESAT = 261;
+	SYS_NEWFSTATAT = 262;
+	SYS_UNLINKAT = 263;
+	SYS_RENAMEAT = 264;
+	SYS_LINKAT = 265;
+	SYS_SYMLINKAT = 266;
+	SYS_READLINKAT = 267;
+	SYS_FCHMODAT = 268;
+	SYS_FACCESSAT = 269;
+	SYS_PSELECT6 = 270;
+	SYS_PPOLL = 271;
+	SYS_UNSHARE = 272;
+	SYS_SET_ROBUST_LIST = 273;
+	SYS_GET_ROBUST_LIST = 274;
+	SYS_SPLICE = 275;
+	SYS_TEE = 276;
+	SYS_SYNC_FILE_RANGE = 277;
+	SYS_VMSPLICE = 278;
+	SYS_MOVE_PAGES = 279;
+	SYS_UTIMENSAT = 280;
+	SYS_EPOLL_PWAIT = 281;
+	SYS_SIGNALFD = 282;
+	SYS_TIMERFD = 283;
+	SYS_EVENTFD = 284;
+	SYS_FALLOCATE = 285;
+)
diff --git a/src/lib/syscall/time_amd64_darwin.go b/src/lib/syscall/time_amd64_darwin.go
new file mode 100644
index 0000000..011933b
--- /dev/null
+++ b/src/lib/syscall/time_amd64_darwin.go
@@ -0,0 +1,18 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+import syscall "syscall"
+
+export func gettimeofday() (sec, nsec, errno int64) {
+	// The "1" in the call is the timeval pointer, which must be
+	// non-zero but is otherwise unused.  The results
+	// are returned in r1, r2.
+	r1, r2, err := Syscall(SYS_GETTIMEOFDAY, 1, 0, 0);
+	if err != 0 {
+		return 0, 0, err
+	}
+	return r1, r2*1000, 0
+}
diff --git a/src/lib/syscall/time_amd64_linux.go b/src/lib/syscall/time_amd64_linux.go
new file mode 100644
index 0000000..43b0501
--- /dev/null
+++ b/src/lib/syscall/time_amd64_linux.go
@@ -0,0 +1,16 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package syscall
+
+import syscall "syscall"
+
+export func gettimeofday() (sec, nsec, errno int64) {
+	var tv Timeval;
+	r1, r2, e := Syscall(SYS_GETTIMEOFDAY, TimevalPtr(&tv), 0, 0);
+	if e != 0 {
+		return 0, 0, e
+	}
+	return int64(tv.sec), int64(tv.usec*1000), 0
+}
diff --git a/src/lib/syscall/types_amd64_darwin.go b/src/lib/syscall/types_amd64_darwin.go
new file mode 100644
index 0000000..bb715cc
--- /dev/null
+++ b/src/lib/syscall/types_amd64_darwin.go
@@ -0,0 +1,191 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Types and defined constants.
+// Should be automatically generated, but is not.
+
+package syscall
+
+
+// Time
+
+export type Timespec struct {
+	sec	int64;
+	nsec	uint64;
+}
+export func TimespecPtr(t *Timespec) int64;
+
+export type Timeval struct {
+	sec	int64;
+	usec	uint32;
+}
+export func TimevalPtr(t *Timeval) int64;
+
+
+// Files
+
+export const (
+	O_RDONLY = 0x0;
+	O_WRONLY = 0x1;
+	O_RDWR = 0x2;
+	O_APPEND = 0x8;
+	O_ASYNC = 0x40;
+	O_CREAT = 0x200;
+	O_NOCTTY = 0x20000;
+	O_NONBLOCK = 0x4;
+	O_NDELAY = O_NONBLOCK;
+	O_SYNC = 0x80;
+	O_TRUNC = 0x400;
+
+	F_GETFL = 3;
+	F_SETFL = 4;
+)
+
+export type Stat struct {
+	dev	uint32;
+	mode	uint16;
+	nlink	uint16;
+	ino	uint64;
+	uid	uint32;
+	gid	uint32;
+	rdev	uint32;
+	pad1	uint32;
+	atime Timespec;
+	mtime Timespec;
+	ctime Timespec;
+	birthtime Timespec;
+	size uint64;
+	blocks uint64;
+	blksize uint32;
+	flags uint32;
+	gen uint32;
+	lspare uint32;
+	qspare [2]uint64;
+}
+export func StatPtr(s *Stat) int64;
+
+
+// Sockets
+
+export const (
+	AF_UNIX = 1;
+	AF_INET = 2;
+	AF_DATAKIT = 9;
+	AF_INET6 = 30;
+
+	SOCK_STREAM = 1;
+	SOCK_DGRAM = 2;
+	SOCK_RAW = 3;
+	SOCK_RDM = 4;
+	SOCK_SEQPACKET = 5;
+
+	SOL_SOCKET = 0xffff;
+
+	SO_REUSEADDR = 0x0004;
+	SO_KEEPALIVE = 0x0008;
+	SO_DONTROUTE = 0x0010;
+	SO_BROADCAST = 0x0020;
+	SO_USELOOPBACK = 0x0040;
+	SO_LINGER = 0x1080;
+	SO_REUSEPORT = 0x0200;
+	SO_SNDBUF = 0x1001;
+	SO_RCVBUF = 0x1002;
+	SO_SNDTIMEO = 0x1005;
+	SO_RCVTIMEO = 0x1006;
+	SO_NOSIGPIPE = 0x1022;
+
+	IPPROTO_TCP = 6;
+	IPPROTO_UDP = 17;
+
+	TCP_NODELAY = 0x01;
+
+	SOMAXCONN = 128;
+)
+
+export type SockaddrUnix struct {
+	len	byte;
+	family	byte;
+	path	[104]byte
+}
+export const SizeofSockaddrUnix = 106
+
+export type SockaddrInet4 struct {
+	len	byte;
+	family	byte;
+	port	[2]byte;
+	addr	[4]byte;
+	zero	[8]byte
+}
+export const SizeofSockaddrInet4 = 16
+
+export type SockaddrInet6 struct {
+	len	byte;
+	family	byte;
+	port	[2]byte;
+	flowinfo	[4]byte;
+	addr	[16]byte;
+	scopeid	[4]byte;
+}
+export const SizeofSockaddrInet6 = 28
+
+export type Sockaddr struct {
+	len	byte;
+	family	byte;
+	opaque	[126]byte
+}
+export const SizeofSockaddr = 128
+export func SockaddrPtr(s *Sockaddr) int64;
+
+export type Linger struct {
+	yes int32;
+	sec int32;
+}
+export func LingerPtr(l *Linger) int64;
+
+
+// Events (kqueue, kevent)
+
+export const (
+	// filters
+	EVFILT_READ = -1;
+	EVFILT_WRITE = -2;
+	EVFILT_AIO = -3;
+	EVFILT_VNODE = -4;
+	EVFILT_PROC = -5;
+	EVFILT_SIGNAL = -6;
+	EVFILT_TIMER = -7;
+	EVFILT_MACHPORT = -8;
+	EVFILT_FS = -9;
+
+	EVFILT_SYSCOUNT = 9;
+
+	// actions
+	EV_ADD = 0x0001;
+	EV_DELETE = 0x0002;
+	EV_DISABLE = 0x0008;
+	EV_RECEIPT = 0x0040;
+
+	// flags
+	EV_ONESHOT = 0x0010;
+	EV_CLEAR = 0x0020;
+	EV_RECEIPT = 0x40;
+	EV_SYSFLAGS = 0xF000;
+	EV_FLAG0 = 0x1000;
+	EV_FLAG1 = 0x2000;
+
+	// returned values
+	EV_EOF = 0x8000;
+	EV_ERROR = 0x4000
+)
+
+export type Kevent struct {
+	ident int64;
+	filter int16;
+	flags uint16;
+	fflags uint32;
+	data int64;
+	udata int64;
+}
+export func KeventPtr(e *Kevent) int64;
+
diff --git a/src/lib/syscall/types_amd64_linux.go b/src/lib/syscall/types_amd64_linux.go
new file mode 100644
index 0000000..7de1419
--- /dev/null
+++ b/src/lib/syscall/types_amd64_linux.go
@@ -0,0 +1,149 @@
+// Copyright 2009 The Go Authors.  All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// Types and defined constants.
+// Should be automatically generated, but is not.
+
+package syscall
+
+
+// Time
+
+export type Timespec struct {
+	sec	int64;
+	nsec	uint64;
+}
+export func TimespecPtr(t *Timespec) int64;
+
+export type Timeval struct {
+	sec	int64;
+	usec	uint64;
+}
+export func TimevalPtr(t *Timeval) int64;
+
+
+// Files
+
+export const (
+	O_RDONLY = 0x0;
+	O_WRONLY = 0x1;
+	O_RDWR = 0x2;
+	O_APPEND = 0x400;
+	O_ASYNC = 0x2000;
+	O_CREAT = 0x40;
+	O_NOCTTY = 0x100;
+	O_NONBLOCK = 0x800;
+	O_NDELAY = O_NONBLOCK;
+	O_SYNC = 0x1000;
+	O_TRUNC = 0x200;
+)
+
+export type Stat struct {
+	dev	uint64;
+	ino	uint64;
+	nlink	uint64;
+	mode	uint32;
+	uid	uint32;
+	gid	uint32;
+	_pad0	uint32;
+	rdev	uint64;
+	size	int64;
+	blksize	int64;
+	blocks	int64;
+	atime	Timespec;
+	mtime	Timespec;
+	ctime	Timespec;
+	_unused	[3]int64
+}
+export func StatPtr(s *Stat) int64;
+
+
+// Sockets
+
+export const (
+	AF_UNIX = 1;
+	AF_INET = 2;
+	AF_INET6 = 10;
+
+	SOCK_STREAM = 1;
+	SOCK_DGRAM = 2;
+	SOCK_RAW = 3;
+	SOCK_RDM = 4;
+	SOCK_SEQPACKET = 5;
+
+	SOL_SOCKET = 1;
+
+	SO_DEBUG = 1;
+	SO_REUSEADDR = 2;
+	SO_TYPE = 3;
+	SO_ERROR = 4;
+	SO_DONTROUTE = 5;
+	SO_BROADCAST = 6;
+	SO_SNDBUF = 7;
+	SO_RCVBUF = 8;
+	SO_SNDBUFFORCE = 32;
+	SO_RCVBUFFORCE = 33;
+	SO_KEEPALIVE = 9;
+	SO_OOBINLINE = 10;
+	SO_NO_CHECK = 11;
+	SO_PRIORITY = 12;
+	SO_LINGER = 13;
+	SO_BSDCOMPAT = 14;
+	SO_PASSCRED = 16;
+	SO_PEERCRED = 17;
+	SO_RCVLOWAT = 18;
+	SO_SNDLOWAT = 19;
+	SO_RCVTIMEO = 20;
+	SO_SNDTIMEO = 21;
+	SO_BINDTODEVICE = 25;
+
+	IPPROTO_TCP = 6;
+	IPPROTO_UDP = 17;
+
+	TCP_NODELAY = 0x01;
+
+	SOMAXCONN = 128;
+)
+
+export type SockaddrUnix struct {
+	family	uint16;
+	path	[108]byte
+}
+export const SizeofSockaddrUnix = 110
+
+export type SockaddrInet4 struct {
+	family	uint16;
+	port	[2]byte;
+	addr	[4]byte;
+	zero	[8]byte
+}
+export const SizeofSockaddrInet4 = 16
+
+export type SockaddrInet6 struct {
+	family	uint16;
+	port	[2]byte;
+	flowinfo	[4]byte;
+	addr	[16]byte;
+	scopeid	[4]byte;
+}
+export const SizeofSockaddrInet6 = 28
+
+export type Sockaddr struct {
+	family	uint16;
+	opaque	[126]byte
+}
+export const SizeofSockaddr = 128
+export func SockaddrPtr(s *Sockaddr) int64;
+
+export type Linger struct {
+	yes int32;
+	sec int32;
+}
+export func LingerPtr(l *Linger) int64;
+
+
+// Events (epoll)
+
+// TODO
+