shithub: purgatorio

Download patch

ref: f8935b5778397074d41a48205e5c7f87d7b531fe
parent: 27ca2618d4bc7642370feb39a83a3cff92495ca2
author: henesy <devnull@localhost>
date: Mon Mar 11 12:01:08 EDT 2019

merge updates from december 2018 from official repo ;; add vga font

diff: cannot open b/AIX/power/include//null: file does not exist: 'b/AIX/power/include//null' diff: cannot open b/AIX/power//null: file does not exist: 'b/AIX/power//null' diff: cannot open b/AIX//null: file does not exist: 'b/AIX//null' diff: cannot open b/NetBSD/power/include//null: file does not exist: 'b/NetBSD/power/include//null' diff: cannot open b/NetBSD/power//null: file does not exist: 'b/NetBSD/power//null' diff: cannot open b/emu/AIX//null: file does not exist: 'b/emu/AIX//null' diff: cannot open b/fonts/vga//null: file does not exist: 'b/fonts/vga//null'
--- a/.hgignore
+++ b/.hgignore
@@ -63,3 +63,12 @@
 ^libinterp/cryptmod.h
 ^libinterp/ipintsmod.h
 ^libinterp/keyringif.h
+^libinterp/drawmod.h
+^libinterp/freetypemod.h
+^libinterp/keyring.h
+^libinterp/loadermod.h
+^libinterp/mathmod.h
+^libinterp/runt.h
+^libinterp/sysmod.h
+^libinterp/tkmod.h
+^limbo/runt.h
--- /dev/null
+++ b/AIX/power/include/ar.h
@@ -1,0 +1,30 @@
+#define	ARMAG	"<bigaf>\n"
+#define	SARMAG	8
+
+#define	ARFMAG	"`\n"
+
+struct fl_hdr /* archive fixed length header - printable ascii */
+{
+	char	magic[SARMAG];	/* Archive file magic string */
+	char	memoff[20];		/* Offset to member table */
+	char	gstoff[20];		/* Offset to 32-bit global sym table */
+	char	gst64off[20];	/* Offset to 64-bit global sym table */
+	char	fstmoff[20];		/* Offset to first archive member */
+	char	lstmoff[20];		/* Offset to last archive member */
+	char	freeoff[20];		/* Offset to first mem on free list */
+};
+#define	SAR_FLHDR	(SARMAG+120)
+
+struct ar_hdr /* archive file member header - printable ascii */
+{
+	char	size[20];	/* file member size - decimal */
+	char	nxtmem[20];	/* pointer to next member -  decimal */
+	char	prvmem[20];	/* pointer to previous member -  decimal */
+	char	date[12];	/* file member date - decimal */
+	char	uid[12];	/* file member user id - decimal */
+	char	gid[12];	/* file member group id - decimal */
+	char	mode[12];	/* file member mode - octal */
+	char	namlen[4];	/* file member name length - decimal */
+	/*      and variable length name follows*/
+};
+#define	SAR_HDR	112
--- /dev/null
+++ b/AIX/power/include/emu.h
@@ -1,0 +1,25 @@
+/*
+ * system- and machine-specific declarations for emu:
+ * floating-point save and restore, signal handling primitive, and
+ * implementation of the current-process variable `up'.
+ */
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+typedef struct FPU FPU;
+struct FPU
+{
+	uchar	env[18*8];
+};
+
+#define KSTACK (32 * 1024)
+
+extern	Proc*	getup(void);
+
+#define	up	(getup())
+
+typedef sigjmp_buf osjmpbuf;
+#define	ossetjmp(buf)	sigsetjmp(buf, 1)
+
+#define	pthread_yield	sched_yield
--- /dev/null
+++ b/AIX/power/include/lib9.h
@@ -1,0 +1,509 @@
+#define _DEFAULT_SOURCE
+#define _BSD_SOURCE
+#define _LINUX_SOURCE_COMPAT
+#define _XOPEN_SOURCE  500
+#define _LARGEFILE_SOURCE	1
+#define _LARGEFILE64_SOURCE	1
+#define _FILE_OFFSET_BITS 64
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#define sync __os_sync
+#include <unistd.h>
+#undef sync
+#include <errno.h>
+#define __NO_STRING_INLINES
+#include <string.h>
+#include "math.h"
+#include <fcntl.h>
+#include <setjmp.h>
+#include <float.h>
+
+#define	getwd	infgetwd
+
+#ifndef EMU
+typedef struct Proc Proc;
+#endif
+
+#undef __LITTLE_ENDIAN
+
+#define	nil		((void*)0)
+
+typedef unsigned char	uchar;
+typedef signed char	schar;
+typedef unsigned int Rune;
+typedef long long int	vlong;
+typedef unsigned long long int	uvlong;
+typedef unsigned int u32int;
+typedef uvlong u64int;
+typedef unsigned long ulong;
+typedef unsigned short ushort;
+typedef unsigned int uint;
+
+typedef unsigned int	mpdigit;	/* for /sys/include/mp.h */
+typedef unsigned short u16int;
+typedef unsigned char u8int;
+typedef unsigned long uintptr;
+
+#define	USED(x)		if(x){}else{}
+#define	SET(x)
+
+#undef nelem
+#define	nelem(x)	(sizeof(x)/sizeof((x)[0]))
+#undef offsetof
+#define	offsetof(s, m)	(ulong)(&(((s*)0)->m))
+#undef assert
+#define	assert(x)	if(x){}else _assert("x")
+
+/*
+ * most mem and string routines are declared by ANSI/POSIX files above
+ */
+
+extern	char*	strecpy(char*, char*, char*);
+extern	char*	strdup(const char*);
+extern	int	cistrncmp(char*, char*, int);
+extern	int	cistrcmp(char*, char*);
+extern	char*	cistrstr(char*, char*);
+extern	int	tokenize(char*, char**, int);
+
+enum
+{
+	UTFmax		= 4,		/* maximum bytes per rune */
+	Runesync	= 0x80,		/* cannot represent part of a UTF sequence (<) */
+	Runeself	= 0x80,		/* rune and UTF sequences are the same (<) */
+	Runeerror	= 0xFFFD,	/* decoding error in UTF */
+	Runemax		= 0x10FFFF,	/* 21-bit rune */
+	Runemask	= 0x1FFFFF,	/* bits used by runes (see grep) */
+};
+
+/*
+ * rune routines
+ */
+extern	int	runetochar(char*, Rune*);
+extern	int	chartorune(Rune*, char*);
+extern	int	runelen(long);
+extern	int	runenlen(Rune*, int);
+extern	int	fullrune(char*, int);
+extern	int	utflen(char*);
+extern	int	utfnlen(char*, long);
+extern	char*	utfrune(char*, long);
+extern	char*	utfrrune(char*, long);
+extern	char*	utfutf(char*, char*);
+extern	char*	utfecpy(char*, char*, char*);
+
+extern	Rune*	runestrcat(Rune*, Rune*);
+extern	Rune*	runestrchr(Rune*, Rune);
+extern	int	runestrcmp(Rune*, Rune*);
+extern	Rune*	runestrcpy(Rune*, Rune*);
+extern	Rune*	runestrncpy(Rune*, Rune*, long);
+extern	Rune*	runestrecpy(Rune*, Rune*, Rune*);
+extern	Rune*	runestrdup(Rune*);
+extern	Rune*	runestrncat(Rune*, Rune*, long);
+extern	int	runestrncmp(Rune*, Rune*, long);
+extern	Rune*	runestrrchr(Rune*, Rune);
+extern	long	runestrlen(Rune*);
+extern	Rune*	runestrstr(Rune*, Rune*);
+
+extern	Rune	tolowerrune(Rune);
+extern	Rune	totitlerune(Rune);
+extern	Rune	toupperrune(Rune);
+extern	int	isalpharune(Rune);
+extern	int	islowerrune(Rune);
+extern	int	isspacerune(Rune);
+extern	int	istitlerune(Rune);
+extern	int	isupperrune(Rune);
+
+/*
+ * malloc
+ */
+extern	void*	malloc(size_t);
+extern	void*	mallocz(ulong, int);
+extern	void	free(void*);
+extern	ulong	msize(void*);
+extern	void*	calloc(size_t, size_t);
+extern	void*	realloc(void*, size_t);
+extern	void		setmalloctag(void*, ulong);
+extern	void		setrealloctag(void*, ulong);
+extern	ulong	getmalloctag(void*);
+extern	ulong	getrealloctag(void*);
+extern	void*	malloctopoolblock(void*);
+
+/*
+ * print routines
+ */
+typedef struct Fmt	Fmt;
+struct Fmt{
+	uchar	runes;			/* output buffer is runes or chars? */
+	void	*start;			/* of buffer */
+	void	*to;			/* current place in the buffer */
+	void	*stop;			/* end of the buffer; overwritten if flush fails */
+	int	(*flush)(Fmt *);	/* called when to == stop */
+	void	*farg;			/* to make flush a closure */
+	int	nfmt;			/* num chars formatted so far */
+	va_list	args;			/* args passed to dofmt */
+	int	r;			/* % format Rune */
+	int	width;
+	int	prec;
+	ulong	flags;
+};
+
+enum{
+	FmtWidth	= 1,
+	FmtLeft		= FmtWidth << 1,
+	FmtPrec		= FmtLeft << 1,
+	FmtSharp	= FmtPrec << 1,
+	FmtSpace	= FmtSharp << 1,
+	FmtSign		= FmtSpace << 1,
+	FmtZero		= FmtSign << 1,
+	FmtUnsigned	= FmtZero << 1,
+	FmtShort	= FmtUnsigned << 1,
+	FmtLong		= FmtShort << 1,
+	FmtVLong	= FmtLong << 1,
+	FmtComma	= FmtVLong << 1,
+	FmtByte	= FmtComma << 1,
+
+	FmtFlag		= FmtByte << 1
+};
+
+extern	int	print(char*, ...);
+extern	char*	seprint(char*, char*, char*, ...);
+extern	char*	vseprint(char*, char*, char*, va_list);
+extern	int	snprint(char*, int, char*, ...);
+extern	int	vsnprint(char*, int, char*, va_list);
+extern	char*	smprint(char*, ...);
+extern	char*	vsmprint(char*, va_list);
+extern	int	sprint(char*, char*, ...);
+extern	int	fprint(int, char*, ...);
+extern	int	vfprint(int, char*, va_list);
+
+extern	int	runesprint(Rune*, char*, ...);
+extern	int	runesnprint(Rune*, int, char*, ...);
+extern	int	runevsnprint(Rune*, int, char*, va_list);
+extern	Rune*	runeseprint(Rune*, Rune*, char*, ...);
+extern	Rune*	runevseprint(Rune*, Rune*, char*, va_list);
+extern	Rune*	runesmprint(char*, ...);
+extern	Rune*	runevsmprint(char*, va_list);
+
+extern	int	fmtfdinit(Fmt*, int, char*, int);
+extern	int	fmtfdflush(Fmt*);
+extern	int	fmtstrinit(Fmt*);
+extern	char*	fmtstrflush(Fmt*);
+extern	int	runefmtstrinit(Fmt*);
+extern	Rune*	runefmtstrflush(Fmt*);
+
+extern	int	fmtinstall(int, int (*)(Fmt*));
+extern	int	dofmt(Fmt*, char*);
+extern	int	dorfmt(Fmt*, Rune*);
+extern	int	fmtprint(Fmt*, char*, ...);
+extern	int	fmtvprint(Fmt*, char*, va_list);
+extern	int	fmtrune(Fmt*, int);
+extern	int	fmtstrcpy(Fmt*, char*);
+extern	int	fmtrunestrcpy(Fmt*, Rune*);
+/*
+ * error string for %r
+ * supplied on per os basis, not part of fmt library
+ */
+extern	int	errfmt(Fmt *f);
+
+/*
+ * quoted strings
+ */
+extern	char	*unquotestrdup(char*);
+extern	Rune	*unquoterunestrdup(Rune*);
+extern	char	*quotestrdup(char*);
+extern	Rune	*quoterunestrdup(Rune*);
+extern	int	quotestrfmt(Fmt*);
+extern	int	quoterunestrfmt(Fmt*);
+extern	void	quotefmtinstall(void);
+extern	int	(*doquote)(int);
+
+/*
+ * random number
+ */
+extern	ulong	truerand(void);
+extern	ulong	ntruerand(ulong);
+
+/*
+ * math
+ */
+extern	int	isNaN(double);
+extern	double	NaN(void);
+extern	int	isInf(double, int);
+
+/*
+ * Time-of-day
+ */
+
+typedef struct Tm Tm;
+struct Tm {
+	int	sec;
+	int	min;
+	int	hour;
+	int	mday;
+	int	mon;
+	int	year;
+	int	wday;
+	int	yday;
+	char	zone[4];
+	int	tzoff;
+};
+extern	vlong	osnsec(void);
+#define	nsec	osnsec
+	
+/*
+ * one-of-a-kind
+ */
+extern	void	_assert(char*);
+extern	double	charstod(int(*)(void*), void*);
+extern	char*	cleanname(char*);
+extern	uintptr	getcallerpc(void*);
+extern	int	getfields(char*, char**, int, int, char*);
+extern	char*	getuser(void);
+extern	char*	getwd(char*, int);
+extern	double	ipow10(int);
+#define	pow10	infpow10
+extern	double	pow10(int);
+extern	vlong	strtoll(const char*, char**, int);
+#define	qsort	infqsort
+extern	void	qsort(void*, long, long, int (*)(void*, void*));
+extern	uvlong	strtoull(const char*, char**, int);
+extern	void	sysfatal(char*, ...);
+extern	int	dec64(uchar*, int, char*, int);
+extern	int	enc64(char*, int, uchar*, int);
+extern	int	dec32(uchar*, int, char*, int);
+extern	int	enc32(char*, int, uchar*, int);
+extern	int	dec16(uchar*, int, char*, int);
+extern	int	enc16(char*, int, uchar*, int);
+extern	int	encodefmt(Fmt*);
+
+/*
+ *  synchronization
+ */
+typedef
+struct Lock {
+	int	val;
+	int	pid;
+} Lock;
+
+extern int	_tas(int*);
+
+extern	void	lock(Lock*);
+extern	void	unlock(Lock*);
+extern	int	canlock(Lock*);
+
+typedef struct QLock QLock;
+struct QLock
+{
+	Lock	use;			/* to access Qlock structure */
+	Proc	*head;			/* next process waiting for object */
+	Proc	*tail;			/* last process waiting for object */
+	int	locked;			/* flag */
+};
+
+extern	void	qlock(QLock*);
+extern	void	qunlock(QLock*);
+extern	int	canqlock(QLock*);
+extern	void	_qlockinit(ulong (*)(ulong, ulong));	/* called only by the thread library */
+
+typedef
+struct RWLock
+{
+	Lock	l;			/* Lock modify lock */
+	QLock	x;			/* Mutual exclusion lock */
+	QLock	k;			/* Lock for waiting writers */
+	int	readers;		/* Count of readers in lock */
+} RWLock;
+
+extern	int	canrlock(RWLock*);
+extern	int	canwlock(RWLock*);
+extern	void	rlock(RWLock*);
+extern	void	runlock(RWLock*);
+extern	void	wlock(RWLock*);
+extern	void	wunlock(RWLock*);
+
+/*
+ * network dialing
+ */
+#define NETPATHLEN 40
+
+/*
+ * system calls
+ *
+ */
+#define	STATMAX	65535U	/* max length of machine-independent stat structure */
+#define	DIRMAX	(sizeof(Dir)+STATMAX)	/* max length of Dir structure */
+#define	ERRMAX	128	/* max length of error string */
+
+#define	MORDER	0x0003	/* mask for bits defining order of mounting */
+#define	MREPL	0x0000	/* mount replaces object */
+#define	MBEFORE	0x0001	/* mount goes before others in union directory */
+#define	MAFTER	0x0002	/* mount goes after others in union directory */
+#define	MCREATE	0x0004	/* permit creation in mounted directory */
+#define	MCACHE	0x0010	/* cache some data */
+#define	MMASK	0x0017	/* all bits on */
+
+#define	OREAD	0	/* open for read */
+#define	OWRITE	1	/* write */
+#define	ORDWR	2	/* read and write */
+#define	OEXEC	3	/* execute, == read but check execute permission */
+#define	OTRUNC	16	/* or'ed in (except for exec), truncate file first */
+#define	OCEXEC	32	/* or'ed in, close on exec */
+#define	ORCLOSE	64	/* or'ed in, remove on close */
+#define	OEXCL	0x1000	/* or'ed in, exclusive use (create only) */
+
+#define	AEXIST	0	/* accessible: exists */
+#define	AEXEC	1	/* execute access */
+#define	AWRITE	2	/* write access */
+#define	AREAD	4	/* read access */
+
+/* bits in Qid.type */
+#define QTDIR		0x80		/* type bit for directories */
+#define QTAPPEND	0x40		/* type bit for append only files */
+#define QTEXCL		0x20		/* type bit for exclusive use files */
+#define QTMOUNT		0x10		/* type bit for mounted channel */
+#define QTAUTH		0x08		/* type bit for authentication file */
+#define QTFILE		0x00		/* plain file */
+
+/* bits in Dir.mode */
+#define DMDIR		0x80000000	/* mode bit for directories */
+#define DMAPPEND	0x40000000	/* mode bit for append only files */
+#define DMEXCL		0x20000000	/* mode bit for exclusive use files */
+#define DMMOUNT		0x10000000	/* mode bit for mounted channel */
+#define DMAUTH		0x08000000	/* mode bit for authentication file */
+#define DMREAD		0x4		/* mode bit for read permission */
+#define DMWRITE		0x2		/* mode bit for write permission */
+#define DMEXEC		0x1		/* mode bit for execute permission */
+
+typedef
+struct Qid
+{
+	uvlong	path;
+	ulong	vers;
+	uchar	type;
+} Qid;
+
+typedef
+struct Dir {
+	/* system-modified data */
+	ushort	type;	/* server type */
+	uint	dev;	/* server subtype */
+	/* file data */
+	Qid	qid;	/* unique id from server */
+	ulong	mode;	/* permissions */
+	ulong	atime;	/* last read time */
+	ulong	mtime;	/* last write time */
+	vlong	length;	/* file length */
+	char	*name;	/* last element of path */
+	char	*uid;	/* owner name */
+	char	*gid;	/* group name */
+	char	*muid;	/* last modifier name */
+} Dir;
+
+extern	Dir*	dirstat(char*);
+extern	Dir*	dirfstat(int);
+extern	int	dirwstat(char*, Dir*);
+extern	int	dirfwstat(int, Dir*);
+extern	long	dirread(int, Dir**);
+extern	void	nulldir(Dir*);
+extern	long	dirreadall(int, Dir**);
+
+typedef
+struct Waitmsg
+{
+	int pid;	/* of loved one */
+	ulong time[3];	/* of loved one & descendants */
+	char	*msg;
+} Waitmsg;
+
+extern	void	_exits(char*);
+
+extern	void	exits(char*);
+extern	int	create(char*, int, int);
+extern	int	errstr(char*, uint);
+
+extern	void	perror(const char*);
+extern	long	readn(int, void*, long);
+extern	int	remove(const char*);
+extern	void	rerrstr(char*, uint);
+extern	vlong	seek(int, vlong, int);
+extern	int	segflush(void*, ulong);
+extern	void	werrstr(char*, ...);
+
+extern char *argv0;
+#define	ARGBEGIN	for((argv0||(argv0=*argv)),argv++,argc--;\
+			    argv[0] && argv[0][0]=='-' && argv[0][1];\
+			    argc--, argv++) {\
+				char *_args, *_argt;\
+				Rune _argc;\
+				_args = &argv[0][1];\
+				if(_args[0]=='-' && _args[1]==0){\
+					argc--; argv++; break;\
+				}\
+				_argc = 0;\
+				while(*_args && (_args += chartorune(&_argc, _args)))\
+				switch(_argc)
+#define	ARGEND		SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
+#define	ARGF()		(_argt=_args, _args="",\
+				(*_argt? _argt: argv[1]? (argc--, *++argv): 0))
+#define	EARGF(x)	(_argt=_args, _args="",\
+				(*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
+
+#define	ARGC()		_argc
+
+/*
+ *	Extensions for Inferno to basic libc.h
+ */
+
+#define	setbinmode()
+
+extern	void	setfcr(ulong);
+extern	void	setfsr(ulong);
+extern	ulong	getfcr(void);
+extern	ulong	getfsr(void);
+
+
+/* FPSCR */
+#define	FPSFX	(1<<31)	/* exception summary (sticky) */
+#define	FPSEX	(1<<30)	/* enabled exception summary */
+#define	FPSVX	(1<<29)	/* invalid operation exception summary */
+#define	FPSOX	(1<<28)	/* overflow exception OX (sticky) */
+#define	FPSUX	(1<<27)	/* underflow exception UX (sticky) */
+#define	FPSZX	(1<<26)	/* zero divide exception ZX (sticky) */
+#define	FPSXX	(1<<25)	/* inexact exception XX (sticky) */
+#define	FPSVXSNAN (1<<24)	/* invalid operation exception for SNaN (sticky) */
+#define	FPSVXISI	(1<<23)	/* invalid operation exception for ∞-∞ (sticky) */
+#define	FPSVXIDI	(1<<22)	/* invalid operation exception for ∞/∞ (sticky) */
+#define	FPSVXZDZ (1<<21)	/* invalid operation exception for 0/0 (sticky) */
+#define	FPSVXIMZ	(1<<20)	/* invalid operation exception for ∞*0 (sticky) */
+#define	FPSVXVC	(1<<19)	/* invalid operation exception for invalid compare (sticky) */
+#define	FPSFR	(1<<18)	/* fraction rounded */
+#define	FPSFI	(1<<17)	/* fraction inexact */
+#define	FPSFPRF	(1<<16)	/* floating point result class */
+#define	FPSFPCC	(0xF<<12)	/* <, >, =, unordered */
+#define	FPVXCVI	(1<<8)	/* enable exception for invalid integer convert (sticky) */
+
+/* FCR */
+#define	FPVE	(1<<7)	/* invalid operation exception enable */
+#define	FPOVFL	(1<<6)	/* enable overflow exceptions */
+#define	FPUNFL	(1<<5)	/* enable underflow */
+#define	FPZDIV	(1<<4)	/* enable zero divide */
+#define	FPINEX	(1<<3)	/* enable inexact exceptions */
+#define	FPRMASK	(3<<0)	/* rounding mode */
+#define	FPRNR	(0<<0)
+#define	FPRZ	(1<<0)
+#define	FPRPINF	(2<<0)
+#define	FPRNINF	(3<<0)
+#define	FPPEXT	0
+#define	FPPSGL	0
+#define	FPPDBL	0
+#define	FPPMASK	0
+#define	FPINVAL	FPVE
+/* FSR */
+#define	FPAOVFL	FPSOX
+#define	FPAINEX	FPSXX
+#define	FPAUNFL	FPSUX
+#define	FPAZDIV	FPSZX
+#define	FPAINVAL	FPSVX
+
--- a/FreeBSD/386/include/lib9.h
+++ b/FreeBSD/386/include/lib9.h
@@ -473,31 +473,3 @@
 
 #define	setbinmode()
 
-/* floating point things to get it to build. (stolen from netbsd) */
-
-/* FCR */
-#define	FPINEX	(1<<5)
-#define	FPUNFL	((1<<4)|(1<<1))
-#define	FPOVFL	(1<<3)
-#define	FPZDIV	(1<<2)
-#define	FPINVAL	(1<<0)
-#define	FPRNR	(0<<10)
-#define	FPRZ	(3<<10)
-#define	FPRPINF	(2<<10)
-#define	FPRNINF	(1<<10)
-#define	FPRMASK	(3<<10)
-#define	FPPEXT	(3<<8)
-#define	FPPSGL	(0<<8)
-#define	FPPDBL	(2<<8)
-#define	FPPMASK	(3<<8)
-/* FSR */
-#define	FPAINEX	FPINEX
-#define	FPAOVFL	FPOVFL
-#define	FPAUNFL	FPUNFL
-#define	FPAZDIV	FPZDIV
-#define	FPAINVAL	FPINVAL
-
-extern	void	setfcr(ulong);
-extern	void	setfsr(ulong);
-extern	ulong	getfcr(void);
-extern	ulong	getfsr(void);
binary files a/Linux/386/bin/c2l b/Linux/386/bin/c2l differ
binary files a/Linux/386/bin/data2c b/Linux/386/bin/data2c differ
binary files a/Linux/386/bin/ftl b/Linux/386/bin/ftl differ
binary files a/Linux/386/bin/iar b/Linux/386/bin/iar differ
binary files a/Linux/386/bin/idea b/Linux/386/bin/idea differ
binary files a/Linux/386/bin/inm b/Linux/386/bin/inm differ
binary files a/Linux/386/bin/iyacc b/Linux/386/bin/iyacc differ
binary files a/Linux/386/bin/kprof b/Linux/386/bin/kprof differ
binary files a/Linux/386/bin/ksize b/Linux/386/bin/ksize differ
binary files a/Linux/386/bin/kstrip b/Linux/386/bin/kstrip differ
binary files a/Linux/386/bin/md5sum b/Linux/386/bin/md5sum differ
binary files a/Linux/386/bin/mk b/Linux/386/bin/mk differ
binary files a/Linux/386/bin/mk.save b/Linux/386/bin/mk.save differ
binary files a/Linux/386/bin/mkext b/Linux/386/bin/mkext differ
binary files a/Linux/386/bin/mkppcimage b/Linux/386/bin/mkppcimage differ
binary files a/Linux/386/bin/ms2 b/Linux/386/bin/ms2 differ
binary files a/Linux/386/bin/ndate b/Linux/386/bin/ndate differ
binary files a/Linux/386/bin/sqz b/Linux/386/bin/sqz differ
binary files a/Linux/386/bin/srclist b/Linux/386/bin/srclist differ
binary files a/Linux/386/bin/styxtest b/Linux/386/bin/styxtest differ
--- a/NetBSD/386/include/lib9.h
+++ b/NetBSD/386/include/lib9.h
@@ -244,6 +244,7 @@
  * math
  */
 extern	int	isNaN(double);
+extern	double	NaN(void);
 extern	int	isInf(double, int);
 extern	double	pow(double, double);
 
--- /dev/null
+++ b/NetBSD/power/include/emu.h
@@ -1,0 +1,28 @@
+/*
+ * system- and machine-specific declarations for emu:
+ * floating-point save and restore, signal handling primitive, and
+ * implementation of the current-process variable `up'.
+ */
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+typedef struct FPU FPU;
+struct FPU
+{
+	uchar	env[18*8];
+};
+
+#define KSTACK (32 * 1024)
+
+static __inline Proc *getup(void) {
+	Proc *p;
+	__asm__(	"mr	%0, 1" : "=r" (p));
+	return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
+};
+
+#define	up	(getup())
+
+typedef sigjmp_buf osjmpbuf;
+#define	ossetjmp(buf)	sigsetjmp(buf, 1)
+
--- /dev/null
+++ b/NetBSD/power/include/lib9.h
@@ -1,0 +1,527 @@
+#include <sys/types.h>
+#include <sys/endian.h>
+#include <sys/stat.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <math.h>
+#include <fcntl.h>
+#include <setjmp.h>
+#include <float.h>
+#include <time.h>
+
+#define	getwd	infgetwd
+
+#define	round	infround
+#define	fmax	inffmax
+#define	log2	inflog2
+
+#ifndef EMU
+typedef struct Proc Proc;
+#endif
+
+/*
+ * math module dtoa
+ */
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+#define __LITTLE_ENDIAN
+#endif
+
+#define	nil		((void*)0)
+
+typedef unsigned char	uchar;
+typedef signed char	schar;
+#if 0 /* XXX: uwe: already defined in <sys/types.h> */
+typedef unsigned long	ulong;
+#endif
+
+typedef int64_t		vlong;
+typedef uint64_t	uvlong;
+
+typedef uint8_t		u8int;
+typedef uint16_t	u16int;
+typedef uint32_t	u32int;
+typedef uvlong u64int;
+
+typedef uintptr_t	uintptr;
+
+typedef signed char	int8;
+typedef unsigned char	uint8;
+typedef short	int16;
+typedef unsigned short	uint16;
+typedef int	int32;
+typedef unsigned int	uint32;
+typedef long long	int64;
+typedef unsigned long long	uint64;
+
+typedef unsigned int Rune;
+typedef unsigned int	mpdigit;	/* for /sys/include/mp.h */
+
+
+#define	USED(x)		if(x){}else{}
+#define	SET(x)
+
+#undef nelem
+#define	nelem(x)	(sizeof(x)/sizeof((x)[0]))
+#undef offsetof
+#define	offsetof(s, m)	(ulong)(&(((s*)0)->m))
+#undef assert
+#define	assert(x)	if(x){}else _assert(#x)
+
+/*
+ * most mem and string routines are declared by ANSI/POSIX files above
+ */
+
+extern	char*	strecpy(char*, char*, char*);
+extern	char*	strdup(const char*);
+extern	int	cistrncmp(char*, char*, int);
+extern	int	cistrcmp(char*, char*);
+extern	char*	cistrstr(char*, char*);
+extern	int	tokenize(char*, char**, int);
+
+enum
+{
+	UTFmax		= 4,		/* maximum bytes per rune */
+	Runesync	= 0x80,		/* cannot represent part of a UTF sequence (<) */
+	Runeself	= 0x80,		/* rune and UTF sequences are the same (<) */
+	Runeerror	= 0xFFFD,	/* decoding error in UTF */
+	Runemax		= 0x10FFFF,	/* 21-bit rune */
+	Runemask	= 0x1FFFFF,	/* bits used by runes (see grep) */
+};
+
+/*
+ * rune routines
+ */
+extern	int	runetochar(char*, Rune*);
+extern	int	chartorune(Rune*, char*);
+extern	int	runelen(long);
+extern	int	runenlen(Rune*, int);
+extern	int	fullrune(char*, int);
+extern	int	utflen(char*);
+extern	int	utfnlen(char*, long);
+extern	char*	utfrune(char*, long);
+extern	char*	utfrrune(char*, long);
+extern	char*	utfutf(char*, char*);
+extern	char*	utfecpy(char*, char*, char*);
+
+extern	Rune*	runestrcat(Rune*, Rune*);
+extern	Rune*	runestrchr(Rune*, Rune);
+extern	int	runestrcmp(Rune*, Rune*);
+extern	Rune*	runestrcpy(Rune*, Rune*);
+extern	Rune*	runestrncpy(Rune*, Rune*, long);
+extern	Rune*	runestrecpy(Rune*, Rune*, Rune*);
+extern	Rune*	runestrdup(Rune*);
+extern	Rune*	runestrncat(Rune*, Rune*, long);
+extern	int	runestrncmp(Rune*, Rune*, long);
+extern	Rune*	runestrrchr(Rune*, Rune);
+extern	long	runestrlen(Rune*);
+extern	Rune*	runestrstr(Rune*, Rune*);
+
+extern	Rune	tolowerrune(Rune);
+extern	Rune	totitlerune(Rune);
+extern	Rune	toupperrune(Rune);
+extern	int	isalpharune(Rune);
+extern	int	islowerrune(Rune);
+extern	int	isspacerune(Rune);
+extern	int	istitlerune(Rune);
+extern	int	isupperrune(Rune);
+
+/*
+ * malloc
+ */
+extern	void*	malloc(size_t);
+extern	void*	mallocz(ulong, int);
+extern	void	free(void*);
+extern	ulong	msize(void*);
+extern	void*	calloc(size_t, size_t);
+extern	void*	realloc(void*, size_t);
+extern	void		setmalloctag(void*, ulong);
+extern	void		setrealloctag(void*, ulong);
+extern	ulong	getmalloctag(void*);
+extern	ulong	getrealloctag(void*);
+extern	void*	malloctopoolblock(void*);
+
+/*
+ * print routines
+ */
+typedef struct Fmt	Fmt;
+struct Fmt{
+	uchar	runes;			/* output buffer is runes or chars? */
+	void	*start;			/* of buffer */
+	void	*to;			/* current place in the buffer */
+	void	*stop;			/* end of the buffer; overwritten if flush fails */
+	int	(*flush)(Fmt *);	/* called when to == stop */
+	void	*farg;			/* to make flush a closure */
+	int	nfmt;			/* num chars formatted so far */
+	va_list	args;			/* args passed to dofmt */
+	int	r;			/* % format Rune */
+	int	width;
+	int	prec;
+	ulong	flags;
+};
+
+enum{
+	FmtWidth	= 1,
+	FmtLeft		= FmtWidth << 1,
+	FmtPrec		= FmtLeft << 1,
+	FmtSharp	= FmtPrec << 1,
+	FmtSpace	= FmtSharp << 1,
+	FmtSign		= FmtSpace << 1,
+	FmtZero		= FmtSign << 1,
+	FmtUnsigned	= FmtZero << 1,
+	FmtShort	= FmtUnsigned << 1,
+	FmtLong		= FmtShort << 1,
+	FmtVLong	= FmtLong << 1,
+	FmtComma	= FmtVLong << 1,
+	FmtByte	= FmtComma << 1,
+
+	FmtFlag		= FmtByte << 1
+};
+
+extern	int	print(char*, ...);
+extern	char*	seprint(char*, char*, char*, ...);
+extern	char*	vseprint(char*, char*, char*, va_list);
+extern	int	snprint(char*, int, char*, ...);
+extern	int	vsnprint(char*, int, char*, va_list);
+extern	char*	smprint(char*, ...);
+extern	char*	vsmprint(char*, va_list);
+extern	int	sprint(char*, char*, ...);
+extern	int	fprint(int, char*, ...);
+extern	int	vfprint(int, char*, va_list);
+
+extern	int	runesprint(Rune*, char*, ...);
+extern	int	runesnprint(Rune*, int, char*, ...);
+extern	int	runevsnprint(Rune*, int, char*, va_list);
+extern	Rune*	runeseprint(Rune*, Rune*, char*, ...);
+extern	Rune*	runevseprint(Rune*, Rune*, char*, va_list);
+extern	Rune*	runesmprint(char*, ...);
+extern	Rune*	runevsmprint(char*, va_list);
+
+extern	int	fmtfdinit(Fmt*, int, char*, int);
+extern	int	fmtfdflush(Fmt*);
+extern	int	fmtstrinit(Fmt*);
+extern	char*	fmtstrflush(Fmt*);
+extern	int	runefmtstrinit(Fmt*);
+extern	Rune*	runefmtstrflush(Fmt*);
+
+extern	int	fmtinstall(int, int (*)(Fmt*));
+extern	int	dofmt(Fmt*, char*);
+extern	int	dorfmt(Fmt*, Rune*);
+extern	int	fmtprint(Fmt*, char*, ...);
+extern	int	fmtvprint(Fmt*, char*, va_list);
+extern	int	fmtrune(Fmt*, int);
+extern	int	fmtstrcpy(Fmt*, char*);
+extern	int	fmtrunestrcpy(Fmt*, Rune*);
+/*
+ * error string for %r
+ * supplied on per os basis, not part of fmt library
+ */
+extern	int	errfmt(Fmt *f);
+
+/*
+ * quoted strings
+ */
+extern	char	*unquotestrdup(char*);
+extern	Rune	*unquoterunestrdup(Rune*);
+extern	char	*quotestrdup(char*);
+extern	Rune	*quoterunestrdup(Rune*);
+extern	int	quotestrfmt(Fmt*);
+extern	int	quoterunestrfmt(Fmt*);
+extern	void	quotefmtinstall(void);
+extern	int	(*doquote)(int);
+
+/*
+ * random number
+ */
+extern	int	nrand(int);
+extern	ulong	truerand(void);
+extern	ulong	ntruerand(ulong);
+
+/*
+ * math
+ */
+extern	int	isNaN(double);
+extern	double	NaN(void);
+extern	int	isInf(double, int);
+extern	double	pow(double, double);
+
+/*
+ * Time-of-day
+ */
+
+typedef struct Tm Tm;
+struct Tm {
+	int	sec;
+	int	min;
+	int	hour;
+	int	mday;
+	int	mon;
+	int	year;
+	int	wday;
+	int	yday;
+	char	zone[4];
+	int	tzoff;
+};
+extern	vlong	osnsec(void);
+#define	nsec	osnsec
+	
+/*
+ * one-of-a-kind
+ */
+extern	void	_assert(char*);
+extern	double	charstod(int(*)(void*), void*);
+extern	char*	cleanname(char*);
+extern	double	frexp(double, int*);
+extern	ulong	getcallerpc(void*);
+extern	int	getfields(char*, char**, int, int, char*);
+extern	char*	getuser(void);
+extern	char*	getwd(char*, int);
+extern	double	ipow10(int);
+extern	double	ldexp(double, int);
+extern	double	modf(double, double*);
+#define	pow10	infpow10
+extern	double	pow10(int);
+extern	vlong	strtoll(const char*, char**, int);
+#define	qsort	infqsort
+extern	void	qsort(void*, long, long, int (*)(void*, void*));
+extern	uvlong	strtoull(const char*, char**, int);
+extern	void	sysfatal(char*, ...);
+extern	int	dec64(uchar*, int, char*, int);
+extern	int	enc64(char*, int, uchar*, int);
+extern	int	dec32(uchar*, int, char*, int);
+extern	int	enc32(char*, int, uchar*, int);
+extern	int	dec16(uchar*, int, char*, int);
+extern	int	enc16(char*, int, uchar*, int);
+extern	int	encodefmt(Fmt*);
+
+/*
+ *  synchronization
+ */
+typedef
+struct Lock {
+	int	val;
+	int	pid;
+} Lock;
+
+extern int	_tas(int*);
+
+extern	void	lock(Lock*);
+extern	void	unlock(Lock*);
+extern	int	canlock(Lock*);
+
+typedef struct QLock QLock;
+struct QLock
+{
+	Lock	use;			/* to access Qlock structure */
+	Proc	*head;			/* next process waiting for object */
+	Proc	*tail;			/* last process waiting for object */
+	int	locked;			/* flag */
+};
+
+extern	void	qlock(QLock*);
+extern	void	qunlock(QLock*);
+extern	int	canqlock(QLock*);
+extern	void	_qlockinit(ulong (*)(ulong, ulong));	/* called only by the thread library */
+
+typedef
+struct RWLock
+{
+	Lock	l;			/* Lock modify lock */
+	QLock	x;			/* Mutual exclusion lock */
+	QLock	k;			/* Lock for waiting writers */
+	int	readers;		/* Count of readers in lock */
+} RWLock;
+
+extern	int	canrlock(RWLock*);
+extern	int	canwlock(RWLock*);
+extern	void	rlock(RWLock*);
+extern	void	runlock(RWLock*);
+extern	void	wlock(RWLock*);
+extern	void	wunlock(RWLock*);
+
+/*
+ * network dialing
+ */
+#define NETPATHLEN 40
+
+/*
+ * system calls
+ *
+ */
+#define	STATMAX	65535U	/* max length of machine-independent stat structure */
+#define	DIRMAX	(sizeof(Dir)+STATMAX)	/* max length of Dir structure */
+#define	ERRMAX	128	/* max length of error string */
+
+#define	MORDER	0x0003	/* mask for bits defining order of mounting */
+#define	MREPL	0x0000	/* mount replaces object */
+#define	MBEFORE	0x0001	/* mount goes before others in union directory */
+#define	MAFTER	0x0002	/* mount goes after others in union directory */
+#define	MCREATE	0x0004	/* permit creation in mounted directory */
+#define	MCACHE	0x0010	/* cache some data */
+#define	MMASK	0x0017	/* all bits on */
+
+#define	OREAD	0	/* open for read */
+#define	OWRITE	1	/* write */
+#define	ORDWR	2	/* read and write */
+#define	OEXEC	3	/* execute, == read but check execute permission */
+#define	OTRUNC	16	/* or'ed in (except for exec), truncate file first */
+#define	OCEXEC	32	/* or'ed in, close on exec */
+#define	ORCLOSE	64	/* or'ed in, remove on close */
+#define	OEXCL	0x1000	/* or'ed in, exclusive use (create only) */
+
+#define	AEXIST	0	/* accessible: exists */
+#define	AEXEC	1	/* execute access */
+#define	AWRITE	2	/* write access */
+#define	AREAD	4	/* read access */
+
+/* bits in Qid.type */
+#define QTDIR		0x80		/* type bit for directories */
+#define QTAPPEND	0x40		/* type bit for append only files */
+#define QTEXCL		0x20		/* type bit for exclusive use files */
+#define QTMOUNT		0x10		/* type bit for mounted channel */
+#define QTAUTH		0x08		/* type bit for authentication file */
+#define QTFILE		0x00		/* plain file */
+
+/* bits in Dir.mode */
+#define DMDIR		0x80000000	/* mode bit for directories */
+#define DMAPPEND	0x40000000	/* mode bit for append only files */
+#define DMEXCL		0x20000000	/* mode bit for exclusive use files */
+#define DMMOUNT		0x10000000	/* mode bit for mounted channel */
+#define DMAUTH		0x08000000	/* mode bit for authentication file */
+#define DMREAD		0x4		/* mode bit for read permission */
+#define DMWRITE		0x2		/* mode bit for write permission */
+#define DMEXEC		0x1		/* mode bit for execute permission */
+
+typedef
+struct Qid
+{
+	uvlong	path;
+	ulong	vers;
+	uchar	type;
+} Qid;
+
+typedef
+struct Dir {
+	/* system-modified data */
+	ushort	type;	/* server type */
+	uint	dev;	/* server subtype */
+	/* file data */
+	Qid	qid;	/* unique id from server */
+	ulong	mode;	/* permissions */
+	ulong	atime;	/* last read time */
+	ulong	mtime;	/* last write time */
+	vlong	length;	/* file length */
+	char	*name;	/* last element of path */
+	char	*uid;	/* owner name */
+	char	*gid;	/* group name */
+	char	*muid;	/* last modifier name */
+} Dir;
+
+extern	Dir*	dirstat(char*);
+extern	Dir*	dirfstat(int);
+extern	int	dirwstat(char*, Dir*);
+extern	int	dirfwstat(int, Dir*);
+extern	long	dirread(int, Dir**);
+extern	void	nulldir(Dir*);
+extern	long	dirreadall(int, Dir**);
+
+typedef
+struct Waitmsg
+{
+	int pid;	/* of loved one */
+	ulong time[3];	/* of loved one & descendants */
+	char	*msg;
+} Waitmsg;
+
+extern	void	_exits(char*);
+
+extern	void	exits(char*);
+extern	int	create(char*, int, int);
+extern	int	errstr(char*, uint);
+
+extern	void	perror(const char*);
+extern	long	readn(int, void*, long);
+extern	int	remove(const char*);
+extern	void	rerrstr(char*, uint);
+extern	vlong	seek(int, vlong, int);
+extern	int	segflush(void*, ulong);
+extern	void	werrstr(char*, ...);
+
+extern char *argv0;
+#define	ARGBEGIN	for((argv0||(argv0=*argv)),argv++,argc--;\
+			    argv[0] && argv[0][0]=='-' && argv[0][1];\
+			    argc--, argv++) {\
+				char *_args, *_argt;\
+				Rune _argc;\
+				_args = &argv[0][1];\
+				if(_args[0]=='-' && _args[1]==0){\
+					argc--; argv++; break;\
+				}\
+				_argc = 0;\
+				while(*_args && (_args += chartorune(&_argc, _args)))\
+				switch(_argc)
+#define	ARGEND		SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
+#define	ARGF()		(_argt=_args, _args="",\
+				(*_argt? _argt: argv[1]? (argc--, *++argv): 0))
+#define	EARGF(x)	(_argt=_args, _args="",\
+				(*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
+
+#define	ARGC()		_argc
+
+/*
+ *	Extensions for Inferno to basic libc.h
+ */
+
+#define	setbinmode()
+
+extern	void	setfcr(ulong);
+extern	void	setfsr(ulong);
+extern	ulong	getfcr(void);
+extern	ulong	getfsr(void);
+
+
+/* FPSCR */
+#define	FPSFX	(1<<31)	/* exception summary (sticky) */
+#define	FPSEX	(1<<30)	/* enabled exception summary */
+#define	FPSVX	(1<<29)	/* invalid operation exception summary */
+#define	FPSOX	(1<<28)	/* overflow exception OX (sticky) */
+#define	FPSUX	(1<<27)	/* underflow exception UX (sticky) */
+#define	FPSZX	(1<<26)	/* zero divide exception ZX (sticky) */
+#define	FPSXX	(1<<25)	/* inexact exception XX (sticky) */
+#define	FPSVXSNAN (1<<24)	/* invalid operation exception for SNaN (sticky) */
+#define	FPSVXISI	(1<<23)	/* invalid operation exception for ∞-∞ (sticky) */
+#define	FPSVXIDI	(1<<22)	/* invalid operation exception for ∞/∞ (sticky) */
+#define	FPSVXZDZ (1<<21)	/* invalid operation exception for 0/0 (sticky) */
+#define	FPSVXIMZ	(1<<20)	/* invalid operation exception for ∞*0 (sticky) */
+#define	FPSVXVC	(1<<19)	/* invalid operation exception for invalid compare (sticky) */
+#define	FPSFR	(1<<18)	/* fraction rounded */
+#define	FPSFI	(1<<17)	/* fraction inexact */
+#define	FPSFPRF	(1<<16)	/* floating point result class */
+#define	FPSFPCC	(0xF<<12)	/* <, >, =, unordered */
+#define	FPVXCVI	(1<<8)	/* enable exception for invalid integer convert (sticky) */
+
+/* FCR */
+#define	FPVE	(1<<7)	/* invalid operation exception enable */
+#define	FPOVFL	(1<<6)	/* enable overflow exceptions */
+#define	FPUNFL	(1<<5)	/* enable underflow */
+#define	FPZDIV	(1<<4)	/* enable zero divide */
+#define	FPINEX	(1<<3)	/* enable inexact exceptions */
+#define	FPRMASK	(3<<0)	/* rounding mode */
+#define	FPRNR	(0<<0)
+#define	FPRZ	(1<<0)
+#define	FPRPINF	(2<<0)
+#define	FPRNINF	(3<<0)
+#define	FPPEXT	0
+#define	FPPSGL	0
+#define	FPPDBL	0
+#define	FPPMASK	0
+#define	FPINVAL	FPVE
+/* FSR */
+#define	FPAOVFL	FPSOX
+#define	FPAINEX	FPSXX
+#define	FPAUNFL	FPSUX
+#define	FPAZDIV	FPSZX
+#define	FPAINVAL	FPSVX
--- a/OpenBSD/386/include/emu.h
+++ b/OpenBSD/386/include/emu.h
@@ -15,6 +15,7 @@
 
 #define KSTACK (32 * 1024)
 
+#ifndef USE_PTHREADS
 static __inline Proc *getup(void) {
 	Proc *p;
 	__asm__(	"movl	%%esp, %%eax\n\t"
@@ -22,6 +23,9 @@
 	);
 	return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
 };
+#else
+extern	Proc*	getup(void);
+#endif
 
 #define	up	(getup())
 
--- a/OpenBSD/386/include/lib9.h
+++ b/OpenBSD/386/include/lib9.h
@@ -1,4 +1,5 @@
 /* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
+#define	USE_PTHREADS
 #ifndef _BSD_SOURCE
 #define _BSD_SOURCE
 #endif
@@ -5,6 +6,10 @@
 /* these aren't really needed because OpenBSD does the right thing and makes off_t 64 bits, full stop */
 #define _LARGEFILE64_SOURCE	1
 #define _FILE_OFFSET_BITS 64
+
+#ifdef USE_PTHREADS
+#define	_REENTRANT	1
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <stdlib.h>
@@ -473,3 +478,29 @@
 
 #define	setbinmode()
 
+/* FCR */
+#define FPINEX  (1<<5)
+#define FPUNFL  ((1<<4)|(1<<1))
+#define FPOVFL  (1<<3)
+#define FPZDIV  (1<<2)
+#define FPINVAL (1<<0)
+#define FPRNR   (0<<10)
+#define FPRZ    (3<<10)
+#define FPRPINF (2<<10)
+#define FPRNINF (1<<10)
+#define FPRMASK (3<<10)
+#define FPPEXT  (3<<8)
+#define FPPSGL  (0<<8)
+#define FPPDBL  (2<<8)
+#define FPPMASK (3<<8)
+/* FSR */
+#define FPAINEX FPINEX
+#define FPAOVFL FPOVFL
+#define FPAUNFL FPUNFL
+#define FPAZDIV FPZDIV
+#define FPAINVAL        FPINVAL
+
+extern  void    setfcr(ulong);
+extern  void    setfsr(ulong);
+extern  ulong   getfcr(void);
+extern  ulong   getfsr(void);
--- a/README.md
+++ b/README.md
@@ -4,6 +4,6 @@
 
 The system can be used to build portable client and server applications. It makes it straightforward to build lean applications that share all manner of resources over a network, without the cruft of much of the 'Grid' software one sees.
 
-Inferno can run 'native' on various ARM, PowerPC, SPARC and x86 platforms but also 'hosted', under an existing operating system (including FreeBSD, Irix, Linux, MacOS X, Plan 9, and Solaris), again on various processor types.
+Inferno can run 'native' on various ARM, PowerPC, SPARC and x86 platforms but also 'hosted', under an existing operating system (including AIX, FreeBSD, Irix, Linux, MacOS X, Plan 9, and Solaris), again on various processor types.
 
 This Bitbucket project includes source for the basic applications, Inferno itself (hosted and native), all supporting software, including the native compiler suite, essential executables and supporting files.
--- a/appl/acme/ecmd.b
+++ b/appl/acme/ecmd.b
@@ -1192,7 +1192,7 @@
 {
 	buf: string;
 	w: ref Window;
-	match, i, dirty: int;
+	match, dirty: int;
 	s: Rangeset;
 
 	# compile expr first so if we get an error, we haven't allocated anything
@@ -1203,7 +1203,7 @@
 	dirty = !w.isdir && !w.isscratch && f.mod;
 	buf = sprint("%c%c%c %s\n", " '"[dirty],
 		'+', " ."[curtext!=nil && curtext.file==f], f.name);
-	(match, s) = rxexecute(nil, buf, 0, i);
+	(match, s) = rxexecute(nil, buf, 0, len buf);
 	buf = nil;
 	return match;
 }
--- a/appl/cmd/limbo/limbo.y
+++ b/appl/cmd/limbo/limbo.y
@@ -655,13 +655,13 @@
 	{
 		$$ = mkids($1.src, enter("junk", 0), $3, nil);
 		$$.store = Darg;
-		yyerror("illegal argument declaraion");
+		yyerror("illegal argument declaration");
 	}
 	| idterms ':' adtk
 	{
 		$$ = mkids($1.src, enter("junk", 0), $3, nil);
 		$$.store = Darg;
-		yyerror("illegal argument declaraion");
+		yyerror("illegal argument declaration");
 	}
 	;
 
--- a/appl/cmd/limbo/types.b
+++ b/appl/cmd/limbo/types.b
@@ -1775,7 +1775,7 @@
 				+id.sym.name+" of "+stypeconv(base));
 		id.cycerr = byte 1;
 	}else if(arc & ArcCyc){
-		if((arc & ArcArray) && id.cyc == byte 0 && !(arc & ArcPolycyc)){
+		if((arc & ArcArray) && oldcycles && id.cyc == byte 0 && !(arc & ArcPolycyc)){
 			if(id.cycerr == byte 0)
 				error(base.src.start, "illegal circular reference to type "+typeconv(id.ty)
 					+" in field "+id.sym.name+" of "+stypeconv(base));
--- a/appl/cmd/m4.b
+++ b/appl/cmd/m4.b
@@ -52,8 +52,11 @@
 rquote := '\'';
 initcom := "#";
 endcom := "\n";
+prefix := "";
 bout: ref Iobuf;
 sh: Sh;
+stderr: ref Sys->FD;
+tracing := 0;
 
 init(nil: ref Draw->Context, args: list of string)
 {
@@ -61,9 +64,27 @@
 	bufio = load Bufio Bufio->PATH;
 
 	bout = bufio->fopen(sys->fildes(1), Sys->OWRITE);
+	stderr = sys->fildes(2);
 
 	define("inferno", "inferno", 0);
 
+	arg := load Arg Arg->PATH;
+	arg->setusage("m4 [-t] [-pprefix] [-Dname[=value]] [-Qname[=value]] [-Uname] [file ...]");
+	arg->init(args);
+
+	while((o := arg->opt()) != 0){
+		case o {
+		'D' or 'Q' or 'U' =>
+			;	# for second pass
+		'p' =>
+			prefix = arg->earg();
+		't' =>
+			tracing = 1;
+		* =>
+			arg->usage();
+		}
+	}
+
 	builtin("changecom", dochangecom);
 	builtin("changequote", dochangequote);
 	builtin("copydef", docopydef);
@@ -88,11 +109,9 @@
 	builtin("undefine", doundefine);
 	builtin("undivert", doundivert);
 
-	arg := load Arg Arg->PATH;
-	arg->setusage("m4 [-Dname[=value]] [-Qname[=value]] [-Uname] [file ...]");
 	arg->init(args);
 
-	while((o := arg->opt()) != 0){
+	while((o = arg->opt()) != 0){
 		case o {
 		'D' =>
 			argdefine(arg->earg(), 0);
@@ -100,6 +119,10 @@
 			argdefine(arg->earg(), 1);
 		'U' =>
 			undefine(arg->earg());
+		'p' =>
+			arg->earg();
+		't' =>
+			;
 		* =>
 			arg->usage();
 		}
@@ -157,7 +180,8 @@
 		ios := hd instack;
 		where = sys->sprint(" %s:%d:", ios.name, ios.line);
 	}
-	sys->fprint(sys->fildes(2), "m4:%s %s\n", where, s);
+	bout.flush();
+	sys->fprint(stderr, "m4:%s %s\n", where, s);
 	raise "fail:error";
 }
 
@@ -191,9 +215,12 @@
 	curarg = ref Param("");
 	nesting := 0;	# () depth
 	skipws();
+	mark := instack;
 	for(;;){
-		if((c = getc()) < 0)
+		if((c = getc()) < 0) {
+			instack = mark;
 			error("EOF in parameters");
+		}
 		if(isalpha(c))
 			called(c);
 		else if(c == lquote)
@@ -228,9 +255,12 @@
 quoted()
 {
 	nesting :=0;
+	mark := instack;
 	while((c := getc()) != rquote || nesting > 0){
-		if(c < 0)
+		if(c < 0) {
+			instack = mark;
 			error("EOF in string");
+		}
 		if(c == rquote)
 			nesting--;
 		else if(c == lquote)
@@ -276,19 +306,9 @@
 	return c == ' ' || c == '\t' || c == '\n' || c == '\r';
 }
 
-isname(s: string): int
-{
-	if(s == nil || !isalpha(s[0]))
-		return 0;
-	for(i := 1; i < len s; i++)
-		if(!(isalpha(s[i]) || s[i]>='0' && s[i]<='9'))
-			return 0;
-	return 1;
-}
-
 isalpha(c: int): int
 {
-	return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c > 16rA0;
+	return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c > 16rA0 && c != lquote && c != rquote;
 }
 
 hash(name: string): int
@@ -301,6 +321,13 @@
 
 builtin(name: string, impl: ref fn(nil: array of string))
 {
+	if(prefix != "")
+		name = prefix+name;
+	ibuiltin(name, impl);
+}
+
+ibuiltin(name: string, impl: ref fn(nil: array of string))
+{
 	h := hash(name);
 	n := ref Name(name, nil, impl, 0, 0);
 	names[h] = n :: names[h];
@@ -418,6 +445,12 @@
 
 expand(def: ref Name, args: array of string)
 {
+	if(tracing){
+		sys->fprint(stderr, "expand %s [%s]", args[0], def.name);
+		for(i := 1; i < len args; i++)
+			sys->fprint(stderr, " %d: [%s]", i, args[i]);
+		sys->fprint(stderr, "\n");
+	}
 	if(def.impl != nil){
 		def.impl(args);
 		return;
@@ -474,7 +507,7 @@
 			if(n.impl == nil)
 				define(args[2], n.repl, n.asis);
 			else
-				builtin(args[2], n.impl);
+				ibuiltin(args[2], n.impl);
 		}else
 			define(args[2], "", 0);
 	}
@@ -524,12 +557,12 @@
 
 doifdef(args: array of string)
 {
-	if(len args < 2)
+	if(len args < 3)
 		return;
 	n := lookup(args[1]);
 	if(n != nil)
 		pushs(args[2]);
-	else if(len args > 2)
+	else if(len args > 3)
 		pushs(args[3]);
 }
 
@@ -642,7 +675,7 @@
 	for(i := 1; i < len args; i++)
 		s += " "+args[i];
 	if(s != nil)
-		sys->fprint(sys->fildes(2), "m4:%s\n", s);
+		sys->fprint(stderr, "m4:%s\n", s);
 }
 
 dolen(args: array of string)
--- a/appl/math/mersenne.b
+++ b/appl/math/mersenne.b
@@ -3,9 +3,9 @@
 include "sys.m";
 	sys : Sys;
 include "draw.m";
-include "keyring.m";
-	keyring: Keyring;
-	IPint: import keyring;
+include "ipints.m";
+	ipints: IPints;
+	IPint: import ipints;
 
 # Test primality of Mersenne numbers
 
@@ -17,7 +17,7 @@
 init(nil: ref Draw->Context, argv: list of string)
 {
 	sys = load Sys Sys->PATH;
-	keyring = load Keyring Keyring->PATH;
+	ipints = load IPints IPints->PATH;
 	p := 3;
 	if(tl argv != nil)
 		p = int hd tl argv;
--- a/appl/math/parts.b
+++ b/appl/math/parts.b
@@ -3,9 +3,9 @@
 include "sys.m";
 	sys : Sys;
 include "draw.m";
-include "keyring.m";
-	keyring: Keyring;
-	IPint: import keyring;
+include "ipints.m";
+	ipints: IPints;
+	IPint: import ipints;
 
 #
 # the number p(n) of partitions of n 
@@ -25,7 +25,7 @@
 init(nil: ref Draw->Context, argv: list of string)
 {
 	sys = load Sys Sys->PATH;
-	keyring = load Keyring Keyring->PATH;
+	ipints = load IPints IPints->PATH;
 	argv = tl argv;
 	while(argv != nil){
 		s := hd argv;
--- a/doc/port.ms
+++ b/doc/port.ms
@@ -189,6 +189,7 @@
 The source is held in directory
 .CW emu ,
 with a subdirectory for each hosted platform:
+.CW AIX ,
 .CW FreeBSD ,
 .CW Irix ,
 .CW Linux ,
@@ -246,6 +247,7 @@
 .PP
 There are working emu versions
 for
+AIX/power,
 FreeBSD/386,
 Irix/mips,
 Linux/386,
--- /dev/null
+++ b/emu/AIX/asm-power.s
@@ -1,0 +1,108 @@
+.set r0,0; .set SP,1; .set RTOC,2; .set r3,3; .set r4,4
+.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
+.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
+.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
+.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
+.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
+.set r30,30; .set r31,31
+.set fp0,0; .set fp1,1; .set fp2,2; .set fp3,3; .set fp4,4
+.set fp5,5; .set fp6,6; .set fp7,7; .set fp8,8; .set fp9,9
+.set fp10,10; .set fp11,11; .set fp12,12; .set fp13,13; .set fp14,14
+.set fp15,15; .set fp16,16; .set fp17,17; .set fp18,18; .set fp19,19
+.set fp20,20; .set fp21,21; .set fp22,22; .set fp23,23; .set fp24,24
+.set fp25,25; .set fp26,26; .set fp27,27; .set fp28,28; .set fp29,29
+.set fp30,30; .set fp31,31
+.set v0,0; .set v1,1; .set v2,2; .set v3,3; .set v4,4
+.set v5,5; .set v6,6; .set v7,7; .set v8,8; .set v9,9
+.set v10,10; .set v11,11; .set v12,12; .set v13,13; .set v14,14
+.set v15,15; .set v16,16; .set v17,17; .set v18,18; .set v19,19
+.set v20,20; .set v21,21; .set v22,22; .set v23,23; .set v24,24
+.set v25,25; .set v26,26; .set v27,27; .set v28,28; .set v29,29
+.set v30,30; .set v31,31
+.set LR,8; .set CTR,9; .set TID,17; .set DSISR,18; .set DAR,19; .set TO_RTCU,20
+
+.machine "ppc"
+
+	.align	2
+	.globl	.FPsave
+.FPsave:
+	stfd	fp14,0*8(r3)
+	stfd	fp15,1*8(r3)
+	stfd	fp16,2*8(r3)
+	stfd	fp17,3*8(r3)
+	stfd	fp18,4*8(r3)
+	stfd	fp19,5*8(r3)
+	stfd	fp20,6*8(r3)
+	stfd	fp21,7*8(r3)
+	stfd	fp22,8*8(r3)
+	stfd	fp23,9*8(r3)
+	stfd	fp24,10*8(r3)
+	stfd	fp25,11*8(r3)
+	stfd	fp26,12*8(r3)
+	stfd	fp27,13*8(r3)
+	stfd	fp28,14*8(r3)
+	stfd	fp29,15*8(r3)
+	stfd	fp30,16*8(r3)
+	stfd	fp31,17*8(r3)
+	blr
+
+	.align	2
+	.globl	.FPrestore
+.FPrestore:
+	lfd		fp14,0*8(r3)
+	lfd		fp15,1*8(r3)
+	lfd		fp16,2*8(r3)
+	lfd		fp17,3*8(r3)
+	lfd		fp18,4*8(r3)
+	lfd		fp19,5*8(r3)
+	lfd		fp20,6*8(r3)
+	lfd		fp21,7*8(r3)
+	lfd		fp22,8*8(r3)
+	lfd		fp23,9*8(r3)
+	lfd		fp24,10*8(r3)
+	lfd		fp25,11*8(r3)
+	lfd		fp26,12*8(r3)
+	lfd		fp27,13*8(r3)
+	lfd		fp28,14*8(r3)
+	lfd		fp29,15*8(r3)
+	lfd		fp30,16*8(r3)
+	lfd		fp31,17*8(r3)
+	blr
+
+	.align	2
+	.globl	._tas
+._tas:
+	sync
+	mr		r4, r3
+	addi		r5,0,0x1	
+_tas_1:
+	lwarx	r3, 0, r4
+	cmpwi	r3, 0
+	bne-	_tas_2
+	stwcx.	r5, 0, r4
+	bne-	_tas_1
+_tas_2:
+	sync
+	blr
+
+	.align	2
+	.globl	.executeonnewstack
+.executeonnewstack:
+	mr		SP,r3	# change stacks
+	stwu 	LR,-16(SP)	# save lr to aid the traceback
+	li		r0,0
+	stw 	r0,20(SP)
+	mr		r3,r5
+	mtctr 	r4
+	bctrl	# tramp(arg)
+	br
+
+	.align	2
+	.globl	.unlockandexit
+.unlockandexit:
+	li	r0,0x0
+	stw	r0,0(r3)	# unlock
+	li	r0,1		# sys exit; 234 is exit group
+	li	r3,0		# exit status
+	sc
+	br
--- /dev/null
+++ b/emu/AIX/cmd.c
@@ -1,0 +1,213 @@
+#include	<sys/types.h>
+#include	<signal.h>
+#include 	<pwd.h>
+#include	<sys/resource.h>
+#include	<sys/wait.h>
+#include	<fcntl.h>
+
+#include	"dat.h"
+#include	"fns.h"
+#include	"error.h"
+
+enum
+{
+	Debug = 0
+};
+
+/*
+ * os-specific devcmd support.
+ * this version should be reasonably portable across Unix systems.
+ */
+typedef struct Targ Targ;
+struct Targ
+{
+	int	fd[3];	/* fd[0] is standard input, fd[1] is standard output, fd[2] is standard error */
+	char**	args;
+	char*	dir;
+	int	pid;
+	int	wfd;	/* child writes errors that occur after the fork or on exec */
+	int	uid;
+	int	gid;
+};
+
+extern int gidnobody;
+extern int uidnobody;
+
+static int
+childproc(Targ *t)
+{
+	int i, nfd;
+
+	if(Debug)
+		print("devcmd: '%s'", t->args[0]);
+
+	nfd = getdtablesize();
+	for(i = 0; i < nfd; i++)
+		if(i != t->fd[0] && i != t->fd[1] && i != t->fd[2] && i != t->wfd)
+			close(i);
+
+	dup2(t->fd[0], 0);
+	dup2(t->fd[1], 1);
+	dup2(t->fd[2], 2);
+	close(t->fd[0]);
+	close(t->fd[1]);
+	close(t->fd[2]);
+
+	/* should have an auth file to do host-specific authorisation? */
+	if(t->gid != -1){
+		if(setgid(t->gid) < 0 && getegid() == 0){
+			fprint(t->wfd, "can't set gid %d: %s", t->gid, strerror(errno));
+			_exit(1);
+		}
+	}
+
+	if(t->uid != -1){
+		if(setuid(t->uid) < 0 && geteuid() == 0){
+			fprint(t->wfd, "can't set uid %d: %s", t->uid, strerror(errno));
+			_exit(1);
+		}
+	}
+
+	if(t->dir != nil && chdir(t->dir) < 0){
+		fprint(t->wfd, "can't chdir to %s: %s", t->dir, strerror(errno));
+		_exit(1);
+	}
+
+	signal(SIGPIPE, SIG_DFL);
+
+	execvp(t->args[0], t->args);
+	if(Debug)
+		print("execvp: %s\n",strerror(errno));
+	fprint(t->wfd, "exec failed: %s", strerror(errno));
+
+	_exit(1);
+}
+
+void*
+oscmd(char **args, int nice, char *dir, int *fd)
+{
+	Targ *t;
+	int r, fd0[2], fd1[2], fd2[2], wfd[2], n, pid;
+
+	t = mallocz(sizeof(*t), 1);
+	if(t == nil)
+		return nil;
+
+	fd0[0] = fd0[1] = -1;
+	fd1[0] = fd1[1] = -1;
+	fd2[0] = fd2[1] = -1;
+	wfd[0] = wfd[1] = -1;
+	if(pipe(fd0) < 0 || pipe(fd1) < 0 || pipe(fd2) < 0 || pipe(wfd) < 0)
+		goto Error;
+	if(fcntl(wfd[1], F_SETFD, FD_CLOEXEC) < 0)	/* close on exec to give end of file on success */
+		goto Error;
+
+	t->fd[0] = fd0[0];
+	t->fd[1] = fd1[1];
+	t->fd[2] = fd2[1];
+	t->wfd = wfd[1];
+	t->args = args;
+	t->dir = dir;
+	t->gid = up->env->gid;
+	if(t->gid == -1)
+		t->gid = gidnobody;
+	t->uid = up->env->uid;
+	if(t->uid == -1)
+		t->uid = uidnobody;
+
+	signal(SIGCHLD, SIG_DFL);
+	switch(pid = fork()) {
+	case -1:
+		goto Error;
+	case 0:
+		setpgid(0, getpid());
+		if(nice)
+			oslopri();
+		childproc(t);
+		_exit(1);
+	default:
+		t->pid = pid;
+		if(Debug)
+			print("cmd pid %d\n", t->pid);
+		break;
+	}
+
+	close(fd0[0]);
+	close(fd1[1]);
+	close(fd2[1]);
+	close(wfd[1]);
+
+	n = read(wfd[0], up->genbuf, sizeof(up->genbuf)-1);
+	close(wfd[0]);
+	if(n > 0){
+		close(fd0[1]);
+		close(fd1[0]);
+		close(fd2[0]);
+		free(t);
+		up->genbuf[n] = 0;
+		if(Debug)
+			print("oscmd: bad exec: %q\n", up->genbuf);
+		error(up->genbuf);
+		return nil;
+	}
+
+	fd[0] = fd0[1];
+	fd[1] = fd1[0];
+	fd[2] = fd2[0];
+	return t;
+
+Error:
+	r = errno;
+	if(Debug)
+		print("oscmd: %q\n",strerror(r));
+	close(fd0[0]);
+	close(fd0[1]);
+	close(fd1[0]);
+	close(fd1[1]);
+	close(fd2[0]);
+	close(fd2[1]);
+	close(wfd[0]);
+	close(wfd[1]);
+	error(strerror(r));
+	return nil;
+}
+
+int
+oscmdkill(void *a)
+{
+	Targ *t = a;
+
+	if(Debug)
+		print("kill: %d\n", t->pid);
+	return kill(-t->pid, SIGTERM);
+}
+
+int
+oscmdwait(void *a, char *buf, int n)
+{
+	Targ *t = a;
+	int s;
+
+	if(waitpid(t->pid, &s, 0) == -1){
+		if(Debug)
+			print("wait error: %d [in %d] %q\n", t->pid, getpid(), strerror(errno));
+		return -1;
+	}
+	if(WIFEXITED(s)){
+		if(WEXITSTATUS(s) == 0)
+			return snprint(buf, n, "%d 0 0 0 ''", t->pid);
+		return snprint(buf, n, "%d 0 0 0 'exit: %d'", t->pid, WEXITSTATUS(s));
+	}
+	if(WIFSIGNALED(s)){
+		if(WTERMSIG(s) == SIGTERM || WTERMSIG(s) == SIGKILL)
+			return snprint(buf, n, "%d 0 0 0 killed", t->pid);
+		return snprint(buf, n, "%d 0 0 0 'signal: %d'", t->pid, WTERMSIG(s));
+	}
+	return snprint(buf, n, "%d 0 0 0 'odd status: 0x%x'", t->pid, s);
+}
+
+void
+oscmdfree(void *a)
+{
+	free(a);
+}
--- /dev/null
+++ b/emu/AIX/deveia.c
@@ -1,0 +1,40 @@
+/*
+ * AIX serial port definitions
+ */
+
+static char *sysdev[] = {
+        "/dev/tty0",
+        "/dev/tty1",
+        "/dev/tty2",
+        "/dev/tty3",
+        "/dev/tty4",
+        "/dev/tty5",
+        "/dev/tty6",
+        "/dev/tty7",
+};
+
+#include <sys/ioctl.h>
+#include "deveia-posix.c"
+#include "deveia-bsd.c"
+
+
+static struct tcdef_t bps[] = {
+	{0,		B0},
+	{50,		B50},
+	{75,		B75},
+	{110,		B110},
+	{134,		B134},
+	{150,		B150},
+	{200,		B200},
+	{300,		B300},
+	{600,		B600},
+	{1200,	B1200},
+	{1800,	B1800},
+	{2400,	B2400},
+	{4800,	B4800},
+	{9600,	B9600},
+	{19200,	B19200},
+	{38400,	B38400},
+	{-1,		-1}
+};
+
--- /dev/null
+++ b/emu/AIX/devfs.c
@@ -1,0 +1,7 @@
+#include "devfs-posix.c"
+
+static vlong
+osdisksize(int fd)
+{
+	return 0;
+}
--- /dev/null
+++ b/emu/AIX/emu
@@ -1,0 +1,104 @@
+dev
+	root
+	cons
+	env
+	mnt
+	pipe
+	prog
+	prof
+	srv
+	dup
+	ssl
+	cap
+	fs
+	cmd	cmd
+	indir
+
+	draw	win-x11a
+	pointer
+	snarf
+
+	ip	ipif6-posix ipaux
+	eia
+	mem
+
+lib
+	interp
+	tk
+	freetype
+	math
+	draw
+
+	memlayer
+	memdraw
+	keyring
+	sec
+	mp
+
+	9
+
+link
+
+mod
+	sys
+	draw
+
+	tk
+	math
+	srv	srv
+	keyring
+	crypt
+	ipints
+	loader
+	freetype
+
+port
+	alloc
+	cache
+	chan
+	dev
+	devtab
+
+	dial
+	dis
+	discall
+	env
+	error
+	errstr
+	exception
+	exportfs
+	inferno
+	latin1
+	main
+	parse
+	pgrp
+	print
+	proc
+	qio
+	random
+	sysfile
+	uqid
+
+code
+
+init
+	emuinit
+
+root
+	/dev	/
+	/fd	/
+	/prog	/
+	/prof	/
+	/net	/
+	/net.alt	/
+	/chan	/
+	/nvfs	/
+	/env	/
+#	/dis
+#	/n
+#	/icons
+#	/osinit.dis
+#	/dis/emuinit.dis
+#	/dis/lib/auth.dis
+#	/dis/lib/ssl.dis
+#	/n/local /
--- /dev/null
+++ b/emu/AIX/emu-g
@@ -1,0 +1,100 @@
+env
+	X11LIBS=
+dev
+	root
+	cons
+	env
+	mnt
+	pipe
+	prog
+	prof
+	srv
+	dup
+	ssl
+	cap
+	fs
+	cmd	cmd
+	indir
+
+	ip	ipif6-posix ipaux
+	eia
+	mem
+
+lib
+	interp
+	math
+	keyring
+	sec
+	mp
+
+	9
+
+link
+
+mod
+	sys
+	math
+	srv	srv
+	keyring
+	crypt
+	ipints
+	loader
+
+port
+	alloc
+	cache
+	chan
+	dev
+	devtab
+
+	dial
+	dis
+	discall
+	env
+	error
+	errstr
+	exception
+	exportfs
+	inferno
+	latin1
+	main
+	parse
+	pgrp
+	print
+	proc
+	qio
+	random
+	sysfile
+	uqid
+
+code
+	void setpointer(int x, int y){USED(x); USED(y);}
+	ulong strtochan(char *s){USED(s); return ~0;}
+
+init
+	emuinit
+
+root
+	/dev	/
+	/fd	/
+	/prog	/
+	/prof	/
+	/net	/
+	/net.alt	/
+	/chan	/
+	/nvfs	/
+	/env	/
+#	/chan
+#	/dev
+#	/dis
+#	/env
+#	/n
+#	/net
+#	/nvfs /
+#	/prog
+#	/icons
+#	/osinit.dis
+#	/dis/emuinit.dis
+#	/dis/lib/auth.dis
+#	/dis/lib/ssl.dis
+#	/n/local /
--- /dev/null
+++ b/emu/AIX/mkfile
@@ -1,0 +1,52 @@
+SYSTARG=AIX
+<../../mkconfig
+SYSTARG=AIX
+
+#Configurable parameters
+
+CONF=emu			#default configuration
+CONFLIST=emu
+CLEANCONFLIST=
+
+INSTALLDIR=$ROOT/$SYSTARG/$OBJTYPE/bin	#path of directory where kernel is installed
+
+#end configurable parameters
+
+X11LIBS= -lX11 -lXext
+
+<$ROOT/mkfiles/mkfile-$SYSTARG-$OBJTYPE	#set vars based on target system
+
+<| $SHELLNAME ../port/mkdevlist $CONF	#sets $IP, $DEVS, $PORT, $LIBS
+<mkfile-$OBJTYPE
+
+OBJ=\
+	asm-$OBJTYPE.$O\
+	$ARCHFILES\
+	os.$O\
+	kproc-pthreads.$O\
+	segflush-$OBJTYPE.$O\
+	$CONF.root.$O\
+	lock.$O\
+	$DEVS\
+	$PORT\
+
+LIBNAMES=${LIBS:%=lib%.a}
+
+HFILES=\
+
+CFLAGS='-DROOT="'$ROOT'"' -DEMU -I. -I../port -I$ROOT/$SYSTARG/$OBJTYPE/include -I$ROOT/include -I$ROOT/libinterp $CTHREADFLAGS $CFLAGS $EMUOPTIONS
+SYSLIBS= $X11LIBS -lm -lpthread
+KERNDATE=`{$NDATE}
+
+default:V:	$O.$CONF
+
+$O.$CONF:	$OBJ $CONF.c $CONF.root.h $LIBNAMES
+	$CC $CFLAGS '-DKERNDATE='$KERNDATE $CONF.c
+	$LD $LDFLAGS -o $target $OBJ $CONF.$O $LIBFILES $SYSLIBS
+
+install:V: $O.$CONF
+	cp $O.$CONF $INSTALLDIR/$CONF
+
+<../port/portmkfile
+
+devfs.$O:	../port/devfs-posix.c
--- /dev/null
+++ b/emu/AIX/os.c
@@ -1,0 +1,300 @@
+#include	<sys/types.h>
+#include	<time.h>
+#include	<termios.h>
+#include	<signal.h>
+#include 	<pwd.h>
+#include	<sched.h>
+#include	<sys/resource.h>
+#include	<sys/wait.h>
+#include	<sys/time.h>
+
+#include	<stdint.h>
+
+#include	"dat.h"
+#include	"fns.h"
+#include	"error.h"
+
+#include <semaphore.h>
+
+#include	<raise.h>
+
+enum
+{
+	DELETE	= 0x7f,
+	CTRLC	= 'C'-'@',
+	NSTACKSPERALLOC = 16,
+	X11STACK=	256*1024
+};
+char *hosttype = "Linux";
+
+typedef sem_t	Sem;
+
+extern int dflag;
+
+int	gidnobody = -1;
+int	uidnobody = -1;
+static struct 	termios tinit;
+
+static void
+sysfault(char *what, void *addr)
+{
+	char buf[64];
+
+	snprint(buf, sizeof(buf), "sys: %s%#p", what, addr);
+	disfault(nil, buf);
+}
+
+static void
+trapILL(int signo, siginfo_t *si, void *a)
+{
+	USED(signo);
+	USED(a);
+	sysfault("illegal instruction pc=", si->si_addr);
+}
+
+static int
+isnilref(siginfo_t *si)
+{
+	return si != 0 && (si->si_addr == (void*)~(uintptr_t)0 || (uintptr_t)si->si_addr < 512);
+}
+
+static void
+trapmemref(int signo, siginfo_t *si, void *a)
+{
+	USED(a);	/* ucontext_t*, could fetch pc in machine-dependent way */
+	if(isnilref(si))
+		disfault(nil, exNilref);
+	else if(signo == SIGBUS)
+		sysfault("bad address addr=", si->si_addr);	/* eg, misaligned */
+	else
+		sysfault("segmentation violation addr=", si->si_addr);
+}
+
+static void
+trapFPE(int signo, siginfo_t *si, void *a)
+{
+	char buf[64];
+
+	USED(signo);
+	USED(a);
+	snprint(buf, sizeof(buf), "sys: fp: exception status=%.4lux pc=%#p", getfsr(), si->si_addr);
+	disfault(nil, buf);
+}
+
+static void
+trapUSR1(int signo)
+{
+	int intwait;
+
+	USED(signo);
+
+	intwait = up->intwait;
+	up->intwait = 0;	/* clear it to let proc continue in osleave */
+
+	if(up->type != Interp)		/* Used to unblock pending I/O */
+		return;
+
+	if(intwait == 0)		/* Not posted so it's a sync error */
+		disfault(nil, Eintr);	/* Should never happen */
+}
+
+void
+oslongjmp(void *regs, osjmpbuf env, int val)
+{
+	USED(regs);
+	siglongjmp(env, val);
+}
+
+static void
+termset(void)
+{
+	struct termios t;
+
+	tcgetattr(0, &t);
+	tinit = t;
+	t.c_lflag &= ~(ICANON|ECHO|ISIG);
+	t.c_cc[VMIN] = 1;
+	t.c_cc[VTIME] = 0;
+	tcsetattr(0, TCSANOW, &t);
+}
+
+static void
+termrestore(void)
+{
+	tcsetattr(0, TCSANOW, &tinit);
+}
+
+void
+cleanexit(int x)
+{
+	USED(x);
+
+	if(up->intwait) {
+		up->intwait = 0;
+		return;
+	}
+
+	if(dflag == 0)
+		termrestore();
+
+	kill(0, SIGKILL);
+	exit(0);
+}
+
+void
+osreboot(char *file, char **argv)
+{
+	if(dflag == 0)
+		termrestore();
+	execvp(file, argv);
+	error("reboot failure");
+}
+
+void
+libinit(char *imod)
+{
+	struct sigaction act;
+	struct passwd *pw;
+	Proc *p;
+	char sys[64];
+
+	setsid();
+
+	gethostname(sys, sizeof(sys));
+	kstrdup(&ossysname, sys);
+	pw = getpwnam("nobody");
+	if(pw != nil) {
+		uidnobody = pw->pw_uid;
+		gidnobody = pw->pw_gid;
+	}
+
+	if(dflag == 0)
+		termset();
+
+	memset(&act, 0, sizeof(act));
+	act.sa_handler = trapUSR1;
+	sigaction(SIGUSR1, &act, nil);
+
+	act.sa_handler = SIG_IGN;
+	sigaction(SIGCHLD, &act, nil);
+
+	/*
+	 * For the correct functioning of devcmd in the
+	 * face of exiting slaves
+	 */
+	signal(SIGPIPE, SIG_IGN);
+	if(signal(SIGTERM, SIG_IGN) != SIG_IGN)
+		signal(SIGTERM, cleanexit);
+	if(signal(SIGINT, SIG_IGN) != SIG_IGN)
+		signal(SIGINT, cleanexit);
+
+	if(sflag == 0) {
+		act.sa_flags = SA_SIGINFO;
+		act.sa_sigaction = trapILL;
+		sigaction(SIGILL, &act, nil);
+		act.sa_sigaction = trapFPE;
+		sigaction(SIGFPE, &act, nil);
+		act.sa_sigaction = trapmemref;
+		sigaction(SIGBUS, &act, nil);
+		sigaction(SIGSEGV, &act, nil);
+		act.sa_flags &= ~SA_SIGINFO;
+	}
+
+	p = newproc();
+	kprocinit(p);
+
+	pw = getpwuid(getuid());
+	if(pw != nil)
+		kstrdup(&eve, pw->pw_name);
+	else
+		print("cannot getpwuid\n");
+
+	p->env->uid = getuid();
+	p->env->gid = getgid();
+
+	emuinit(imod);
+}
+
+int
+readkbd(void)
+{
+	int n;
+	char buf[1];
+
+	n = read(0, buf, sizeof(buf));
+	if(n < 0)
+		print("keyboard close (n=%d, %s)\n", n, strerror(errno));
+	if(n <= 0)
+		pexit("keyboard thread", 0);
+
+	switch(buf[0]) {
+	case '\r':
+		buf[0] = '\n';
+		break;
+	case DELETE:
+		buf[0] = 'H' - '@';
+		break;
+	case CTRLC:
+		cleanexit(0);
+		break;
+	}
+	return buf[0];
+}
+
+/*
+ * Return an abitrary millisecond clock time
+ */
+long
+osmillisec(void)
+{
+	static long sec0 = 0, usec0;
+	struct timeval t;
+
+	if(gettimeofday(&t,(struct timezone*)0)<0)
+		return 0;
+
+	if(sec0 == 0) {
+		sec0 = t.tv_sec;
+		usec0 = t.tv_usec;
+	}
+	return (t.tv_sec-sec0)*1000+(t.tv_usec-usec0+500)/1000;
+}
+
+/*
+ * Return the time since the epoch in nanoseconds and microseconds
+ * The epoch is defined at 1 Jan 1970
+ */
+vlong
+osnsec(void)
+{
+	struct timeval t;
+
+	gettimeofday(&t, nil);
+	return (vlong)t.tv_sec*1000000000L + t.tv_usec*1000;
+}
+
+vlong
+osusectime(void)
+{
+	struct timeval t;
+ 
+	gettimeofday(&t, nil);
+	return (vlong)t.tv_sec * 1000000 + t.tv_usec;
+}
+
+int
+osmillisleep(ulong milsec)
+{
+	struct  timespec time;
+
+	time.tv_sec = milsec/1000;
+	time.tv_nsec= (milsec%1000)*1000000;
+	nanosleep(&time, NULL);
+	return 0;
+}
+
+int
+limbosleep(ulong milsec)
+{
+	return osmillisleep(milsec);
+}
--- /dev/null
+++ b/emu/AIX/segflush-power.c
@@ -1,0 +1,33 @@
+#include <sys/types.h>
+
+#include "dat.h"
+
+
+/*
+ * from geoff collyer's port
+ * invalidate instruction cache and write back data cache from a to a+n-1,
+ * at least.
+ */
+int
+segflush(void *a, ulong n)
+{
+    ulong *p;
+
+    // cache blocks are often eight words (32 bytes) long, sometimes 16 bytes.
+    // need to determine it dynamically?
+    for (p = (ulong *)((ulong)a & ~7UL); (char *)p < (char *)a + n; p++)
+        __asm__("dcbst	0,r0\n\t"	// not dcbf, which writes back, then invalidates
+            "icbi	0,r0\n\t"
+            : // no output
+            : "ar" (p)
+            );
+     __asm__("sync\n\t"
+            : // no output
+            :
+            );
+   __asm__("isync\n\t"
+            : // no output
+            :
+            );
+	return 0;
+}
--- /dev/null
+++ b/emu/Linux/emu-g.c
@@ -1,0 +1,80 @@
+#include "dat.h"
+#include "fns.h"
+#include "error.h"
+#include "interp.h"
+
+
+#include "emu-g.root.h"
+
+ulong ndevs = 25;
+
+extern Dev rootdevtab;
+extern Dev consdevtab;
+extern Dev envdevtab;
+extern Dev mntdevtab;
+extern Dev pipedevtab;
+extern Dev progdevtab;
+extern Dev profdevtab;
+extern Dev srvdevtab;
+extern Dev dupdevtab;
+extern Dev ssldevtab;
+extern Dev capdevtab;
+extern Dev fsdevtab;
+extern Dev cmddevtab;
+extern Dev indirdevtab;
+extern Dev ipdevtab;
+extern Dev eiadevtab;
+extern Dev memdevtab;
+Dev* devtab[]={
+	&rootdevtab,
+	&consdevtab,
+	&envdevtab,
+	&mntdevtab,
+	&pipedevtab,
+	&progdevtab,
+	&profdevtab,
+	&srvdevtab,
+	&dupdevtab,
+	&ssldevtab,
+	&capdevtab,
+	&fsdevtab,
+	&cmddevtab,
+	&indirdevtab,
+	&ipdevtab,
+	&eiadevtab,
+	&memdevtab,
+	nil,
+	nil,
+	nil,
+	nil,
+	nil,
+	nil,
+	nil,
+	nil,
+	nil,
+};
+
+void links(void){
+}
+
+extern void sysmodinit(void);
+extern void mathmodinit(void);
+extern void srvmodinit(void);
+extern void keyringmodinit(void);
+extern void cryptmodinit(void);
+extern void ipintsmodinit(void);
+extern void loadermodinit(void);
+void modinit(void){
+	sysmodinit();
+	mathmodinit();
+	srvmodinit();
+	keyringmodinit();
+	cryptmodinit();
+	ipintsmodinit();
+	loadermodinit();
+}
+
+	void setpointer(int x, int y){USED(x); USED(y);}
+	ulong strtochan(char *s){USED(s); return ~0;}
+char* conffile = "emu-g";
+ulong kerndate = KERNDATE;
binary files /dev/null b/emu/Linux/o.emu-g differ
--- /dev/null
+++ b/emu/NetBSD/asm-power.S
@@ -1,0 +1,91 @@
+#include <machine/asm.h>
+
+ENTRY_NOPROFILE(FPsave)
+	stfd	%f14,0*8(%r3)
+	stfd	%f15,1*8(%r3)
+	stfd	%f16,2*8(%r3)
+	stfd	%f17,3*8(%r3)
+	stfd	%f18,4*8(%r3)
+	stfd	%f19,5*8(%r3)
+	stfd	%f20,6*8(%r3)
+	stfd	%f21,7*8(%r3)
+	stfd	%f22,8*8(%r3)
+	stfd	%f23,9*8(%r3)
+	stfd	%f24,10*8(%r3)
+	stfd	%f25,11*8(%r3)
+	stfd	%f26,12*8(%r3)
+	stfd	%f27,13*8(%r3)
+	stfd	%f28,14*8(%r3)
+	stfd	%f29,15*8(%r3)
+	stfd	%f30,16*8(%r3)
+	stfd	%f31,17*8(%r3)
+	blr
+	END(FPsave)
+
+ENTRY_NOPROFILE(FPrestore)
+	lfd	%f14,0*8(%r3)
+	lfd	%f15,1*8(%r3)
+	lfd	%f16,2*8(%r3)
+	lfd	%f17,3*8(%r3)
+	lfd	%f18,4*8(%r3)
+	lfd	%f19,5*8(%r3)
+	lfd	%f20,6*8(%r3)
+	lfd	%f21,7*8(%r3)
+	lfd	%f22,8*8(%r3)
+	lfd	%f23,9*8(%r3)
+	lfd	%f24,10*8(%r3)
+	lfd	%f25,11*8(%r3)
+	lfd	%f26,12*8(%r3)
+	lfd	%f27,13*8(%r3)
+	lfd	%f28,14*8(%r3)
+	lfd	%f29,15*8(%r3)
+	lfd	%f30,16*8(%r3)
+	lfd	%f31,17*8(%r3)
+	blr
+	END(FPrestore)
+
+ENTRY_NOPROFILE(_tas)
+	sync
+	mr	%r4, %r3
+	addi	%r5,0,0x1	
+1:
+	lwarx	%r3, 0, %r4
+	cmpwi	%r3, 0
+	bne-	2f
+	stwcx.	%r5, 0, %r4
+	bne-	1b
+2:
+	sync
+	blr
+	END(_tas)
+
+/*
+ * void
+ * executeonnewstack(void *tos, void (*tramp)(void *arg), void *arg)
+ */
+ENTRY_NOPROFILE(executeonnewstack)
+	mr	%r1,%r3		/* change stacks */
+	stwu 	%lr,-16(%r1)	/* save lr to aid the traceback */
+	li	%r0,0
+	stw 	%r0,20(%r1)
+	mr	%r3,%r5
+	mtctr 	%r4
+	bctrl	/* tramp(arg) */
+	br
+	END(executeonnewstack)
+
+/*
+ * void unlockandexit(int *key)
+ *
+ * NB: the return status may be garbaged if the stack is reused
+ *	between the unlock and the system call, but this should
+ *	not matter since no task is waiting for the result
+ */
+ENTRY_NOPROFILE(unlockandexit)
+	li	%r0,0x0
+	stw	%r0,0(%r3)	/* unlock */
+	li	%r0,1		/* sys exit; 234 is exit group */
+	li	%r3,0		/* exit status */
+	sc
+	br
+	END(unlockandexit)
--- a/emu/NetBSD/emu
+++ b/emu/NetBSD/emu
@@ -81,6 +81,9 @@
 	uqid
 
 code
+	#ifdef __powerpc__
+	int macjit = 1; /* tell compiler it's not plan9 abi */
+	#endif
 
 init
 	emuinit
--- a/emu/NetBSD/emu-g
+++ b/emu/NetBSD/emu-g
@@ -70,6 +70,10 @@
 	uqid
 
 code
+	#ifdef __powerpc__
+	int macjit = 1; /* tell compiler it's not plan9 abi */
+	#endif
+
 	void setpointer(int x, int y){USED(x); USED(y);}
 	ulong strtochan(char *s){USED(s); return ~0;}
 
--- a/emu/NetBSD/os.c
+++ b/emu/NetBSD/os.c
@@ -527,11 +527,3 @@
 	*(Proc **)rv = p;
 	return rv;
 }
-
-int
-segflush(void *a, ulong n)
-{
-	USED(a);
-	USED(n);
-	return 0;
-}
--- /dev/null
+++ b/emu/NetBSD/segflush-386.c
@@ -1,0 +1,9 @@
+#include "dat.h"
+
+int
+segflush(void *a, ulong n)
+{
+	USED(a);
+	USED(n);
+	return 0;
+}
--- /dev/null
+++ b/emu/NetBSD/segflush-power.c
@@ -1,0 +1,12 @@
+#include <sys/types.h>
+#include <machine/cpu.h>
+
+#include "dat.h"
+
+
+int
+segflush(void *a, ulong n)
+{
+	__syncicache(a, n);
+	return 0;
+}
--- a/emu/OpenBSD/asm-386.S
+++ b/emu/OpenBSD/asm-386.S
@@ -3,8 +3,6 @@
 #include <sys/syscall.h>
 #include <machine/asm.h>
 
-#include "rfork_thread.S"
-
 /*
  * executeonnewstack(void *tos, void (*tramp)(void *arg), void *arg)
  */
--- a/emu/OpenBSD/os.c
+++ b/emu/OpenBSD/os.c
@@ -24,53 +24,9 @@
 };
 char *hosttype = "OpenBSD";
 
-int rfork_thread(int, void *, void (*)(void *), void *);
-
-extern void unlockandexit(int*);
-extern void executeonnewstack(void*, void (*f)(void*), void*);
-static void *stackalloc(Proc *p, void **tos);
-static void stackfreeandexit(void *stack);
-
 extern int dflag;
 
 void
-pexit(char *msg, int t)
-{
-	Osenv *e;
-	Proc *p;
-	void *kstack;
-
-	lock(&procs.l);
-	p = up;
-	if(p->prev)
-		p->prev->next = p->next;
-	else
-		procs.head = p->next;
-
-	if(up->next)
-		p->next->prev = p->prev;
-	else
-		procs.tail = p->prev;
-	unlock(&procs.l);
-
-	if(0)
-		print("pexit: %s: %s\n", up->text, msg);
-
-	e = up->env;
-	if(e != nil) {
-		closefgrp(e->fgrp);
-		closepgrp(e->pgrp);
-		closeegrp(e->egrp);
-		closesigs(e->sigs);
-	}
-	kstack = p->kstack;
-	free(p->prog);
-	free(p);
-	if(kstack != nil)
-		stackfreeandexit(kstack);
-}
-
-void
 trapBUS(int signo, siginfo_t *info, void *context)
 {
 	if(info)
@@ -77,7 +33,7 @@
 		print("trapBUS: signo: %d code: %d addr: %lx\n",
 		info->si_signo, info->si_code, info->si_addr);
 	else
-		print("trapBUS: no info\n"); 
+		print("trapBUS: no info\n");
 	disfault(nil, "Bus error");
 }
 
@@ -135,7 +91,7 @@
 
 	memset(&act, 0 , sizeof(act));
 	sigemptyset(&initmask);
-	
+
 	signal(SIGPIPE, SIG_IGN);	/* prevent signal when devcmd child exits */
 	if(signal(SIGTERM, SIG_IGN) != SIG_IGN)
 		signal(SIGTERM, cleanexit);
@@ -180,102 +136,7 @@
 		panic("sigprocmask");
 }
 
-static void
-tramp(void *arg)
-{
-	Proc *p;
-
-	p = arg;
-	p->pid = p->sigid = getpid();
-	sigprocmask(SIG_BLOCK, &initmask, nil);	/* in 5.3, rfork_thread doesn't copy from parent, contrary to docs? */
-	(*p->func)(p->arg);
-	pexit("{Tramp}", 0);
-	_exit(0);
-}
-
 void
-kproc(char *name, void (*func)(void*), void *arg, int flags)
-{
-	Proc *p;
-	Pgrp *pg;
-	Fgrp *fg;
-	Egrp *eg;
-	int pid;
-	void *tos;
-
-	p = newproc();
-
-	if(flags & KPDUPPG) {
-		pg = up->env->pgrp;
-		incref(&pg->r);
-		p->env->pgrp = pg;
-	}
-	if(flags & KPDUPFDG) {
-		fg = up->env->fgrp;
-		incref(&fg->r);
-		p->env->fgrp = fg;
-	}
-	if(flags & KPDUPENVG) {
-		eg = up->env->egrp;
-		incref(&eg->r);
-		p->env->egrp = eg;
-	}
-
-	p->env->uid = up->env->uid;
-	p->env->gid = up->env->gid;
-	kstrdup(&p->env->user, up->env->user);
-
-	strcpy(p->text, name);
-
-	p->func = func;
-	p->arg = arg;
-
-	lock(&procs.l);
-	if(procs.tail != nil) {
-		p->prev = procs.tail;
-		procs.tail->next = p;
-	}
-	else {
-		procs.head = p;
-		p->prev = nil;
-	}
-	procs.tail = p;
-	unlock(&procs.l);
-
-	if(flags & KPX11){
-		p->kstack = nil;	/* never freed; also up not defined */
-		tos = (char*)mallocz(X11STACK, 0) + X11STACK - sizeof(void*);
-	}else
-		p->kstack = stackalloc(p, &tos);
-	pid = rfork_thread(RFPROC|RFMEM|RFNOWAIT, tos, tramp, p);
-	if(pid < 0)
-		panic("rfork");
-}
-
-void
-oshostintr(Proc *p)
-{
-	kill(p->sigid, SIGUSR1);
-}
-
-void
-osblock(void)
-{
-	sigset_t mask;
-
-	sigprocmask(SIG_SETMASK, NULL, &mask);
-	sigdelset(&mask, SIGUSR2);
-	sigsuspend(&mask);
-}
-
-void
-osready(Proc *p)
-{
-	if(kill(p->sigid, SIGUSR2) < 0)
-		fprint(2, "emu: osready failed: pid %d: %s\n", p->sigid, strerror(errno));
-}
-
-void
 oslongjmp(void *regs, osjmpbuf env, int val)
 {
 	USED(regs);
@@ -335,7 +196,7 @@
 getnobody()
 {
 	struct passwd *pwd;
-	
+
 	if(pwd = getpwnam("nobody")) {
 		uidnobody = pwd->pw_uid;
 		gidnobody = pwd->pw_gid;
@@ -347,7 +208,6 @@
 {
 	struct passwd *pw;
 	Proc *p;
-	void *tos;
 	char sys[64];
 
 	setsid();
@@ -362,7 +222,7 @@
 	setsigs();
 
 	p = newproc();
-	p->kstack = stackalloc(p, &tos);
+	kprocinit(p);
 
 	pw = getpwuid(getuid());
 	if(pw != nil)
@@ -369,11 +229,11 @@
 		kstrdup(&eve, pw->pw_name);
 	else
 		print("cannot getpwuid\n");
- 
+
 	p->env->uid = getuid();
 	p->env->gid = getgid();
 
-	executeonnewstack(tos, emuinit, imod);
+	emuinit(imod);
 }
 
 int
@@ -440,7 +300,7 @@
 osusectime(void)
 {
 	struct timeval t;
- 
+
 	gettimeofday(&t, nil);
 	return (vlong)t.tv_sec * 1000000 + t.tv_usec;
 }
@@ -454,76 +314,6 @@
 	time.tv_nsec = (milsec % 1000) * 1000000;
 	nanosleep(&time, 0);
 	return 0;
-}
-
-void
-osyield(void)
-{
-	sched_yield();
-}
-
-void
-ospause(void)
-{
-	for(;;)
-		pause();
-}
-
-void
-oslopri(void)
-{
-	setpriority(PRIO_PROCESS, 0, getpriority(PRIO_PROCESS,0)+4);
-}
-
-static struct {
-	Lock l;
-	void *free;
-} stacklist;
-
-static void
-_stackfree(void *stack)
-{
-	*((void **)stack) = stacklist.free;
-	stacklist.free = stack;
-}
-
-static void
-stackfreeandexit(void *stack)
-{
-	lock(&stacklist.l);
-	_stackfree(stack);
-	unlockandexit(&stacklist.l.val);
-}
-
-static void *
-stackalloc(Proc *p, void **tos)
-{
-	void *rv;
-	lock(&stacklist.l);
-	if (stacklist.free == 0) {
-		int x;
-		/*
-		 * obtain some more by using sbrk()
-		 */
-		void *more = sbrk(KSTACK * (NSTACKSPERALLOC + 1));
-		if (more == 0)
-			panic("stackalloc: no more stacks");
-		/*
-		 * align to KSTACK
-		 */
-		more = (void *)((((unsigned long)more) + (KSTACK - 1)) & ~(KSTACK - 1));
-		/*
-		 * free all the new stacks onto the freelist
-		 */
-		for (x = 0; x < NSTACKSPERALLOC; x++)
-			_stackfree((char *)more + KSTACK * x);
-	}
-	rv = stacklist.free;
-	stacklist.free = *(void **)rv;
-	unlock(&stacklist.l);
-	*tos = rv + KSTACK - sizeof(void*);
-	*(Proc **)rv = p;
-	return rv;
 }
 
 int
--- a/emu/port/devfs-posix.c
+++ b/emu/port/devfs-posix.c
@@ -9,7 +9,7 @@
 
 #include	<sys/types.h>
 #include	<sys/stat.h>
-#include	<sys/fcntl.h>
+#include	<fcntl.h>
 #include	<sys/socket.h>
 #include	<sys/un.h>
 #include	<utime.h>
--- a/emu/port/win-x11a.c
+++ b/emu/port/win-x11a.c
@@ -304,7 +304,7 @@
 		lp = dp + width;
 		while(dp < lp){
 			v = *dp++;
-			w = infernortox11[(v>>16)&0xff]<<16|infernogtox11[(v>>8)&0xff]<<8|infernobtox11[(v>>0)&0xff]<<0;
+			w = v&(0xff<<24)|infernortox11[(v>>16)&0xff]<<16|infernogtox11[(v>>8)&0xff]<<8|infernobtox11[(v>>0)&0xff]<<0;
 			*wp++ = w;
 		}
 		dp += dx;
@@ -313,6 +313,33 @@
 }
 
 static void
+copy16to16(Rectangle r)
+{
+	int dx, width;
+	u16int *dp, *wp, *edp, *lp;
+
+	width = Dx(r);
+	dx = Xsize - width;
+	dp = (u16int*)(gscreendata + ((r.min.y * Xsize) + r.min.x) * 2);
+	wp = (u16int*)(xscreendata + ((r.min.y * Xsize) + r.min.x) * 2);
+	edp = (u16int*)(gscreendata + ((r.max.y * Xsize) + r.max.x) * 2);
+
+	/* The pixel format should be the same as the underlying X display (see
+	   the xtruevisual function) unless a different channel format is
+	   explicitly specified on the command line, so just copy the pixel data
+	   without any processing. */
+
+	while(dp < edp) {
+		lp = dp + width;
+		while(dp < lp){
+			*wp++ = *dp++;
+		}
+		dp += dx;
+		wp += dx;
+	}
+}
+
+static void
 copy8to32(Rectangle r)
 {
 	int dx, width;
@@ -435,6 +462,17 @@
 	case 32:
 		copy32to32(r);
 		break;
+    case 16:
+        switch(xscreendepth){
+        case 16:
+            copy16to16(r);
+            break;
+        default:
+		    fprint(2, "emu: bad display depth %d chan %s xscreendepth %d\n", displaydepth,
+			    chantostr(chanbuf, displaychan), xscreendepth);
+		    cleanexit(0);
+        }
+        break;
 	case 8:
 		switch(xscreendepth){
 		case 24:
--- /dev/null
+++ b/fonts/vga/unicode.font
@@ -1,0 +1,252 @@
+16 12
+0x0000	0x007f	vga.0000-007F
+0x00a0	0x021f	vga.00A0-021F
+0x0222	0x0233	vga.0222-0233
+0x0250	0x02ad	vga.0250-02AD
+0x02b0	0x02cf	vga.02B0-02CF
+0x02d8	0x02dd	vga.02D8-02DD
+0x02ee	0x02ee	vga.02EE-02EE
+0x0300	0x0301	vga.0300-0301
+0x0303	0x0303	vga.0303-0303
+0x0309	0x0309	vga.0309-0309
+0x0312	0x0314	vga.0312-0314
+0x0323	0x0323	vga.0323-0323
+0x0340	0x0341	vga.0340-0341
+0x0374	0x0375	vga.0374-0375
+0x037a	0x037a	vga.037A-037A
+0x037e	0x037e	vga.037E-037E
+0x0384	0x038a	vga.0384-038A
+0x038c	0x038c	vga.038C-038C
+0x038e	0x03a1	vga.038E-03A1
+0x03a3	0x03ce	vga.03A3-03CE
+0x03d0	0x03d7	vga.03D0-03D7
+0x03da	0x03f3	vga.03DA-03F3
+0x0400	0x0486	vga.0400-0486
+0x0488	0x04ce	vga.0488-04CE
+0x04d0	0x04f5	vga.04D0-04F5
+0x04f8	0x04f9	vga.04F8-04F9
+0x0500	0x050f	vga.0500-050F
+0x0530	0x0556	vga.0530-0556
+0x0559	0x055f	vga.0559-055F
+0x0561	0x0587	vga.0561-0587
+0x0589	0x058a	vga.0589-058A
+0x0591	0x05a1	vga.0591-05A1
+0x05a3	0x05b9	vga.05A3-05B9
+0x05bb	0x05c4	vga.05BB-05C4
+0x05d0	0x05ea	vga.05D0-05EA
+0x05f0	0x05f4	vga.05F0-05F4
+0x060c	0x060c	vga.060C-060C
+0x061b	0x061b	vga.061B-061B
+0x061f	0x061f	vga.061F-061F
+0x0621	0x063a	vga.0621-063A
+0x0640	0x0655	vga.0640-0655
+0x0660	0x066d	vga.0660-066D
+0x0670	0x06ed	vga.0670-06ED
+0x06f0	0x06fe	vga.06F0-06FE
+0x10d3	0x10d3	vga.10D3-10D3
+0x10d7	0x10d7	vga.10D7-10D7
+0x10da	0x10da	vga.10DA-10DA
+0x10dd	0x10dd	vga.10DD-10DD
+0x10e6	0x10e6	vga.10E6-10E6
+0x1e00	0x1e9b	vga.1E00-1E9B
+0x1ea0	0x1ef9	vga.1EA0-1EF9
+0x1f00	0x1f07	vga.1F00-1F07
+0x2000	0x2027	vga.2000-2027
+0x2030	0x2046	vga.2030-2046
+0x2048	0x204d	vga.2048-204D
+0x2070	0x2070	vga.2070-2070
+0x2074	0x208f	vga.2074-208F
+0x20a0	0x20af	vga.20A0-20AF
+0x2100	0x213a	vga.2100-213A
+0x2153	0x2183	vga.2153-2183
+0x2190	0x21f3	vga.2190-21F3
+0x2200	0x22f1	vga.2200-22F1
+0x2300	0x2300	vga.2300-2300
+0x2302	0x2302	vga.2302-2302
+0x2308	0x230b	vga.2308-230B
+0x2310	0x2310	vga.2310-2310
+0x2318	0x2318	vga.2318-2318
+0x231a	0x231b	vga.231A-231B
+0x2320	0x2321	vga.2320-2321
+0x2329	0x232a	vga.2329-232A
+0x239b	0x23bd	vga.239B-23BD
+0x23ce	0x23ce	vga.23CE-23CE
+0x2409	0x240d	vga.2409-240D
+0x2423	0x2424	vga.2423-2424
+0x2426	0x2426	vga.2426-2426
+0x2500	0x2595	vga.2500-2595
+0x25a0	0x25f7	vga.25A0-25F7
+0x2600	0x2602	vga.2600-2602
+0x2605	0x260d	vga.2605-260D
+0x2610	0x2613	vga.2610-2613
+0x2620	0x2620	vga.2620-2620
+0x2622	0x2622	vga.2622-2622
+0x2626	0x2626	vga.2626-2626
+0x2628	0x262b	vga.2628-262B
+0x262e	0x2637	vga.262E-2637
+0x2639	0x2653	vga.2639-2653
+0x2660	0x2667	vga.2660-2667
+0x2669	0x266f	vga.2669-266F
+0xfb00	0xfb05	vga.FB00-FB05
+0xfb50	0xfbb1	vga.FB50-FBB1
+0xfbd3	0xfbe9	vga.FBD3-FBE9
+0xfbfc	0xfbff	vga.FBFC-FBFF
+0xfc5b	0xfc63	vga.FC5B-FC63
+0xfc90	0xfc90	vga.FC90-FC90
+0xfcf2	0xfcf4	vga.FCF2-FCF4
+0xfd3c	0xfd3f	vga.FD3C-FD3F
+0xfdf2	0xfdf2	vga.FDF2-FDF2
+0xfe50	0xfe52	vga.FE50-FE52
+0xfe54	0xfe66	vga.FE54-FE66
+0xfe68	0xfe6b	vga.FE68-FE6B
+0xfe70	0xfe72	vga.FE70-FE72
+0xfe74	0xfe74	vga.FE74-FE74
+0xfe76	0xfefc	vga.FE76-FEFC
+0xfeff	0xfeff	vga.FEFF-FEFF
+0xfffd	0xfffd	vga.FFFD-FFFD
+0xfff9	0xffff	../dejavu/dejavu.12.fff9
+0xfb00	0xfc00	../dejavu/dejavu.12.fb00
+0xf6c5	0xf7c5	../dejavu/dejavu.12.f6c5
+0xf400	0xf500	../dejavu/dejavu.12.f400
+0xa746	0xa846	../dejavu/dejavu.12.a746
+0xa644	0xa744	../dejavu/dejavu.12.a644
+0x2e18	0x2f18	../dejavu/dejavu.12.2e18
+0x2c60	0x2d60	../dejavu/dejavu.12.2c60
+0x2b00	0x2c00	../dejavu/dejavu.12.2b00
+0x29eb	0x2aeb	../dejavu/dejavu.12.29eb
+0x28a2	0x29a2	../dejavu/dejavu.12.28a2
+0x27a1	0x28a1	../dejavu/dejavu.12.27a1
+0x2638	0x2738	../dejavu/dejavu.12.2638
+0x2524	0x2624	../dejavu/dejavu.12.2524
+0x2423	0x2523	../dejavu/dejavu.12.2423
+0x2310	0x2410	../dejavu/dejavu.12.2310
+0x220b	0x230b	../dejavu/dejavu.12.220b
+0x2109	0x2209	../dejavu/dejavu.12.2109
+0x2003	0x2103	../dejavu/dejavu.12.2003
+0x1f02	0x2002	../dejavu/dejavu.12.1f02
+0x1e01	0x1f01	../dejavu/dejavu.12.1e01
+0x1d00	0x1e00	../dejavu/dejavu.12.1d00
+0x10a0	0x11a0	../dejavu/dejavu.12.10a0
+0x0510	0x0610	../dejavu/dejavu.12.0510
+0x0404	0x0504	../dejavu/dejavu.12.0404
+0x0303	0x0403	../dejavu/dejavu.12.0303
+0x0202	0x0302	../dejavu/dejavu.12.0202
+0x0000	0x0100	../dejavu/dejavu.12.0000
+0xfe00	0xfeff	../dejavusans/dejavusans.12.fe00
+0xf001	0xf101	../dejavusans/dejavusans.12.f001
+0xef00	0xf000	../dejavusans/dejavusans.12.ef00
+0x4dc0	0x4dff	../dejavusans/dejavusans.12.4dc0
+0x2d61	0x2e61	../dejavusans/dejavusans.12.2d61
+0x2a7d	0x2b7d	../dejavusans/dejavusans.12.2a7d
+0x2940	0x2a40	../dejavusans/dejavusans.12.2940
+0x2713	0x2813	../dejavusans/dejavusans.12.2713
+0x2612	0x2712	../dejavusans/dejavusans.12.2612
+0x2422	0x2522	../dejavusans/dejavusans.12.2422
+0x22f8	0x23f8	../dejavusans/dejavusans.12.22f8
+0x21fc	0x22f7	../dejavusans/dejavusans.12.21fc
+0x1502	0x15ff	../dejavusans/dejavusans.12.1502
+0x1401	0x1501	../dejavusans/dejavusans.12.1401
+0x0f00	0x0f3f	../dejavusans/dejavusans.12.0e3f
+0x07c0	0x08c0	../dejavusans/dejavusans.12.07c0
+0x0606	0x0706	../dejavusans/dejavusans.12.0606
+0x3000	0x30fe	../shinonome/k12.3000
+0x4e00	0x4ffe	../shinonome/k12.4e00
+0x5005	0x51fe	../shinonome/k12.5005
+0x5200	0x53fa	../shinonome/k12.5200
+0x5401	0x55fe	../shinonome/k12.5401
+0x5606	0x57fc	../shinonome/k12.5606
+0x5800	0x59ff	../shinonome/k12.5800
+0x5a01	0x5bff	../shinonome/k12.5a01
+0x5c01	0x5dfe	../shinonome/k12.5c01
+0x5e02	0x5fff	../shinonome/k12.5e02
+0x600e	0x61ff	../shinonome/k12.600e
+0x6200	0x63fa	../shinonome/k12.6200
+0x6406	0x65fb	../shinonome/k12.6406
+0x6602	0x67ff	../shinonome/k12.6602
+0x6802	0x69ff	../shinonome/k12.6802
+0x6a02	0x6bf3	../shinonome/k12.6a02
+0x6c08	0x6dfb	../shinonome/k12.6c08
+0x6e05	0x6ffe	../shinonome/k12.6e05
+0x7001	0x71ff	../shinonome/k12.7001
+0x7206	0x73fe	../shinonome/k12.7206
+0x7403	0x75ff	../shinonome/k12.7403
+0x7601	0x77fc	../shinonome/k12.7601
+0x7802	0x79fb	../shinonome/k12.7802
+0x7a00	0x7bf7	../shinonome/k12.7a00
+0x7c00	0x7dfb	../shinonome/k12.7c00
+0x7e01	0x7ffc	../shinonome/k12.7e01
+0x8000	0x81fe	../shinonome/k12.8000
+0x8201	0x83fd	../shinonome/k12.8201
+0x8403	0x85fe	../shinonome/k12.8403
+0x8602	0x87fe	../shinonome/k12.8602
+0x8805	0x89f8	../shinonome/k12.8805
+0x8a00	0x8b9a	../shinonome/k12.8a00
+0x8c37	0x8dff	../shinonome/k12.8c37
+0x8e08	0x8ffd	../shinonome/k12.8e08
+0x9000	0x91ff	../shinonome/k12.9000
+0x920d	0x93e8	../shinonome/k12.920d
+0x9403	0x95e5	../shinonome/k12.9403
+0x961c	0x97ff	../shinonome/k12.961c
+0x9801	0x99ff	../shinonome/k12.9801
+0x9a01	0x9bf5	../shinonome/k12.9a01
+0x9c04	0x9dfd	../shinonome/k12.9c04
+0x9e1a	0x9fa0	../shinonome/k12.9e1a
+0x0e00	0x0eff	../fixed/7x14.0E00
+0x1600	0x16ff	../fixed/7x14.1600
+0x2400	0x24ff	../fixed/7x14.2400
+0xff00	0xffff	../fixed/7x14.FF00
+0x1000	0x10ff	../fixed/9x15.1000
+0x1200	0x12ff	../fixed/9x15.1200
+0x1300	0x13ff	../fixed/9x15.1300
+0xe000	0xe0ff	../fixed/9x15.E000
+0xe700	0xe7ff	../fixed/9x15.E700
+0x1400	0x14ff	../fixed/9x18.1400
+0xfc00	0xfcff	../fixed/10x20.FC00
+0xfd00	0xfdff	../fixed/10x20.FD00
+0x4e00	0x4fff	../jis/jis4e00.24
+0x5000	0x51ff	../jis/jis5000.24
+0x5200	0x53ff	../jis/jis5200.24
+0x5400	0x55ff	../jis/jis5400.24
+0x5600	0x57ff	../jis/jis5600.24
+0x5a00	0x5bff	../jis/jis5a00.24
+0x5c00	0x5dff	../jis/jis5c00.24
+0x5e00	0x5fff	../jis/jis5e00.24
+0x6000	0x61ff	../jis/jis6000.24
+0x6200	0x63ff	../jis/jis6200.24
+0x6400	0x65ff	../jis/jis6400.24
+0x6600	0x67ff	../jis/jis6600.24
+0x6800	0x69ff	../jis/jis6800.24
+0x6a00	0x6bff	../jis/jis6a00.24
+0x6c00	0x6dff	../jis/jis6c00.24
+0x6e00	0x6fff	../jis/jis6e00.24
+0x7000	0x71ff	../jis/jis7000.24
+0x7200	0x73ff	../jis/jis7200.24
+0x7400	0x75ff	../jis/jis7400.24
+0x7600	0x77ff	../jis/jis7600.24
+0x7800	0x79ff	../jis/jis7800.24
+0x7a00	0x7bff	../jis/jis7a00.24
+0x7c00	0x7dff	../jis/jis7c00.24
+0x7e00	0x7fff	../jis/jis7e00.24
+0x8000	0x81ff	../jis/jis8000.24
+0x8200	0x83ff	../jis/jis8200.24
+0x8400	0x85ff	../jis/jis8400.24
+0x8600	0x87ff	../jis/jis8600.24
+0x8800	0x89ff	../jis/jis8800.24
+0x8a00	0x8bff	../jis/jis8a00.24
+0x8c00	0x8dff	../jis/jis8c00.24
+0x8e00	0x8fff	../jis/jis8e00.24
+0x9200	0x93ff	../jis/jis9200.24
+0x9400	0x95ff	../jis/jis9400.24
+0x9600	0x97ff	../jis/jis9600.24
+0x9800	0x99ff	../jis/jis9800.24
+0x9a00	0x9bff	../jis/jis9a00.24
+0x9c00	0x9dff	../jis/jis9c00.24
+0x9e00	0x9fff	../jis/jis9e00.24
+0x1100	0x11ff	../fixed/6x13.1100
+0x4d00	0x4dff	../fixed/10x20.4D00
+0xf6c4	0xf7c4	../dejavubi/dejavubi.12.f6c4
+0xf5c5	0xf6c5	../dejavusansbi/dejavusansbi.12.f5c5
+0x1700	0x1746	../dejavusansit/dejavusansit.12.1646
+0xf101	0xf201	../germgoth/germgoth.14.f101
+0x3000	0x30ff	../fixed/10x20.3000
+0x2010	0x21d4	../shinonome/k14.2010
binary files /dev/null b/fonts/vga/vga.0000-0000 differ
binary files /dev/null b/fonts/vga/vga.0000-007F differ
binary files /dev/null b/fonts/vga/vga.0020-007F differ
binary files /dev/null b/fonts/vga/vga.00A0-021F differ
binary files /dev/null b/fonts/vga/vga.0222-0233 differ
binary files /dev/null b/fonts/vga/vga.0250-02AD differ
binary files /dev/null b/fonts/vga/vga.02B0-02CF differ
binary files /dev/null b/fonts/vga/vga.02D8-02DD differ
binary files /dev/null b/fonts/vga/vga.02EE-02EE differ
binary files /dev/null b/fonts/vga/vga.0300-0301 differ
binary files /dev/null b/fonts/vga/vga.0303-0303 differ
binary files /dev/null b/fonts/vga/vga.0309-0309 differ
binary files /dev/null b/fonts/vga/vga.0312-0314 differ
binary files /dev/null b/fonts/vga/vga.0323-0323 differ
binary files /dev/null b/fonts/vga/vga.0340-0341 differ
binary files /dev/null b/fonts/vga/vga.0374-0375 differ
binary files /dev/null b/fonts/vga/vga.037A-037A differ
binary files /dev/null b/fonts/vga/vga.037E-037E differ
binary files /dev/null b/fonts/vga/vga.0384-038A differ
binary files /dev/null b/fonts/vga/vga.038C-038C differ
binary files /dev/null b/fonts/vga/vga.038E-03A1 differ
binary files /dev/null b/fonts/vga/vga.03A3-03CE differ
binary files /dev/null b/fonts/vga/vga.03D0-03D7 differ
binary files /dev/null b/fonts/vga/vga.03DA-03F3 differ
binary files /dev/null b/fonts/vga/vga.0400-0486 differ
binary files /dev/null b/fonts/vga/vga.0488-04CE differ
binary files /dev/null b/fonts/vga/vga.04D0-04F5 differ
binary files /dev/null b/fonts/vga/vga.04F8-04F9 differ
binary files /dev/null b/fonts/vga/vga.0500-050F differ
binary files /dev/null b/fonts/vga/vga.0530-0556 differ
binary files /dev/null b/fonts/vga/vga.0559-055F differ
binary files /dev/null b/fonts/vga/vga.0561-0587 differ
binary files /dev/null b/fonts/vga/vga.0589-058A differ
binary files /dev/null b/fonts/vga/vga.0591-05A1 differ
binary files /dev/null b/fonts/vga/vga.05A3-05B9 differ
binary files /dev/null b/fonts/vga/vga.05BB-05C4 differ
binary files /dev/null b/fonts/vga/vga.05D0-05EA differ
binary files /dev/null b/fonts/vga/vga.05F0-05F4 differ
binary files /dev/null b/fonts/vga/vga.060C-060C differ
binary files /dev/null b/fonts/vga/vga.061B-061B differ
binary files /dev/null b/fonts/vga/vga.061F-061F differ
binary files /dev/null b/fonts/vga/vga.0621-063A differ
binary files /dev/null b/fonts/vga/vga.0640-0655 differ
binary files /dev/null b/fonts/vga/vga.0660-066D differ
binary files /dev/null b/fonts/vga/vga.0670-06ED differ
binary files /dev/null b/fonts/vga/vga.06F0-06FE differ
binary files /dev/null b/fonts/vga/vga.10D3-10D3 differ
binary files /dev/null b/fonts/vga/vga.10D7-10D7 differ
binary files /dev/null b/fonts/vga/vga.10DA-10DA differ
binary files /dev/null b/fonts/vga/vga.10DD-10DD differ
binary files /dev/null b/fonts/vga/vga.10E6-10E6 differ
binary files /dev/null b/fonts/vga/vga.1E00-1E9B differ
binary files /dev/null b/fonts/vga/vga.1EA0-1EF9 differ
binary files /dev/null b/fonts/vga/vga.1F00-1F07 differ
binary files /dev/null b/fonts/vga/vga.2000-2027 differ
binary files /dev/null b/fonts/vga/vga.2030-2046 differ
binary files /dev/null b/fonts/vga/vga.2048-204D differ
binary files /dev/null b/fonts/vga/vga.2070-2070 differ
binary files /dev/null b/fonts/vga/vga.2074-208F differ
binary files /dev/null b/fonts/vga/vga.20A0-20AF differ
binary files /dev/null b/fonts/vga/vga.2100-213A differ
binary files /dev/null b/fonts/vga/vga.2153-2183 differ
binary files /dev/null b/fonts/vga/vga.2190-21F3 differ
binary files /dev/null b/fonts/vga/vga.2200-22F1 differ
binary files /dev/null b/fonts/vga/vga.2300-2300 differ
binary files /dev/null b/fonts/vga/vga.2302-2302 differ
binary files /dev/null b/fonts/vga/vga.2308-230B differ
binary files /dev/null b/fonts/vga/vga.2310-2310 differ
binary files /dev/null b/fonts/vga/vga.2318-2318 differ
binary files /dev/null b/fonts/vga/vga.231A-231B differ
binary files /dev/null b/fonts/vga/vga.2320-2321 differ
binary files /dev/null b/fonts/vga/vga.2329-232A differ
binary files /dev/null b/fonts/vga/vga.239B-23BD differ
binary files /dev/null b/fonts/vga/vga.23CE-23CE differ
binary files /dev/null b/fonts/vga/vga.2409-240D differ
binary files /dev/null b/fonts/vga/vga.2423-2424 differ
binary files /dev/null b/fonts/vga/vga.2426-2426 differ
binary files /dev/null b/fonts/vga/vga.2500-2595 differ
binary files /dev/null b/fonts/vga/vga.25A0-25F7 differ
binary files /dev/null b/fonts/vga/vga.2600-2602 differ
binary files /dev/null b/fonts/vga/vga.2605-260D differ
binary files /dev/null b/fonts/vga/vga.2610-2613 differ
binary files /dev/null b/fonts/vga/vga.2620-2620 differ
binary files /dev/null b/fonts/vga/vga.2622-2622 differ
binary files /dev/null b/fonts/vga/vga.2626-2626 differ
binary files /dev/null b/fonts/vga/vga.2628-262B differ
binary files /dev/null b/fonts/vga/vga.262E-2637 differ
binary files /dev/null b/fonts/vga/vga.2639-2653 differ
binary files /dev/null b/fonts/vga/vga.2660-2667 differ
binary files /dev/null b/fonts/vga/vga.2669-266F differ
binary files /dev/null b/fonts/vga/vga.FB00-FB05 differ
binary files /dev/null b/fonts/vga/vga.FB50-FBB1 differ
binary files /dev/null b/fonts/vga/vga.FBD3-FBE9 differ
binary files /dev/null b/fonts/vga/vga.FBFC-FBFF differ
binary files /dev/null b/fonts/vga/vga.FC5B-FC63 differ
binary files /dev/null b/fonts/vga/vga.FC90-FC90 differ
binary files /dev/null b/fonts/vga/vga.FCF2-FCF4 differ
binary files /dev/null b/fonts/vga/vga.FD3C-FD3F differ
binary files /dev/null b/fonts/vga/vga.FDF2-FDF2 differ
binary files /dev/null b/fonts/vga/vga.FE50-FE52 differ
binary files /dev/null b/fonts/vga/vga.FE54-FE66 differ
binary files /dev/null b/fonts/vga/vga.FE68-FE6B differ
binary files /dev/null b/fonts/vga/vga.FE70-FE72 differ
binary files /dev/null b/fonts/vga/vga.FE74-FE74 differ
binary files /dev/null b/fonts/vga/vga.FE76-FEFC differ
binary files /dev/null b/fonts/vga/vga.FEFF-FEFF differ
binary files /dev/null b/fonts/vga/vga.FFFD-FFFD differ
--- /dev/null
+++ b/fonts/vga/vga.font
@@ -1,0 +1,106 @@
+16 12
+0x0	0x7F	vga.0000-007F
+0xA0	0x21F	vga.00A0-021F
+0x222	0x233	vga.0222-0233
+0x250	0x2AD	vga.0250-02AD
+0x2B0	0x2CF	vga.02B0-02CF
+0x2D8	0x2DD	vga.02D8-02DD
+0x2EE	0x2EE	vga.02EE-02EE
+0x300	0x301	vga.0300-0301
+0x303	0x303	vga.0303-0303
+0x309	0x309	vga.0309-0309
+0x312	0x314	vga.0312-0314
+0x323	0x323	vga.0323-0323
+0x340	0x341	vga.0340-0341
+0x374	0x375	vga.0374-0375
+0x37A	0x37A	vga.037A-037A
+0x37E	0x37E	vga.037E-037E
+0x384	0x38A	vga.0384-038A
+0x38C	0x38C	vga.038C-038C
+0x38E	0x3A1	vga.038E-03A1
+0x3A3	0x3CE	vga.03A3-03CE
+0x3D0	0x3D7	vga.03D0-03D7
+0x3DA	0x3F3	vga.03DA-03F3
+0x400	0x486	vga.0400-0486
+0x488	0x4CE	vga.0488-04CE
+0x4D0	0x4F5	vga.04D0-04F5
+0x4F8	0x4F9	vga.04F8-04F9
+0x500	0x50F	vga.0500-050F
+0x530	0x556	vga.0530-0556
+0x559	0x55F	vga.0559-055F
+0x561	0x587	vga.0561-0587
+0x589	0x58A	vga.0589-058A
+0x591	0x5A1	vga.0591-05A1
+0x5A3	0x5B9	vga.05A3-05B9
+0x5BB	0x5C4	vga.05BB-05C4
+0x5D0	0x5EA	vga.05D0-05EA
+0x5F0	0x5F4	vga.05F0-05F4
+0x60C	0x60C	vga.060C-060C
+0x61B	0x61B	vga.061B-061B
+0x61F	0x61F	vga.061F-061F
+0x621	0x63A	vga.0621-063A
+0x640	0x655	vga.0640-0655
+0x660	0x66D	vga.0660-066D
+0x670	0x6ED	vga.0670-06ED
+0x6F0	0x6FE	vga.06F0-06FE
+0x10D3	0x10D3	vga.10D3-10D3
+0x10D7	0x10D7	vga.10D7-10D7
+0x10DA	0x10DA	vga.10DA-10DA
+0x10DD	0x10DD	vga.10DD-10DD
+0x10E6	0x10E6	vga.10E6-10E6
+0x1E00	0x1E9B	vga.1E00-1E9B
+0x1EA0	0x1EF9	vga.1EA0-1EF9
+0x1F00	0x1F07	vga.1F00-1F07
+0x2000	0x2027	vga.2000-2027
+0x2030	0x2046	vga.2030-2046
+0x2048	0x204D	vga.2048-204D
+0x2070	0x2070	vga.2070-2070
+0x2074	0x208F	vga.2074-208F
+0x20A0	0x20AF	vga.20A0-20AF
+0x2100	0x213A	vga.2100-213A
+0x2153	0x2183	vga.2153-2183
+0x2190	0x21F3	vga.2190-21F3
+0x2200	0x22F1	vga.2200-22F1
+0x2300	0x2300	vga.2300-2300
+0x2302	0x2302	vga.2302-2302
+0x2308	0x230B	vga.2308-230B
+0x2310	0x2310	vga.2310-2310
+0x2318	0x2318	vga.2318-2318
+0x231A	0x231B	vga.231A-231B
+0x2320	0x2321	vga.2320-2321
+0x2329	0x232A	vga.2329-232A
+0x239B	0x23BD	vga.239B-23BD
+0x23CE	0x23CE	vga.23CE-23CE
+0x2409	0x240D	vga.2409-240D
+0x2423	0x2424	vga.2423-2424
+0x2426	0x2426	vga.2426-2426
+0x2500	0x2595	vga.2500-2595
+0x25A0	0x25F7	vga.25A0-25F7
+0x2600	0x2602	vga.2600-2602
+0x2605	0x260D	vga.2605-260D
+0x2610	0x2613	vga.2610-2613
+0x2620	0x2620	vga.2620-2620
+0x2622	0x2622	vga.2622-2622
+0x2626	0x2626	vga.2626-2626
+0x2628	0x262B	vga.2628-262B
+0x262E	0x2637	vga.262E-2637
+0x2639	0x2653	vga.2639-2653
+0x2660	0x2667	vga.2660-2667
+0x2669	0x266F	vga.2669-266F
+0xFB00	0xFB05	vga.FB00-FB05
+0xFB50	0xFBB1	vga.FB50-FBB1
+0xFBD3	0xFBE9	vga.FBD3-FBE9
+0xFBFC	0xFBFF	vga.FBFC-FBFF
+0xFC5B	0xFC63	vga.FC5B-FC63
+0xFC90	0xFC90	vga.FC90-FC90
+0xFCF2	0xFCF4	vga.FCF2-FCF4
+0xFD3C	0xFD3F	vga.FD3C-FD3F
+0xFDF2	0xFDF2	vga.FDF2-FDF2
+0xFE50	0xFE52	vga.FE50-FE52
+0xFE54	0xFE66	vga.FE54-FE66
+0xFE68	0xFE6B	vga.FE68-FE6B
+0xFE70	0xFE72	vga.FE70-FE72
+0xFE74	0xFE74	vga.FE74-FE74
+0xFE76	0xFEFC	vga.FE76-FEFC
+0xFEFF	0xFEFF	vga.FEFF-FEFF
+0xFFFD	0xFFFD	vga.FFFD-FFFD
--- a/lib/emptydirs
+++ b/lib/emptydirs
@@ -1,3 +1,4 @@
+AIX/power/lib
 FreeBSD/386/lib
 Inferno/386/bin
 Inferno/386/lib
@@ -16,6 +17,8 @@
 MacOSX/386/lib
 MacOSX/power/lib
 NetBSD/386/lib
+NetBSD/power/lib
+NetBSD/power/bin
 Nt/386/lib
 OpenBSD/386/bin
 OpenBSD/386/lib
--- /dev/null
+++ b/lib9/getcallerpc-AIX-power.c
@@ -1,0 +1,12 @@
+#include <lib9.h>
+
+ulong
+getcallerpc(void *x)
+{
+ulong *lp;
+
+	lp = x;
+
+	return lp[-1];
+}
+
--- a/lib9/getcallerpc-NetBSD-386.S
+++ b/lib9/getcallerpc-NetBSD-386.S
@@ -1,8 +1,7 @@
-	.file	"getcallerpc-NetBSD-386.S"
+#include <machine/asm.h>
 
-	.type	getcallerpc,@function
-	.global	getcallerpc
-getcallerpc:
+NENTRY(getcallerpc)
 	movl	4(%esp), %eax
 	movl	-4(%eax), %eax
 	ret
+	END(getcallerpc)
--- /dev/null
+++ b/lib9/getcallerpc-NetBSD-power.S
@@ -1,0 +1,6 @@
+#include <machine/asm.h>
+
+ENTRY_NOPROFILE(getcallerpc)
+	mflr	%r3
+	blr
+	END(getcallerpc)
--- /dev/null
+++ b/lib9/setfcr-AIX-power.c
@@ -1,0 +1,39 @@
+#include "lib9.h"
+
+ulong
+getfcr(void)
+{
+	double fpscr;
+
+	fpscr = __readflm();
+	return ((ulong*)&fpscr)[1];
+}
+
+ulong
+getfsr(void)
+{
+	double fpscr;
+
+	fpscr = __readflm();
+	return ((ulong*)&fpscr)[1];
+}
+
+void
+setfsr(ulong fsr)
+{
+	double fpscr;
+
+	fpscr = __readflm();
+	(((ulong*)&fpscr)[1]) = fsr;
+	__setflm(fpscr);
+}
+
+void
+setfcr(ulong fcr)
+{
+	double fpscr;
+
+	fpscr = __readflm();
+	(((ulong*)&fpscr)[1]) = fcr;
+	__setflm(fpscr);
+}
--- a/lib9/setfcr-Linux-power.S
+++ b/lib9/setfcr-Linux-power.S
@@ -3,13 +3,13 @@
 
 FN(getfcr):
 	mffs	%f0
-	stfdu	%f0,-16(%r1)
+	stfd	%f0,-16(%r1)
 	lw	%r3,-12(%r1)
 	blr
 
 FN(getfsr):
 	mffs	%f0
-	stfdu	%f0,-16(%r1)
+	stfd	%f0,-16(%r1)
 	lw	%r3,-12(%r1)
 	blr
 
--- a/lib9/setfcr-NetBSD-386.S
+++ b/lib9/setfcr-NetBSD-386.S
@@ -1,10 +1,9 @@
+#include <machine/asm.h>
 
-#define	FN(x)	.type x,@function; .global x; x
 #define	ENT	subl $16, %esp
 #define	RET	addl $16, %esp; ret
 
-	.file	"setfcr-Linux-386.S"
-FN(setfcr):
+NENTRY(setfcr)
 	ENT
 	xorb	$0x3f, %al
 	movl	%eax, (%esp)
@@ -11,8 +10,9 @@
 	fwait
 	fldcw	(%esp)
 	RET
+	END(setfcr)
 
-FN(getfcr):
+NENTRY(getfcr)
 	ENT
 	fwait
 	fstcw	(%esp)
@@ -20,8 +20,9 @@
 	andl	$0xffff, %eax
 	xorb	$0x3f, %al
 	RET
+	END(getfcr)
 
-FN(getfsr):
+NENTRY(getfsr)
 	ENT
 	fwait
 	fstsw	(%esp)
@@ -28,7 +29,9 @@
 	movw	(%esp), %ax
 	andl	$0xffff, %eax
 	RET
+	END(getfsr)
 
-FN(setfsr):
+NENTRY(setfsr)
 	fclex
 	ret
+	END(setfsr)
--- /dev/null
+++ b/lib9/setfcr-NetBSD-power.S
@@ -1,0 +1,33 @@
+#include <machine/asm.h>
+
+ENTRY_NOPROFILE(getfcr)
+	mffs	%f0
+	stfd	%f0,-16(%r1)
+	lwz	%r3,-12(%r1)
+	blr
+	END(getfcr)
+
+ENTRY_NOPROFILE(getfsr)
+	mffs	%f0
+	stfd	%f0,-16(%r1)
+	lwz	%r3,-12(%r1)
+	blr
+	END(getfsr)
+
+ENTRY_NOPROFILE(setfsr)
+	sync
+	stw	%r3,-12(%r1)
+	lfd	%f0,-16(%r1)
+	mtfsf	0xff, %f0
+	isync
+	blr
+	END(setfsr)
+
+ENTRY_NOPROFILE(setfcr)
+	sync
+	stw	%r3,-12(%r1)
+	lfd	%f0,-16(%r1)
+	mtfsf	0xff, %f0
+	isync
+	blr
+	END(setfcr)
--- /dev/null
+++ b/lib9/setfcr-OpenBSD-386.S
@@ -1,0 +1,34 @@
+
+#define	FN(x)	.type x,@function; .global x; x
+#define	ENT	subl $16, %esp
+#define	RET	addl $16, %esp; ret
+
+	.file	"setfcr-Linux-386.S"
+FN(setfcr):
+	ENT
+	xorb	$0x3f, %al
+	movl	%eax, (%esp)
+	fwait
+	fldcw	(%esp)
+	RET
+
+FN(getfcr):
+	ENT
+	fwait
+	fstcw	(%esp)
+	movw	(%esp), %ax
+	andl	$0xffff, %eax
+	xorb	$0x3f, %al
+	RET
+
+FN(getfsr):
+	ENT
+	fwait
+	fstsw	(%esp)
+	movw	(%esp), %ax
+	andl	$0xffff, %eax
+	RET
+
+FN(setfsr):
+	fclex
+	ret
--- a/libinterp/comp-power.c
+++ b/libinterp/comp-power.c
@@ -31,6 +31,10 @@
 #define	MFSPR(s, d)	gen(XO(31,339) | ((d)<<21) | ((s)<<11))
 #define	MTSPR(s, d)	gen(XO(31,467) | ((s)<<21) | ((d)<<11));
 
+#define	MFCR(d)		gen(XO(31,19) | ((d)<<21))
+#define	MTCRF(s, mask)	gen(XO(31,144) | ((s)<<21) | ((mask)<<12))
+#define	MTCR(s)		MTCRF(s, 0xff)
+
 #define	SLWI(d,a,n)	gen(slw((d),(a),(n),0))
 #define	LRET()	gen(Oblr)
 
@@ -1636,7 +1640,7 @@
 }
 
 enum {
-	PREFLEN = 20,	/* max instruction words in comvec */
+	PREFLEN = 64,	/* max instruction words in comvec */
 };
 
 static void
@@ -1649,6 +1653,45 @@
 	s = code = malloc(PREFLEN*sizeof(*code));
 	if(s == nil)
 		error(exNomem);
+
+#ifdef __ELF__
+	if(macjit) {
+		ulong *cp;
+		int r;
+
+		/*
+		 * ELF frame:
+		 *  0(%sp) - back chain
+		 *  4(%sp) - callee's LR save slot
+		 *  8(%sp) to 36(%sp) - 8 words of parameter list area
+		 * 40(%sp) to 48(%sp) - pad to 16 byte alignment/local vars
+		 */
+		mfspr(Ro1, Rlr);
+		AIRR(Ostw, Ro1, Rsp,4);
+		AIRR(Ostwu, Rsp, Rsp,-128);
+
+		MFCR(Ro1);
+		AIRR(Ostw, Ro1, Rsp,52);
+		for (r = 14; r < 32; ++r)
+			AIRR(Ostw, r, Rsp,r*4);
+
+		cp = code;
+		gen(Ob | Lk);
+
+		AIRR(Olwz, Ro1, Rsp,52);
+		MTCR(Ro1);
+		for (r = 14; r < 32; ++r)
+			AIRR(Olwz, r, Rsp,r*4);
+		AIRR(Oaddi, Rsp, Rsp, 128);
+
+		AIRR(Olwz, Ro1, Rsp,4);
+		mtspr(Rlr, Ro1);
+		LRET();
+
+		PATCH(cp);
+	}
+#endif	/* __ELF__ */
+
 	ldc((ulong)&R, Rreg);
 	SETR0();
 	mfspr(Rlink, Rlr);
--- a/libinterp/runt.h
+++ b/libinterp/runt.h
@@ -3096,8 +3096,8 @@
 #define Math_Infinity Infinity
 #define Math_NaN NaN
 #define Math_MachEps 2.220446049250313e-16
-#define Math_Pi 3.1415927410125732
-#define Math_Degree .01745329238474369
+#define Math_Pi 3.141592653589793
+#define Math_Degree .017453292519943295
 #define Math_INVAL 1
 #define Math_ZDIV 2
 #define Math_OVFL 4
--- /dev/null
+++ b/libmath/FPcontrol-AIX.c
@@ -1,0 +1,77 @@
+#include "lib9.h"
+#include "mathi.h"
+
+void
+FPinit(void)
+{
+	setfsr(0);	/* Clear pending exceptions */
+	setfcr(FPPDBL|FPRNR|FPINVAL|FPZDIV|FPUNFL|FPOVFL);
+}
+
+ulong
+getFPstatus(void)
+{
+	ulong fsr = 0, fsr9 = getfsr();
+	/* on specific machines, could be table lookup */
+	if(fsr9&FPAINEX) fsr |= INEX;
+	if(fsr9&FPAOVFL) fsr |= OVFL;
+	if(fsr9&FPAUNFL) fsr |= UNFL;
+	if(fsr9&FPAZDIV) fsr |= ZDIV;
+	if(fsr9&FPAINVAL) fsr |= INVAL;
+	return fsr;
+}
+
+ulong
+FPstatus(ulong fsr, ulong mask)
+{
+	ulong fsr9 = 0;
+	ulong old = getFPstatus();
+	fsr = (fsr&mask) | (old&~mask);
+	if(fsr&INEX) fsr9 |= FPAINEX;
+	if(fsr&OVFL) fsr9 |= FPAOVFL;
+	if(fsr&UNFL) fsr9 |= FPAUNFL;
+	if(fsr&ZDIV) fsr9 |= FPAZDIV;
+	if(fsr&INVAL) fsr9 |= FPAINVAL;
+	setfsr(fsr9);
+	return(old&mask);
+}
+
+ulong
+getFPcontrol(void)
+{
+	ulong fcr = 0, fcr9 = getfcr();
+	switch(fcr9&FPRMASK){
+		case FPRNR:	fcr = RND_NR; break;
+		case FPRNINF:	fcr = RND_NINF; break;
+		case FPRPINF:	fcr = RND_PINF; break;
+		case FPRZ:	fcr = RND_Z; break;
+	}
+	if(fcr9&FPINEX) fcr |= INEX;
+	if(fcr9&FPOVFL) fcr |= OVFL;
+	if(fcr9&FPUNFL) fcr |= UNFL;
+	if(fcr9&FPZDIV) fcr |= ZDIV;
+	if(fcr9&FPINVAL) fcr |= INVAL;
+	return fcr;
+}
+
+ulong
+FPcontrol(ulong fcr, ulong mask)
+{
+	ulong fcr9 = FPPDBL;
+	ulong old = getFPcontrol();
+	fcr = (fcr&mask) | (old&~mask);
+	if(fcr&INEX) fcr9 |= FPINEX;
+	if(fcr&OVFL) fcr9 |= FPOVFL;
+	if(fcr&UNFL) fcr9 |= FPUNFL;
+	if(fcr&ZDIV) fcr9 |= FPZDIV;
+	if(fcr&INVAL) fcr9 |= FPINVAL;
+	switch(fcr&RND_MASK){
+		case RND_NR:	fcr9 |= FPRNR; break;
+		case RND_NINF:	fcr9 |= FPRNINF; break;
+		case RND_PINF:	fcr9 |= FPRPINF; break;
+		case RND_Z:	fcr9 |= FPRZ; break;
+	}
+	setfcr(fcr9);
+	return(old&mask);
+}
+
--- /dev/null
+++ b/libmemdraw/mkfile-AIX
@@ -1,0 +1,1 @@
+<mkfile-Inferno
--- /dev/null
+++ b/libmemlayer/mkfile-AIX
@@ -1,0 +1,4 @@
+#
+#	System dependent objects for Posix model systems
+#
+SYSFILES=lalloc.$O
--- a/limbo/lex.c
+++ b/limbo/lex.c
@@ -1434,7 +1434,7 @@
 {
 	void *p;
 
-	p = malloc(n);
+	p = malloc(n != 0? n: 1);
 	if(p == nil)
 		fatal("out of memory");
 	return p;
--- a/limbo/limbo.y
+++ b/limbo/limbo.y
@@ -582,13 +582,13 @@
 	{
 		$$ = mkids(&$1->src, enter("junk", 0), $3, nil);
 		$$->store = Darg;
-		yyerror("illegal argument declaraion");
+		yyerror("illegal argument declaration");
 	}
 	| idterms ':' adtk
 	{
 		$$ = mkids(&$1->src, enter("junk", 0), $3, nil);
 		$$->store = Darg;
-		yyerror("illegal argument declaraion");
+		yyerror("illegal argument declaration");
 	}
 	;
 
--- a/limbo/types.c
+++ b/limbo/types.c
@@ -2024,7 +2024,7 @@
 				id->sym->name, base);
 		id->cycerr = 1;
 	}else if(arc & ArcCyc){
-		if((arc & ArcArray) && id->cyc == 0 && !(arc & ArcPolycyc)){
+		if((arc & ArcArray) && oldcycles && id->cyc == 0 && !(arc & ArcPolycyc)){
 			if(id->cycerr == 0)
 				error(base->src.start, "illegal circular reference to type %T in field %s of %t",
 					id->ty, id->sym->name, base);
@@ -3466,7 +3466,7 @@
 
 	if(t == nil)
 		return nil;
-if(debug['w']) print("expandtype %d %lux %T\n", t->kind, (ulong)t, t);
+if(debug['w']) print("expandtype %d %#p %T\n", t->kind, t, t);
 	if(!toccurs(t, tp))
 		return t;
 if(debug['w']) print("\texpanding\n");
--- a/limbo/y.tab.c
+++ b/limbo/y.tab.c
@@ -2025,7 +2025,7 @@
 {
 		yyval.ids = mkids(&yypt[-2].yyv.node->src, enter("junk", 0), yypt[-0].yyv.type, nil);
 		yyval.ids->store = Darg;
-		yyerror("illegal argument declaraion");
+		yyerror("illegal argument declaration");
 	} break;
 case 104:
 #line	588	"limbo.y"
@@ -2032,7 +2032,7 @@
 {
 		yyval.ids = mkids(&yypt[-2].yyv.node->src, enter("junk", 0), yypt[-0].yyv.type, nil);
 		yyval.ids->store = Darg;
-		yyerror("illegal argument declaraion");
+		yyerror("illegal argument declaration");
 	} break;
 case 105:
 #line	596	"limbo.y"
--- a/man/1/m4
+++ b/man/1/m4
@@ -4,6 +4,12 @@
 .SH SYNOPSIS
 .B m4
 [
+.BI -p prefix
+]
+[
+.B -t
+]
+[
 .BI -D name = value
 ] [
 .BI -Q name = value
@@ -236,7 +242,20 @@
 Undiverting discards the diverted text.
 .PD
 .PP
+The
+.B -p
+option causes
+.I m4
+to add the given prefix character to the names of predefined macros;
+typically the
+.I prefix
+is a Unicode character, to reduce the chance of a clash with macro names in the input text.
+The
+.B -t
+option produces a trace on standard error.
+.PP
 .I M4
+otherwise
 interprets its command line options after installing the predefined macro set.
 The
 .B -D
--- /dev/null
+++ b/mkfiles/mkfile-AIX-power
@@ -1,0 +1,25 @@
+TARGMODEL=	Posix
+TARGSHTYPE=	sh
+CPUS=		power
+
+O=		o
+OS=		o
+
+AR=		ar
+ARFLAGS=	crvs
+
+AS=		xlc -c
+ASFLAGS=
+
+CC=		xlc_r -c
+CFLAGS=	-q32 -g -O -qsuppress=1506-224\
+	-I$ROOT/$SYSTARG/$OBJTYPE/include\
+	-I$ROOT/include\
+
+ANSICPP=
+LD=		xlc_r
+LDFLAGS=	-bmaxdata:0x80000000
+SYSLIBS=	-lm
+
+YACC=		iyacc
+YFLAGS=		-d
--- a/mkfiles/mkfile-NetBSD-386
+++ b/mkfiles/mkfile-NetBSD-386
@@ -14,6 +14,7 @@
 CC=		cc -c
 CFLAGS=		-g\
 		-O\
+		-fno-strict-aliasing\
 		-Wno-deprecated-declarations -Wuninitialized -Wunused -Wreturn-type -Wimplicit\
 		-I$ROOT/NetBSD/386/include\
 		-I$ROOT/include\
--- /dev/null
+++ b/mkfiles/mkfile-NetBSD-power
@@ -1,0 +1,30 @@
+TARGMODEL=	Posix
+TARGSHTYPE=	sh
+CPUS=		power
+
+O=		o
+OS=		o
+
+AR=		ar
+ARFLAGS=	ruvs
+
+AS=		cc -c
+ASFLAGS=
+
+CC=		cc -c
+CFLAGS=		-g\
+		-O\
+		-fno-strict-aliasing\
+		-Wno-deprecated-declarations -Wuninitialized -Wunused -Wreturn-type -Wimplicit\
+		-I$ROOT/NetBSD/power/include\
+		-I$ROOT/include\
+		-I/usr/X11R7/include
+
+ANSICPP=
+LD=		cc
+LDFLAGS=
+
+SYSLIBS=
+
+YACC=		iyacc
+YFLAGS=		-d
--- /dev/null
+++ b/mkfiles/mkhost-AIX
@@ -1,0 +1,14 @@
+
+#	Variables for host system type = AIX
+
+SHELLTYPE=	sh
+SHELLNAME=	/bin/sh
+HOSTMODEL=	Posix
+OSTARG=		os
+
+DATA2S=		data2s
+NDATE=		ndate
+KSIZE=		ksize
+AWK=		awk
+
+MKAR=		archive-$SYSTARG
--- a/module/draw.m
+++ b/module/draw.m
@@ -91,7 +91,7 @@
 	RGB15: con Chans(((CIgnore<<4)|1)<<24 | ((CRed<<4)|5)<<16 | ((CGreen<<4)|5)<<8 | ((CBlue<<4)|5));
 	RGB16: con Chans(((CRed<<4)|5)<<16 | ((CGreen<<4)|6)<<8 | ((CBlue<<4)|5));
 	RGB24: con Chans(((CRed<<4)|8)<<16 | ((CGreen<<4)|8)<<8 | ((CBlue<<4)|8));
-	RGBA32: con Chans((((CRed<<4)|8)<<16 | ((CGreen<<4)|8)<<8 | ((CBlue<<4)|8))<<8 | ((CAlpha<<4)|8));
+	RGBA32: con Chans((((CRed<<4)|8)<<24 | ((CGreen<<4)|8)<<16 | ((CBlue<<4)|8))<<8 | ((CAlpha<<4)|8));
 	ARGB32: con Chans(((CAlpha<<4)|8)<<24 | ((CRed<<4)|8)<<16 | ((CGreen<<4)|8)<<8 | ((CBlue<<4)|8));	# stupid VGAs
 	XRGB32: con Chans(((CIgnore<<4)|8)<<24 | ((CRed<<4)|8)<<16 | ((CGreen<<4)|8)<<8 | ((CBlue<<4)|8));	# stupid VGAs
 
binary files /dev/null b/services/webget/smallinferno.gif differ
--- a/utils/8l/l.h
+++ b/utils/8l/l.h
@@ -195,7 +195,7 @@
 		uchar	obuf[MAXIO];			/* output buffer */
 		uchar	ibuf[MAXIO];			/* input buffer */
 	} u;
-	char	dbuf[1];
+	char	dbuf[2*MAXIO];
 } buf;
 
 #define	cbuf	u.obuf
@@ -236,8 +236,8 @@
 EXTERN	char	literal[32];
 EXTERN	Prog*	etextp;
 EXTERN	Prog*	firstp;
-EXTERN	char	fnuxi8[8];
-EXTERN	char	fnuxi4[4];
+EXTERN	uchar	fnuxi8[8];
+EXTERN	uchar	fnuxi4[4];
 EXTERN	Sym*	hash[NHASH];
 EXTERN	Sym*	histfrog[MAXHIST];
 EXTERN	int	histfrogp;
@@ -247,9 +247,9 @@
 EXTERN	int	libraryp;
 EXTERN	int	xrefresolv;
 EXTERN	char*	hunk;
-EXTERN	char	inuxi1[1];
-EXTERN	char	inuxi2[2];
-EXTERN	char	inuxi4[4];
+EXTERN	uchar	inuxi1[1];
+EXTERN	uchar	inuxi2[2];
+EXTERN	uchar	inuxi4[4];
 EXTERN	char	ycover[Ymax*Ymax];
 EXTERN	uchar*	andptr;
 EXTERN	uchar	and[30];
--- /dev/null
+++ b/utils/mk/archive-AIX.c
@@ -1,0 +1,203 @@
+#include	"mk.h"
+#include	<ar.h>
+
+static int dolong;
+
+static void atimes(char *);
+static char *split(char*, char**);
+
+long
+atimeof(int force, char *name)
+{
+	Symtab *sym;
+	long t;
+	char *archive, *member, buf[512];
+
+	archive = split(name, &member);
+	if(archive == 0)
+		Exit();
+
+	t = mtime(archive);
+	sym = symlook(archive, S_AGG, 0);
+	if(sym){
+		if(force || (t > (long)sym->value)){
+			atimes(archive);
+			sym->value = (void *)t;
+		}
+	}
+	else{
+		atimes(archive);
+		/* mark the aggegate as having been done */
+		symlook(strdup(archive), S_AGG, "")->value = (void *)t;
+	}
+	snprint(buf, sizeof(buf), "%s(%s)", archive, member);
+	sym = symlook(buf, S_TIME, 0);
+	if (sym)
+		return (long)sym->value;	/* uggh */
+	return 0;
+}
+
+void
+atouch(char *name)
+{
+	char *archive, *member;
+	int fd, i, namelen;
+	struct fl_hdr g;
+	struct ar_hdr h;
+	long t;
+	char memname[256];
+
+	archive = split(name, &member);
+	if(archive == 0)
+		Exit();
+
+	fd = open(archive, ORDWR);
+	if(fd < 0){
+		fd = create(archive, OWRITE, 0666);
+		if(fd < 0){
+			perror(archive);
+			Exit();
+		}
+		write(fd, ARMAG, SARMAG);
+		for(i = 0; i < 6; i++)
+			fprint(fd, "%-20ld", 0);
+	}
+	if(symlook(name, S_TIME, 0)){
+		/* hoon off and change it in situ */
+		LSEEK(fd, 0, 0);
+		if(read(fd, &g, SAR_FLHDR) != SAR_FLHDR){
+			close(fd);
+			return;
+		}
+		t = atol(g.fstmoff);
+		if(t == 0){
+			close(fd);
+			return;
+		}
+		for(;;){
+			LSEEK(fd, t, 0);
+			if(read(fd, (char *)&h, SAR_HDR) != SAR_HDR)
+				break;
+
+			namelen = atol(h.namlen);
+			if(namelen == 0 || namelen >= sizeof memname){
+				namelen = 0;
+				goto skip;
+			}
+			if(read(fd, memname, namelen) != namelen)
+				break;
+			memname[namelen] = 0;
+
+			if(strcmp(member, memname) == 0){
+				snprint(h.date, sizeof(h.date), "%-12ld", time(0));
+				LSEEK(fd, t, 0);
+				write(fd, (char *)&h, SAR_HDR);
+				break;
+			}
+		skip:
+			t = atol(h.nxtmem);
+			if(t == 0)
+				break;
+		}
+	}
+	close(fd);
+}
+
+static void
+atimes(char *ar)
+{
+	struct fl_hdr g;
+	struct ar_hdr h;
+	long o, t;
+	int fd, i, namelen;
+	char buf[2048], *p, *strings;
+	char name[1024];
+	Symtab *sym;
+
+	strings = nil;
+	fd = open(ar, OREAD);
+	if(fd < 0)
+		return;
+
+	if(read(fd, &g, SAR_FLHDR) != SAR_FLHDR){
+		close(fd);
+		return;
+	}
+	o = atol(g.fstmoff);
+	if(o == 0){
+		close(fd);
+		return;
+	}
+	for(;;){
+		LSEEK(fd, o, 0);
+		if(read(fd, (char *)&h, SAR_HDR) != SAR_HDR)
+			break;
+
+		t = atol(h.date);
+		if(t == 0)	/* as it sometimes happens; thanks ken */
+			t = 1;
+
+		namelen = atol(h.namlen);
+		if(namelen == 0 || namelen >= sizeof name){
+			namelen = 0;
+			goto skip;
+		}
+		if(read(fd, name, namelen) != namelen)
+			break;
+		name[namelen] = 0;
+
+		snprint(buf, sizeof buf, "%s(%s)", ar, name);
+		sym = symlook(strdup(buf), S_TIME, (void *)t);
+		sym->value = (void *)t;
+	skip:
+		o = atol(h.nxtmem);
+		if(o == 0)
+			break;
+	}
+	close(fd);
+	free(strings);
+}
+
+static int
+type(char *file)
+{
+	int fd;
+	char buf[SARMAG];
+
+	fd = open(file, OREAD);
+	if(fd < 0){
+		if(symlook(file, S_BITCH, 0) == 0){
+			Bprint(&bout, "%s doesn't exist: assuming it will be an archive\n", file);
+			symlook(file, S_BITCH, (void *)file);
+		}
+		return 1;
+	}
+	if(read(fd, buf, SARMAG) != SARMAG){
+		close(fd);
+		return 0;
+	}
+	close(fd);
+	return strncmp(ARMAG, buf, SARMAG) == 0;
+}
+
+static char*
+split(char *name, char **member)
+{
+	char *p, *q;
+
+	p = strdup(name);
+	q = utfrune(p, '(');
+	if(q){
+		*q++ = 0;
+		if(member)
+			*member = q;
+		q = utfrune(q, ')');
+		if (q)
+			*q = 0;
+		if(type(p))
+			return p;
+		free(p);
+		fprint(2, "mk: '%s' is not an archive\n", name);
+	}
+	return 0;
+}
--- a/utils/mk/mkfile
+++ b/utils/mk/mkfile
@@ -1,9 +1,11 @@
+MKAR=	archive
+
 <../../mkconfig
 
 TARG=mk
 
 OFILES=	arc.$O\
-	archive.$O\
+	$MKAR.$O\
 	bufblock.$O\
 	env.$O\
 	file.$O\