ref: ef6ce918c04fc82bea759fd843cc09e273ec9f6c
parent: 09cf3c0ae6c0fed01e32a149f4668b7a7d52944b
author: henesy <devnull@localhost>
date: Sun Nov 4 06:24:23 EST 2018
add platforms
binary files /dev/null b/FreeBSD/386/bin/data2c differ
binary files /dev/null b/FreeBSD/386/bin/iyacc differ
binary files /dev/null b/FreeBSD/386/bin/mk differ
binary files /dev/null b/FreeBSD/386/bin/mkext differ
--- /dev/null
+++ b/FreeBSD/386/include/emu.h
@@ -1,0 +1,30 @@
+/*
+ * 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[28];
+};
+
+#define KSTACK (32 * 1024)
+
+static __inline Proc *getup(void) {
+ Proc *p;
+ __asm__( "movl %%esp, %%eax\n\t"
+ : "=a" (p)
+ );
+ return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
+};
+
+#define up (getup())
+
+typedef sigjmp_buf osjmpbuf;
+#define ossetjmp(buf) sigsetjmp(buf, 1)
+
--- /dev/null
+++ b/FreeBSD/386/include/fpuctl.h
@@ -1,0 +1,76 @@
+/*
+ * Linux 386 fpu support
+ * Mimic Plan9 floating point support
+ */
+
+static void
+setfcr(ulong fcr)
+{
+ __asm__( "xorb $0x3f, %%al\n\t"
+ "pushw %%ax\n\t"
+ "fwait\n\t"
+ "fldcw (%%esp)\n\t"
+ "popw %%ax\n\t"
+ : /* no output */
+ : "al" (fcr)
+ );
+}
+
+static ulong
+getfcr(void)
+{
+ ulong fcr = 0;
+
+ __asm__( "pushl %%eax\n\t"
+ "fwait\n\t"
+ "fstcw (%%esp)\n\t"
+ "popl %%eax\n\t"
+ "xorb $0x3f, %%al\n\t"
+ : "=a" (fcr)
+ : "eax" (fcr)
+ );
+ return fcr;
+}
+
+static ulong
+getfsr(void)
+{
+ ulong fsr = -1;
+
+ __asm__( "fwait\n\t"
+ "fstsw (%%eax)\n\t"
+ "movl (%%eax), %%eax\n\t"
+ "andl $0xffff, %%eax\n\t"
+ : "=a" (fsr)
+ : "eax" (&fsr)
+ );
+ return fsr;
+}
+
+static void
+setfsr(ulong fsr)
+{
+ __asm__("fclex\n\t");
+}
+
+/* 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
--- /dev/null
+++ b/FreeBSD/386/include/lib9.h
@@ -1,0 +1,475 @@
+/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+/* these aren't really needed because FreeBSD does the right thing and makes off_t 64 bits, full stop */
+#define _LARGEFILE64_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+#include <sys/types.h>
+#include <sys/stat.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
+ */
+#define __LITTLE_ENDIAN
+
+#define nil ((void*)0)
+
+typedef unsigned char uchar;
+typedef signed char schar;
+typedef unsigned long ulong;
+typedef unsigned int Rune;
+typedef long long int vlong;
+typedef unsigned long long int uvlong;
+typedef unsigned int u32int;
+typedef uvlong u64int;
+
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned short u16int;
+typedef unsigned char u8int;
+typedef unsigned long 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;
+
+#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 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 uintptr 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()
+
--- /dev/null
+++ b/Inferno/386/include/lib9.h
@@ -1,0 +1,8 @@
+#include <u.h>
+#include <kern.h>
+
+/*
+ * Extensions for Inferno to basic libc.h
+ */
+
+#define __LITTLE_ENDIAN /* math/dtoa.c only */
--- /dev/null
+++ b/Inferno/386/include/u.h
@@ -1,0 +1,64 @@
+#define nil ((void*)0)
+typedef unsigned short ushort;
+typedef unsigned char uchar;
+typedef unsigned long ulong;
+typedef unsigned int uint;
+typedef signed char schar;
+typedef long long vlong;
+typedef unsigned long long uvlong;
+typedef unsigned long uintptr;
+typedef uint Rune;
+typedef union FPdbleword FPdbleword;
+typedef long jmp_buf[2];
+#define JMPBUFSP 0
+#define JMPBUFPC 1
+#define JMPBUFDPC 0
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned char u8int;
+typedef unsigned short u16int;
+typedef unsigned int u32int;
+typedef unsigned long long u64int;
+
+/* 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
+union FPdbleword
+{
+ double x;
+ struct { /* little endian */
+ ulong lo;
+ ulong hi;
+ };
+};
+
+typedef char* va_list;
+#define va_start(list, start) list =\
+ (sizeof(start) < 4?\
+ (char*)((int*)&(start)+1):\
+ (char*)(&(start)+1))
+#define va_end(list)\
+ USED(list)
+#define va_arg(list, mode)\
+ ((sizeof(mode) == 1)?\
+ ((mode*)(list += 4))[-4]:\
+ (sizeof(mode) == 2)?\
+ ((mode*)(list += 4))[-2]:\
+ ((mode*)(list += sizeof(mode)))[-1])
--- /dev/null
+++ b/Inferno/386/include/ureg.h
@@ -1,0 +1,25 @@
+struct Ureg
+{
+ ulong di; /* general registers */
+ ulong si; /* ... */
+ ulong bp; /* ... */
+ ulong nsp;
+ ulong bx; /* ... */
+ ulong dx; /* ... */
+ ulong cx; /* ... */
+ ulong ax; /* ... */
+ ulong gs; /* data segments */
+ ulong fs; /* ... */
+ ulong es; /* ... */
+ ulong ds; /* ... */
+ ulong trap; /* trap type */
+ ulong ecode; /* error code (or zero) */
+ ulong pc; /* pc */
+ ulong cs; /* old context */
+ ulong flags; /* old flags */
+ union {
+ ulong usp;
+ ulong sp;
+ };
+ ulong ss; /* old stack segment */
+};
--- /dev/null
+++ b/Inferno/arm/include/lib9.h
@@ -1,0 +1,8 @@
+#include <u.h>
+#include <kern.h>
+
+/*
+ * Extensions for Inferno to basic libc.h
+ */
+
+#define __LITTLE_ENDIAN /* math/dtoa.c */
--- /dev/null
+++ b/Inferno/arm/include/u.h
@@ -1,0 +1,65 @@
+#define nil ((void*)0)
+
+typedef unsigned short ushort;
+typedef unsigned char uchar;
+typedef unsigned long ulong;
+typedef unsigned int uint;
+typedef signed char schar;
+typedef long long vlong;
+typedef unsigned long long uvlong;
+typedef uint Rune;
+typedef union FPdbleword FPdbleword;
+typedef long jmp_buf[2];
+#define JMPBUFSP 0
+#define JMPBUFPC 1
+#define JMPBUFDPC 0
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned char u8int;
+typedef unsigned short u16int;
+typedef unsigned int u32int;
+typedef unsigned long long u64int;
+typedef unsigned long uintptr;
+
+/* FCR */
+#define FPINEX (1<<20)
+#define FPUNFL (1<<19)
+#define FPOVFL (1<<18)
+#define FPZDIV (1<<17)
+#define FPINVAL (1<<16)
+#define FPRNR (0<<0)
+#define FPRZ (1<<0)
+#define FPRPINF (2<<0)
+#define FPRNINF (3<<0)
+#define FPRMASK (3<<0)
+#define FPPEXT 0
+#define FPPSGL 0
+#define FPPDBL 0
+#define FPPMASK 0
+/* FSR */
+#define FPAINEX (1<<4)
+#define FPAUNFL (1<<3)
+#define FPAOVFL (1<<2)
+#define FPAZDIV (1<<1)
+#define FPAINVAL (1<<0)
+union FPdbleword
+{
+ double x;
+ struct { /* little endian (on VFP and now in software) */
+ ulong lo;
+ ulong hi;
+ };
+};
+
+typedef char* va_list;
+#define va_start(list, start) list =\
+ (sizeof(start) < 4?\
+ (char*)((int*)&(start)+1):\
+ (char*)(&(start)+1))
+#define va_end(list)\
+ USED(list)
+#define va_arg(list, mode)\
+ ((sizeof(mode) == 1)?\
+ ((mode*)(list += 4))[-4]:\
+ (sizeof(mode) == 2)?\
+ ((mode*)(list += 4))[-2]:\
+ ((mode*)(list += sizeof(mode)))[-1])
--- /dev/null
+++ b/Inferno/arm/include/ureg.h
@@ -1,0 +1,24 @@
+typedef struct Ureg {
+ uint r0;
+ uint r1;
+ uint r2;
+ uint r3;
+ uint r4;
+ uint r5;
+ uint r6;
+ uint r7;
+ uint r8;
+ uint r9;
+ uint r10;
+ uint r11;
+ uint r12;
+ union {
+ uint r13;
+ uint sp;
+ };
+ uint r14;
+ uint link;
+ uint type;
+ uint psr;
+ uint pc;
+} Ureg;
--- /dev/null
+++ b/Inferno/mips/include/lib9.h
@@ -1,0 +1,8 @@
+#include <u.h>
+#include <kern.h>
+
+/*
+ * Extensions for Inferno to basic libc.h
+ */
+
+#undef __LITTLE_ENDIAN /* math/dtoa.c; longs in MIPS doubles are big-endian */
--- /dev/null
+++ b/Inferno/mips/include/u.h
@@ -1,0 +1,65 @@
+#define nil ((void*)0)
+typedef unsigned short ushort;
+typedef unsigned char uchar;
+typedef unsigned long ulong;
+typedef unsigned int uint;
+typedef signed char schar;
+typedef long long vlong;
+typedef unsigned long long uvlong;
+typedef unsigned long uintptr;
+typedef uint Rune;
+typedef union FPdbleword FPdbleword;
+typedef long jmp_buf[2];
+#define JMPBUFSP 0
+#define JMPBUFPC 1
+#define JMPBUFDPC 0
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned char u8int;
+typedef unsigned short u16int;
+typedef unsigned int u32int;
+typedef unsigned long long u64int;
+
+/* FCR */
+#define FPINEX (1<<7)
+#define FPUNFL (1<<8)
+#define FPOVFL (1<<9)
+#define FPZDIV (1<<10)
+#define FPINVAL (1<<11)
+#define FPRNR (0<<0)
+#define FPRZ (1<<0)
+#define FPRPINF (2<<0)
+#define FPRNINF (3<<0)
+#define FPRMASK (3<<0)
+#define FPPEXT 0
+#define FPPSGL 0
+#define FPPDBL 0
+#define FPPMASK 0
+/* FSR */
+#define FPAINEX (1<<2)
+#define FPAOVFL (1<<4)
+#define FPAUNFL (1<<3)
+#define FPAZDIV (1<<5)
+#define FPAINVAL (1<<6)
+union FPdbleword
+{
+ double x;
+ struct { /* big endian */
+ ulong hi;
+ ulong lo;
+ };
+};
+
+/* stdarg */
+typedef char* va_list;
+#define va_start(list, start) list =\
+ (sizeof(start) < 4?\
+ (char*)((int*)&(start)+1):\
+ (char*)(&(start)+1))
+#define va_end(list)\
+ USED(list)
+#define va_arg(list, mode)\
+ ((sizeof(mode) == 1)?\
+ ((mode*)(list += 4))[-1]:\
+ (sizeof(mode) == 2)?\
+ ((mode*)(list += 4))[-1]:\
+ ((mode*)(list += sizeof(mode)))[-1])
--- /dev/null
+++ b/Inferno/power/include/lib9.h
@@ -1,0 +1,4 @@
+#include <u.h>
+#include <kern.h>
+
+#undef __LITTLE_ENDIAN /* math/dtoa.c; longs in PowerPC doubles are big-endian */
--- /dev/null
+++ b/Inferno/power/include/u.h
@@ -1,0 +1,84 @@
+#define nil ((void*)0)
+typedef unsigned short ushort;
+typedef unsigned char uchar;
+typedef unsigned long ulong;
+typedef unsigned int uint;
+typedef signed char schar;
+typedef long long vlong;
+typedef unsigned long long uvlong;
+typedef unsigned long uintptr;
+typedef uint Rune;
+typedef union FPdbleword FPdbleword;
+typedef long jmp_buf[2];
+#define JMPBUFSP 0
+#define JMPBUFPC 1
+#define JMPBUFDPC 0
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned char u8int;
+typedef unsigned short u16int;
+typedef unsigned int u32int;
+typedef unsigned long long u64int;
+
+/* 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) */
+#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
+
+#define FPAOVFL FPSOX
+#define FPAINEX FPSXX
+#define FPAUNFL FPSUX
+#define FPAZDIV FPSZX
+#define FPAINVAL FPSVX
+
+union FPdbleword
+{
+ double x;
+ struct { /* big endian */
+ ulong hi;
+ ulong lo;
+ };
+};
+
+typedef char* va_list;
+#define va_start(list, start) list =\
+ (sizeof(start) < 4?\
+ (char*)((int*)&(start)+1):\
+ (char*)(&(start)+1))
+#define va_end(list)\
+ USED(list)
+#define va_arg(list, mode)\
+ ((sizeof(mode) == 1)?\
+ ((mode*)(list += 4))[-1]:\
+ (sizeof(mode) == 2)?\
+ ((mode*)(list += 4))[-1]:\
+ ((mode*)(list += sizeof(mode)))[-1])
--- /dev/null
+++ b/Inferno/power/include/ureg.h
@@ -1,0 +1,43 @@
+struct Ureg
+{
+ ulong cause;
+ union { ulong srr1; ulong status;};
+ ulong pc; /* SRR0 */
+ ulong pad;
+ ulong lr;
+ ulong cr;
+ ulong xer;
+ ulong ctr;
+ ulong r0;
+ union{ ulong r1; ulong sp; ulong usp; };
+ ulong r2;
+ ulong r3;
+ ulong r4;
+ ulong r5;
+ ulong r6;
+ ulong r7;
+ ulong r8;
+ ulong r9;
+ ulong r10;
+ ulong r11;
+ ulong r12;
+ ulong r13;
+ ulong r14;
+ ulong r15;
+ ulong r16;
+ ulong r17;
+ ulong r18;
+ ulong r19;
+ ulong r20;
+ ulong r21;
+ ulong r22;
+ ulong r23;
+ ulong r24;
+ ulong r25;
+ ulong r26;
+ ulong r27;
+ ulong r28;
+ ulong r29;
+ ulong r30;
+ ulong r31;
+};
--- /dev/null
+++ b/Inferno/sparc/include/lib9.h
@@ -1,0 +1,9 @@
+#include <u.h>
+#include <kern.h>
+
+
+/*
+ * Extensions for Inferno to basic libc.h
+ */
+
+#undef __LITTLE_ENDIAN /* math/dtoa.c; longs in SPARC doubles are big-endian */
--- /dev/null
+++ b/Inferno/sparc/include/u.h
@@ -1,0 +1,64 @@
+#define nil ((void*)0)
+typedef unsigned short ushort;
+typedef unsigned char uchar;
+typedef unsigned long ulong;
+typedef unsigned int uint;
+typedef signed char schar;
+typedef long long vlong;
+typedef unsigned long long uvlong;
+typedef unsigned long uintptr;
+typedef uint Rune;
+typedef union FPdbleword FPdbleword;
+typedef long jmp_buf[2];
+#define JMPBUFSP 0
+#define JMPBUFPC 1
+#define JMPBUFDPC (-8)
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned char u8int;
+typedef unsigned short u16int;
+typedef unsigned int u32int;
+typedef unsigned long long u64int;
+
+/* FCR */
+#define FPINEX (1<<23)
+#define FPOVFL (1<<26)
+#define FPUNFL (1<<25)
+#define FPZDIV (1<<24)
+#define FPRNR (0<<30)
+#define FPRZ (1<<30)
+#define FPINVAL (1<<27)
+#define FPRPINF (2<<30)
+#define FPRNINF (3<<30)
+#define FPRMASK (3<<30)
+#define FPPEXT 0
+#define FPPSGL 0
+#define FPPDBL 0
+#define FPPMASK 0
+/* FSR */
+#define FPAINEX (1<<5)
+#define FPAZDIV (1<<6)
+#define FPAUNFL (1<<7)
+#define FPAOVFL (1<<8)
+#define FPAINVAL (1<<9)
+union FPdbleword
+{
+ double x;
+ struct { /* big endian */
+ ulong hi;
+ ulong lo;
+ };
+};
+
+typedef char* va_list;
+#define va_start(list, start) list =\
+ (sizeof(start) < 4?\
+ (char*)((int*)&(start)+1):\
+ (char*)(&(start)+1))
+#define va_end(list)\
+ USED(list)
+#define va_arg(list, mode)\
+ ((sizeof(mode) == 1)?\
+ ((mode*)(list += 4))[-1]:\
+ (sizeof(mode) == 2)?\
+ ((mode*)(list += 4))[-1]:\
+ ((mode*)(list += sizeof(mode)))[-1])
--- /dev/null
+++ b/Inferno/sparc/include/ureg.h
@@ -1,0 +1,45 @@
+struct Ureg
+{
+ ulong r0; /* unnecessary; just for symmetry */
+ union{
+ ulong sp; /* r1 */
+ ulong usp; /* r1 */
+ ulong r1;
+ };
+ ulong r2;
+ ulong r3;
+ ulong r4;
+ ulong r5;
+ ulong r6;
+ ulong r7;
+ ulong r8;
+ ulong r9;
+ ulong r10;
+ ulong r11;
+ ulong r12;
+ ulong r13;
+ ulong r14;
+ ulong r15;
+ ulong r16;
+ ulong r17;
+ ulong r18;
+ ulong r19;
+ ulong r20;
+ ulong r21;
+ ulong r22;
+ ulong r23;
+ ulong r24;
+ ulong r25;
+ ulong r26;
+ ulong r27;
+ ulong r28;
+ ulong r29;
+ ulong r30;
+ ulong r31;
+ ulong y;
+ ulong tbr;
+ ulong psr;
+ ulong npc;
+ ulong pc;
+ ulong pad; /* so structure is double word aligned */
+};
--- /dev/null
+++ b/Inferno/spim/include/lib9.h
@@ -1,0 +1,8 @@
+#include <u.h>
+#include <kern.h>
+
+/*
+ * Extensions for Inferno to basic libc.h
+ */
+
+#define __LITTLE_ENDIAN /* math/dtoa.c; longs in MIPS doubles are little-endian in LE mode */
--- /dev/null
+++ b/Inferno/spim/include/u.h
@@ -1,0 +1,56 @@
+#define nil ((void*)0)
+typedef unsigned short ushort;
+typedef unsigned char uchar;
+typedef unsigned long ulong;
+typedef unsigned int uint;
+typedef signed char schar;
+typedef long long vlong;
+typedef unsigned long long uvlong;
+typedef uint Rune;
+typedef union FPdbleword FPdbleword;
+typedef long jmp_buf[2];
+#define JMPBUFSP 0
+#define JMPBUFPC 1
+#define JMPBUFDPC 0
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned int u32int; /* for /sys/include/libsec.h */
+typedef unsigned char u8int;
+typedef unsigned short u16int;
+typedef unsigned long uintptr;
+
+/* FCR */
+#define FPINEX (1<<7)
+#define FPUNFL (1<<8)
+#define FPOVFL (1<<9)
+#define FPZDIV (1<<10)
+#define FPINVAL (1<<11)
+#define FPRNR (0<<0)
+#define FPRZ (1<<0)
+#define FPRPINF (2<<0)
+#define FPRNINF (3<<0)
+#define FPRMASK (3<<0)
+#define FPPEXT 0
+#define FPPSGL 0
+#define FPPDBL 0
+#define FPPMASK 0
+/* FSR */
+#define FPAINEX (1<<2)
+#define FPAOVFL (1<<4)
+#define FPAUNFL (1<<3)
+#define FPAZDIV (1<<5)
+#define FPAINVAL (1<<6)
+union FPdbleword
+{
+ double x;
+ struct { /* little endian */
+ ulong lo;
+ ulong hi;
+ };
+};
+
+/* stdarg */
+typedef char *va_list;
+#define va_start(list, start) list = (sizeof(start)<4 ? (char *)((int *)&(start)+1) : \
+(char *)(&(start)+1))
+#define va_arg(list, mode) ((mode*)(list += sizeof(mode)))[-1]
+#define va_end(list)
--- /dev/null
+++ b/Inferno/thumb/include/lib9.h
@@ -1,0 +1,8 @@
+#include <u.h>
+#include <kern.h>
+
+/*
+ * Extensions for Inferno to basic libc.h
+ */
+
+#undef __LITTLE_ENDIAN /* math/dtoa.c; longs in ARM doubles are big-endian */
--- /dev/null
+++ b/Inferno/thumb/include/u.h
@@ -1,0 +1,65 @@
+#define nil ((void*)0)
+
+typedef unsigned short ushort;
+typedef unsigned char uchar;
+typedef unsigned long ulong;
+typedef unsigned int uint;
+typedef signed char schar;
+typedef long long vlong;
+typedef unsigned long long uvlong;
+typedef uint Rune;
+typedef union FPdbleword FPdbleword;
+typedef long jmp_buf[2];
+#define JMPBUFSP 0
+#define JMPBUFPC 1
+#define JMPBUFDPC 0
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned char u8int;
+typedef unsigned short u16int;
+typedef unsigned int u32int;
+typedef unsigned long long u64int;
+typedef unsigned long uintptr;
+
+/* FCR */
+#define FPINEX (1<<20)
+#define FPUNFL (1<<19)
+#define FPOVFL (1<<18)
+#define FPZDIV (1<<17)
+#define FPINVAL (1<<16)
+#define FPRNR (0<<0)
+#define FPRZ (1<<0)
+#define FPRPINF (2<<0)
+#define FPRNINF (3<<0)
+#define FPRMASK (3<<0)
+#define FPPEXT 0
+#define FPPSGL 0
+#define FPPDBL 0
+#define FPPMASK 0
+/* FSR */
+#define FPAINEX (1<<4)
+#define FPAUNFL (1<<3)
+#define FPAOVFL (1<<2)
+#define FPAZDIV (1<<1)
+#define FPAINVAL (1<<0)
+union FPdbleword
+{
+ double x;
+ struct { /* big endian (on 7500) */
+ ulong hi;
+ ulong lo;
+ };
+};
+
+typedef char* va_list;
+#define va_start(list, start) list =\
+ (sizeof(start) < 4?\
+ (char*)((int*)&(start)+1):\
+ (char*)(&(start)+1))
+#define va_end(list)\
+ USED(list)
+#define va_arg(list, mode)\
+ ((sizeof(mode) == 1)?\
+ ((mode*)(list += 4))[-4]:\
+ (sizeof(mode) == 2)?\
+ ((mode*)(list += 4))[-2]:\
+ ((mode*)(list += sizeof(mode)))[-1])
--- /dev/null
+++ b/Inferno/thumb/include/ureg.h
@@ -1,0 +1,24 @@
+typedef struct Ureg {
+ uint r0;
+ uint r1;
+ uint r2;
+ uint r3;
+ uint r4;
+ uint r5;
+ uint r6;
+ uint r7;
+ uint r8;
+ uint r9;
+ uint r10;
+ uint r11;
+ uint r12;
+ union {
+ uint r13;
+ uint sp;
+ };
+ uint r14;
+ uint link;
+ uint type;
+ uint psr;
+ uint pc;
+} Ureg;
binary files /dev/null b/Linux/386/bin/c2l differ
binary files /dev/null b/Linux/386/bin/data2c differ
binary files /dev/null b/Linux/386/bin/ftl differ
binary files /dev/null b/Linux/386/bin/iar differ
binary files /dev/null b/Linux/386/bin/idea differ
binary files /dev/null b/Linux/386/bin/inm differ
binary files /dev/null b/Linux/386/bin/iyacc differ
binary files /dev/null b/Linux/386/bin/kprof differ
binary files /dev/null b/Linux/386/bin/ksize differ
binary files /dev/null b/Linux/386/bin/kstrip differ
binary files /dev/null b/Linux/386/bin/md5sum differ
binary files /dev/null b/Linux/386/bin/mk differ
binary files /dev/null b/Linux/386/bin/mk.save differ
binary files /dev/null b/Linux/386/bin/mkext differ
binary files /dev/null b/Linux/386/bin/mkppcimage differ
binary files /dev/null b/Linux/386/bin/ms2 differ
binary files /dev/null b/Linux/386/bin/ndate differ
binary files /dev/null b/Linux/386/bin/sqz differ
binary files /dev/null b/Linux/386/bin/srclist differ
binary files /dev/null b/Linux/386/bin/styxtest differ
--- /dev/null
+++ b/Linux/386/include/emu.h
@@ -1,0 +1,33 @@
+/*
+ * 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[28];
+};
+
+#define KSTACK (32 * 1024)
+
+#ifndef USE_PTHREADS
+static __inline Proc *getup(void) {
+ Proc *p;
+ __asm__( "movl %%esp, %%eax\n\t"
+ : "=a" (p)
+ );
+ return *(Proc **)((uintptr)p & ~(KSTACK - 1));
+}
+#else
+extern Proc* getup(void);
+#endif
+
+#define up (getup())
+
+typedef sigjmp_buf osjmpbuf;
+#define ossetjmp(buf) sigsetjmp(buf, 1)
--- /dev/null
+++ b/Linux/386/include/lib9.h
@@ -1,0 +1,495 @@
+/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
+#define USE_PTHREADS
+#ifndef _DEFAULT_SOURCE
+#define _DEFAULT_SOURCE
+#endif
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+#define _XOPEN_SOURCE 500
+#define _LARGEFILE_SOURCE 1
+#define _LARGEFILE64_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+#ifdef USE_PTHREADS
+#define _REENTRANT 1
+#endif
+#include <features.h>
+#include <sys/types.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>
+#include <time.h>
+#include <endian.h>
+
+#define getwd infgetwd
+
+#ifndef EMU
+typedef struct Proc Proc;
+#endif
+
+/*
+ * math module dtoa
+ * #define __LITTLE_ENDIAN /usr/include/endian.h under linux
+ */
+
+#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 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()
+
+/* 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);
--- /dev/null
+++ b/Linux/arm/include/emu.h
@@ -1,0 +1,34 @@
+/*
+ * 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[28];
+};
+
+
+#ifndef USE_PTHREADS
+#define KSTACK (16 * 1024) /* must be power of two */
+static __inline Proc *getup(void) {
+ Proc *p;
+ __asm__( "mov %0, %%sp;"
+ : "=r" (p)
+ );
+ return *(Proc **)((uintptr)p & ~(KSTACK - 1));
+}
+#else
+#define KSTACK (32 * 1024) /* need not be power of two */
+extern Proc* getup(void);
+#endif
+
+#define up (getup())
+
+typedef sigjmp_buf osjmpbuf;
+#define ossetjmp(buf) sigsetjmp(buf, 1)
--- /dev/null
+++ b/Linux/arm/include/lib9.h
@@ -1,0 +1,504 @@
+/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
+#define USE_PTHREADS
+#ifndef _DEFAULT_SOURCE
+#define _DEFAULT_SOURCE
+#endif
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+#define _XOPEN_SOURCE 500
+#define _LARGEFILE_SOURCE 1
+#define _LARGEFILE64_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+#ifdef USE_PTHREADS
+#define _REENTRANT 1
+#endif
+#include <features.h>
+#include <sys/types.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>
+#include <endian.h>
+
+#define getwd infgetwd
+
+#ifndef EMU
+typedef struct Proc Proc;
+#endif
+
+/*
+ * math module dtoa
+ * #define __LITTLE_ENDIAN /usr/include/endian.h under linux
+ */
+
+#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 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()
+
+/* need the inline because the link register is not saved in a known location */
+static __inline uintptr getcallerpc(void* dummy) {
+ ulong lr;
+ __asm__( "mov %0, %%lr;"
+ : "=r" (lr)
+ );
+ return lr;
+}
+
+
+extern void setfcr(ulong);
+extern void setfsr(ulong);
+extern ulong getfcr(void);
+extern ulong getfsr(void);
+
+/* 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
binary files /dev/null b/Linux/power/bin/data2c differ
binary files /dev/null b/Linux/power/bin/iyacc differ
binary files /dev/null b/Linux/power/bin/mk differ
binary files /dev/null b/Linux/power/bin/mkext differ
--- /dev/null
+++ b/Linux/power/include/emu.h
@@ -1,0 +1,37 @@
+/*
+ * 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];
+};
+
+/*
+ * Later versions of Linux seemed to need large stack for gethostbyname()
+ * so we had this at 128k, which is excessive. More recently, we've
+ * reduced it again after testing stack usage by gethostbyname.
+ */
+#define KSTACK (16 * 1024)
+
+#ifndef USE_PTHREADS
+static __inline Proc *getup(void) {
+ Proc *p;
+ __asm__( "mr %0, 1" : "=r" (p));
+ return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
+}
+#else
+extern Proc* getup(void);
+#endif
+
+#define up (getup())
+
+typedef sigjmp_buf osjmpbuf;
+#define ossetjmp(buf) sigsetjmp(buf, 1)
+
--- /dev/null
+++ b/Linux/power/include/lib9.h
@@ -1,0 +1,517 @@
+/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
+#define USE_PTHREADS
+#ifndef _DEFAULT_SOURCE
+#define _DEFAULT_SOURCE
+#endif
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+#define _XOPEN_SOURCE 500
+#define _LARGEFILE_SOURCE 1
+#define _LARGEFILE64_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+#ifdef USE_PTHREADS
+#define _REENTRANT 1
+#endif
+#include <features.h>
+#include <sys/types.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>
+#include <endian.h>
+
+#define getwd infgetwd
+
+#ifndef EMU
+typedef struct Proc Proc;
+#endif
+
+/*
+ * math module dtoa
+ * #define __LITTLE_ENDIAN /usr/include/endian.h under linux
+ */
+#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 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
--- /dev/null
+++ b/Linux/spim/include/emu.h
@@ -1,0 +1,39 @@
+/*
+ * 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[28];
+};
+
+/*
+ * Later versions of Linux seemed to need large stack for gethostbyname()
+ * so we had this at 128k, which is excessive. More recently, we've
+ * reduced it again after testing stack usage by gethostbyname.
+ */
+#define KSTACK (16 * 1024)
+
+#ifndef USE_PTHREADS
+static __inline Proc *getup(void) {
+ Proc *p;
+ __asm__( "move %0, $29\n\t"
+ : "=r" (p)
+ );
+ return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
+}
+#else
+extern Proc* getup(void);
+#endif
+
+#define up (getup())
+
+typedef sigjmp_buf osjmpbuf;
+#define ossetjmp(buf) sigsetjmp(buf, 1)
+
--- /dev/null
+++ b/Linux/spim/include/lib9.h
@@ -1,0 +1,499 @@
+/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
+#define USE_PTHREADS
+#ifndef _DEFAULT_SOURCE
+#define _DEFAULT_SOURCE
+#endif
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+#define _LARGEFILE_SOURCE 1
+#define _LARGEFILE64_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+#include <features.h>
+#include <sys/types.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>
+#include <endian.h>
+
+#define getwd infgetwd
+
+#ifndef EMU
+typedef struct Proc Proc;
+#endif
+
+/*
+ * math module dtoa
+ * #define __LITTLE_ENDIAN according to target under linux
+ */
+
+#ifdef __MIPSEB__
+#undef __LITTLE_ENDIAN
+#else
+#define __LITTLE_ENDIAN 1234
+#endif
+
+#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 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 {
+ ulong val;
+ int pid;
+} Lock;
+
+extern ulong _tas(ulong*);
+
+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);
+
+/* FCR */
+#define FCRBITS 0x00000F83
+#define FPINEX (1<<7)
+#define FPUNFL (1<<8)
+#define FPOVFL (1<<9)
+#define FPZDIV (1<<10)
+#define FPINVAL (1<<11)
+#define FPRNR (0<<0)
+#define FPRZ (1<<0)
+#define FPRPINF (2<<0)
+#define FPRNINF (3<<0)
+#define FPRMASK (3<<0)
+#define FPPEXT 0
+#define FPPSGL 0
+#define FPPDBL 0
+#define FPPMASK 0
+/* FSR */
+#define FSRBITS 0x0003F07C
+#define FPAINEX (1<<2)
+#define FPAOVFL (1<<4)
+#define FPAUNFL (1<<3)
+#define FPAZDIV (1<<5)
+#define FPAINVAL (1<<6)
binary files /dev/null b/MacOSX/386/bin/data2c differ
binary files /dev/null b/MacOSX/386/bin/iyacc differ
binary files /dev/null b/MacOSX/386/bin/mk differ
binary files /dev/null b/MacOSX/386/bin/mkext differ
--- /dev/null
+++ b/MacOSX/386/include/emu.h
@@ -1,0 +1,34 @@
+/*
+ * system- and machine-specific declarations for emu:
+ * floating-point save and restore, signal handling primitive, and
+ * implementation of the current-process variable `up'.
+ */
+
+extern Proc *getup(void);
+#define up (getup())
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+
+// something is at odds between i386/fpu.h and some of the thread headers
+#define fp_control inffp_control
+#define fp_control_t inffp_control_t
+#define fp_status inffp_status
+#define fp_status_t inffp_status_t
+
+#include <architecture/i386/fpu.h>
+
+typedef struct FPU FPU;
+struct FPU
+{
+ fp_state_t env;
+};
+
+#undef fp_control
+#undef fp_control_t
+#undef fp_status
+#undef fp_status_t
+
+typedef sigjmp_buf osjmpbuf;
+#define ossetjmp(buf) sigsetjmp(buf, 1)
--- /dev/null
+++ b/MacOSX/386/include/lib9.h
@@ -1,0 +1,516 @@
+/*
+ * Based on FreeBSD lib9.h
+ * Copyright © 1998, 1999 Lucent Technologies Inc. All rights reserved.
+ * Revisions Copyright © 1999, 2002 Vita Nuova Limited. All rights reserved.
+ * Revisions Copyright © 2002, 2003 Corpus Callosum Corporation. All rights reserved.
+ */
+
+/* define _BSD_SOURCE to use ISO C, POSIX, and 4.4BSD things. */
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+#define _LARGEFILE64_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+
+#include <sys/types.h>
+#include <sys/stat.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 nil ((void*)0)
+
+// typedef unsigned short ushort;
+typedef unsigned char uchar;
+typedef unsigned long ulong;
+// typedef unsigned int uint;
+typedef signed char schar;
+typedef long long vlong;
+typedef unsigned long long uvlong;
+typedef unsigned int Rune;
+typedef unsigned int u32int;
+typedef uvlong u64int;
+
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned short u16int;
+typedef unsigned char u8int;
+typedef unsigned long 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;
+
+/* handle conflicts with host os libs */
+#define getwd infgetwd
+#define scalb infscalb
+#define div infdiv
+#define panic infpanic
+#define rint infrint
+#define rcmd infrcmd
+#define pow10 infpow10
+
+#ifndef EMU
+typedef struct Proc Proc;
+#endif
+
+/*
+ * math module dtoa
+ */
+#include <machine/endian.h>
+#define __LITTLE_ENDIAN
+
+#define USED(x) if(x){}else{}
+#define SET(x)
+
+#define nelem(x) (sizeof(x)/sizeof((x)[0]))
+#undef offsetof
+#undef assert
+#define offsetof(s, m) (ulong)(&(((s*)0)->m))
+#define assert(x) if(x){}else _assert("x")
+
+/*
+ * 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);
+extern vlong strtoll(const char*, char**, int);
+#define qsort infqsort
+extern void qsort(void*, long, long, int (*)(void*, void*));
+
+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 uintptr 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*);
+extern void perror(const char*);
+extern double pow10(int);
+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=0;\
+ 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()
+
+/* 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);
--- /dev/null
+++ b/MacOSX/README
@@ -1,0 +1,72 @@
+This file is of historical interest only, but serves to note that
+much of the work of the MacOSX ports was originally done by Corpus Callosum.
+Bugs to support@vitanuova.com, though.
+
+March 2006: initial MacOSX 10.4/x86 port
+
+12-Dec-2003
+Emu can use wm with Apple's X11R6 again.
+
+08-Dec-2003
+Inferno Services (6660, 6666-6676, 2202)
+
+26-Aug-2003
+In order to run and use Inferno services appropriately on OSX, you need to ensure that the Sharing System Preferences include an entry in the Firewall section that is turned on and looks like the following line:
+
+Inferno services (6660, 6666-6674)
+
+
+05-Jul-2003
+In order to support 1.4, the build will now use the default 'mk' provided with the Inferno distribution. You can also copy tcshrc to the Inferno ROOT and source the file from that directory before running or building emu. Modified mkfiles and sources are now available in the srcMacOSX archive. You may also want to change 'mkconfig' with the following diff
+
+% cvs diff -r 1.1 mkconfig
+Index: mkconfig
+===================================================================
+RCS file: /usr/local/Repository/cvs/vitanuova/inferno_v14/mkconfig,v
+retrieving revision 1.1
+retrieving revision 1.3
+diff -r1.1 -r1.3
+7c7
+< ROOT=/usr/inferno
+---
+> ROOT=$ROOT
+17c17
+< SYSHOST=Plan9 # build system OS type (Hp, Inferno, Irix, Linux, Nt, Plan9, Solaris)
+---
+> SYSHOST=MacOSX # build system OS type (Hp, Inferno, Irix, Linux, Nt, Plan9, Solaris)
+25c25
+< OBJTYPE=$objtype
+---
+> OBJTYPE=power
+
+
+
+16-May-2003
+
+The build now uses the open sourced 'mk' from http://www.pdos.lcs.mit.edu/~rsc/software/
+
+There is a file .tcshrc at the root of this tree (..) that can be used to set up the environment required to build emu.
+
+
+
+28-Feb-2001
+
+The initial port has been provided by Corpus Callosum Corporation.
+
+This port of Inferno for Darwin, Mac OS X, and Mac OS X Server hosted environments currently provides base 'emu' support. Wm, audio, and other services are not currently ported. It has only been tested on UFS partitions and will require further testing for HFS+ support.
+
+Emu -c1 currently errors out as "Illegal instruction"
+
+Various malloc/free (from libc/System on Mac OS X/Darwin) warnings should be removed in the following version.
+
+eia devices will recognize /dev/ttyd.irda and /dev/ttyd.modem though both are completely untested (need to get updates to the RCX interface to test irda).
+
+The following modification was added to various 'mkfile' to support required redefinition of varios core functions.
+
+ <$ROOT/mkfiles/mkalloc-$SYSHOST-$OBJTYPE
+
+Some of the base libraries and utils will have *.pbproj files which were used to bootstrap the initial build system on Mac OS X (Public Beta).
+
+
+
+"Mac OS X" and "Mac OS X Server" are trade marks of Apple Computer, Inc.
binary files /dev/null b/MacOSX/power/bin/data2c differ
binary files /dev/null b/MacOSX/power/bin/iyacc differ
binary files /dev/null b/MacOSX/power/bin/mk differ
binary files /dev/null b/MacOSX/power/bin/mkext differ
--- /dev/null
+++ b/MacOSX/power/include/emu.h
@@ -1,0 +1,22 @@
+/*
+ * system- and machine-specific declarations for emu:
+ * floating-point save and restore, signal handling primitive, and
+ * implementation of the current-process variable `up'.
+ */
+
+extern Proc *getup(void);
+#define up (getup())
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+
+#include <architecture/ppc/fp_regs.h>
+
+typedef union {
+ double __dbl;
+ ppc_fp_scr_t __src;
+} FPU;
+
+typedef sigjmp_buf osjmpbuf;
+#define ossetjmp(buf) sigsetjmp(buf, 1)
--- /dev/null
+++ b/MacOSX/power/include/lib9.h
@@ -1,0 +1,537 @@
+/*
+ * Based on FreeBSD lib9.h
+ * Copyright © 1998, 1999 Lucent Technologies Inc. All rights reserved.
+ * Revisions Copyright © 1999, 2002 Vita Nuova Limited. All rights reserved.
+ * Revisions Copyright © 2002, 2003 Corpus Callosum Corporation. All rights reserved.
+ */
+
+/* define _BSD_SOURCE to use ISO C, POSIX, and 4.4BSD things. */
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+#define _LARGEFILE64_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+
+#include <sys/types.h>
+#include <sys/stat.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 nil ((void*)0)
+
+// typedef unsigned short ushort;
+typedef unsigned char uchar;
+typedef unsigned long ulong;
+// typedef unsigned int uint;
+typedef signed char schar;
+typedef long long vlong;
+typedef unsigned long long uvlong;
+typedef unsigned int Rune;
+typedef unsigned int u32int;
+typedef uvlong u64int;
+
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned short u16int;
+typedef unsigned char u8int;
+typedef unsigned long 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;
+
+/* handle conflicts with host os libs */
+#define getwd infgetwd
+#define scalb infscalb
+#define div infdiv
+#define panic infpanic
+#define rint infrint
+#define rcmd infrcmd
+#define pow10 infpow10
+
+#ifndef EMU
+typedef struct Proc Proc;
+#endif
+
+/*
+ * math module dtoa
+ */
+#include <machine/endian.h>
+#define __BIG_ENDIAN
+
+#define USED(x) if(x){}else{}
+#define SET(x)
+
+#define nelem(x) (sizeof(x)/sizeof((x)[0]))
+#undef offsetof
+#undef assert
+#define offsetof(s, m) (ulong)(&(((s*)0)->m))
+#define assert(x) if(x){}else _assert("x")
+
+/*
+ * 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);
+extern vlong strtoll(const char*, char**, int);
+#define qsort infqsort
+extern void qsort(void*, long, long, int (*)(void*, void*));
+
+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 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 uintptr 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*);
+extern void perror(const char*);
+extern double pow10(int);
+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()
+
+
+/* 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
+
+extern void setfcr(ulong);
+extern void setfsr(ulong);
+extern ulong getfcr(void):
+extern ulong getfsr(void);
--- /dev/null
+++ b/MacOSX/tcshrc
@@ -1,0 +1,12 @@
+#
+# needed for the build process
+#
+set path=( $path `pwd`/MacOSX/power/bin )
+
+setenv EMU "-r`pwd` -g1024x768"
+
+setenv ROOT `pwd`
+setenv SYSHOST MacOSX
+setenv OBJTYPE power
+setenv ACIDLIB $ROOT/lib/acid
+
binary files /dev/null b/NetBSD/386/bin/data2c differ
binary files /dev/null b/NetBSD/386/bin/mk differ
binary files /dev/null b/NetBSD/386/bin/mkext differ
binary files /dev/null b/NetBSD/386/bin/yacc differ
--- /dev/null
+++ b/NetBSD/386/include/emu.h
@@ -1,0 +1,30 @@
+/*
+ * 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[28];
+};
+
+#define KSTACK (32 * 1024)
+
+static __inline Proc *getup(void) {
+ Proc *p;
+ __asm__( "movl %%esp, %%eax\n\t"
+ : "=a" (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/386/include/lib9.h
@@ -1,0 +1,504 @@
+#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 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()
+
+/* 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);
--- /dev/null
+++ b/OpenBSD/386/include/emu.h
@@ -1,0 +1,30 @@
+/*
+ * 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[28];
+};
+
+#define KSTACK (32 * 1024)
+
+static __inline Proc *getup(void) {
+ Proc *p;
+ __asm__( "movl %%esp, %%eax\n\t"
+ : "=a" (p)
+ );
+ return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
+};
+
+#define up (getup())
+
+typedef sigjmp_buf osjmpbuf;
+#define ossetjmp(buf) sigsetjmp(buf, 1)
+
--- /dev/null
+++ b/OpenBSD/386/include/fpuctl.h
@@ -1,0 +1,76 @@
+/*
+ * 386 fpu support
+ * Mimic Plan9 floating point support
+ */
+
+static void
+setfcr(ulong fcr)
+{
+ __asm__( "xorb $0x3f, %%al\n\t"
+ "pushw %%ax\n\t"
+ "fwait\n\t"
+ "fldcw (%%esp)\n\t"
+ "popw %%ax\n\t"
+ : /* no output */
+ : "al" (fcr)
+ );
+}
+
+static ulong
+getfcr(void)
+{
+ ulong fcr = 0;
+
+ __asm__( "pushl %%eax\n\t"
+ "fwait\n\t"
+ "fstcw (%%esp)\n\t"
+ "popl %%eax\n\t"
+ "xorb $0x3f, %%al\n\t"
+ : "=a" (fcr)
+ : "eax" (fcr)
+ );
+ return fcr;
+}
+
+static ulong
+getfsr(void)
+{
+ ulong fsr = -1;
+
+ __asm__( "fwait\n\t"
+ "fstsw (%%eax)\n\t"
+ "movl (%%eax), %%eax\n\t"
+ "andl $0xffff, %%eax\n\t"
+ : "=a" (fsr)
+ : "eax" (&fsr)
+ );
+ return fsr;
+}
+
+static void
+setfsr(ulong fsr)
+{
+ __asm__("fclex\n\t");
+}
+
+/* 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
--- /dev/null
+++ b/OpenBSD/386/include/lib9.h
@@ -1,0 +1,475 @@
+/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
+#ifndef _BSD_SOURCE
+#define _BSD_SOURCE
+#endif
+/* 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
+#include <sys/types.h>
+#include <sys/stat.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
+ */
+#define __LITTLE_ENDIAN
+
+#define nil ((void*)0)
+
+typedef unsigned char uchar;
+typedef signed char schar;
+//typedef unsigned long ulong;
+typedef unsigned int Rune;
+typedef long long int vlong;
+typedef unsigned long long int uvlong;
+typedef unsigned int u32int;
+typedef uvlong u64int;
+
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned short u16int;
+typedef unsigned char u8int;
+typedef unsigned long 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;
+
+#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 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 uintptr 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()
+
binary files /dev/null b/Plan9/386/bin/data2c differ
--- /dev/null
+++ b/Plan9/386/include/emu.h
@@ -1,0 +1,22 @@
+/*
+ * system- and machine-specific declarations for emu:
+ * floating-point save and restore, signal handling primitive, and
+ * implementation of the current-process variable `up'.
+ */
+
+extern Proc** Xup;
+#define up (*Xup)
+
+typedef struct FPU FPU;
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+struct FPU
+{
+ uchar env[28];
+};
+
+typedef jmp_buf osjmpbuf;
+#define ossetjmp(buf) setjmp(buf)
+
--- /dev/null
+++ b/Plan9/386/include/lib9.h
@@ -1,0 +1,1 @@
+#include "../../include/lib9.h"
--- /dev/null
+++ b/Plan9/386/include/u.h
@@ -1,0 +1,1 @@
+#include "/386/include/u.h"
--- /dev/null
+++ b/Plan9/arm/include/emu.h
@@ -1,0 +1,22 @@
+/*
+ * system- and machine-specific declarations for emu:
+ * floating-point save and restore, signal handling primitive, and
+ * implementation of the current-process variable `up'.
+ */
+
+extern Proc** Xup;
+#define up (*Xup)
+
+typedef struct FPU FPU;
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+struct FPU
+{
+ int fpcsr;
+};
+
+typedef jmp_buf osjmpbuf;
+#define ossetjmp(buf) setjmp(buf)
+
--- /dev/null
+++ b/Plan9/arm/include/lib9.h
@@ -1,0 +1,1 @@
+#include "../../include/lib9.h"
--- /dev/null
+++ b/Plan9/arm/include/u.h
@@ -1,0 +1,1 @@
+#include "/arm/include/u.h"
--- /dev/null
+++ b/Plan9/include/lib9.h
@@ -1,0 +1,14 @@
+#include <u.h>
+typedef usize size_t;
+
+#define Rendez xRendez
+#include <libc.h>
+#undef Rendez
+
+
+/*
+ * Extensions for Inferno to basic libc.h
+ */
+
+#define setbinmode()
+#define USE_FPdbleword
--- /dev/null
+++ b/Plan9/include/lib9x.h
@@ -1,0 +1,20 @@
+#include <u.h>
+typedef usize size_t;
+
+#define Runeerror xRuneerror
+#define Rendez xRendez
+#include <libc.h>
+#undef Runeerror
+#undef Rendez
+
+
+enum
+{
+ Runeerror = 0x80, /* decoding error in UTF */
+};
+/*
+ * Extensions for Inferno to basic libc.h
+ */
+
+#define setbinmode()
+#define USE_FPdbleword
--- /dev/null
+++ b/Plan9/mips/include/emu.h
@@ -1,0 +1,23 @@
+/*
+ * system- and machine-specific declarations for emu:
+ * floating-point save and restore, signal handling primitive, and
+ * implementation of the current-process variable `up'.
+ */
+
+extern Proc** Xup;
+#define up (*Xup)
+
+typedef struct FPU FPU;
+
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+struct FPU
+{
+ uchar env[28];
+};
+
+typedef jmp_buf osjmpbuf;
+#define ossetjmp(buf) setjmp(buf)
+
--- /dev/null
+++ b/Plan9/mips/include/lib9.h
@@ -1,0 +1,1 @@
+#include "../../include/lib9.h"
--- /dev/null
+++ b/Plan9/mips/include/u.h
@@ -1,0 +1,1 @@
+#include "/mips/include/u.h"
--- /dev/null
+++ b/Plan9/power/include/emu.h
@@ -1,0 +1,30 @@
+/*
+ * system- and machine-specific declarations for emu:
+ * floating-point save and restore, signal handling primitive, and
+ * implementation of the current-process variable `up'.
+ */
+
+extern Proc** Xup;
+#define up (*Xup)
+
+typedef struct FPU FPU;
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+typedef struct FPU FPU;
+struct FPU
+{
+ double fpreg[32];
+ union {
+ double fpscrd;
+ struct {
+ ulong pad;
+ ulong fpscr;
+ };
+ };
+};
+
+typedef jmp_buf osjmpbuf;
+#define ossetjmp(buf) setjmp(buf)
+
--- /dev/null
+++ b/Plan9/power/include/lib9.h
@@ -1,0 +1,1 @@
+#include "../../include/lib9.h"
--- /dev/null
+++ b/Plan9/power/include/u.h
@@ -1,0 +1,1 @@
+#include "/power/include/u.h"
--- /dev/null
+++ b/Plan9/sparc/include/emu.h
@@ -1,0 +1,22 @@
+/*
+ * system- and machine-specific declarations for emu:
+ * floating-point save and restore, signal handling primitive, and
+ * implementation of the current-process variable `up'.
+ */
+
+extern Proc** Xup;
+#define up (*Xup)
+
+typedef struct FPU FPU;
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+struct FPU
+{
+ ulong fsr;
+};
+
+typedef jmp_buf osjmpbuf;
+#define ossetjmp(buf) setjmp(buf)
+
--- /dev/null
+++ b/Plan9/sparc/include/lib9.h
@@ -1,0 +1,1 @@
+#include "../../include/lib9.h"
--- /dev/null
+++ b/Plan9/sparc/include/os.h
@@ -1,0 +1,17 @@
+/*
+ * Solaris 2.5/sparc
+ */
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+typedef struct FPU FPU;
+struct FPU
+{
+ ulong fsr;
+};
+
+extern Proc *getup();
+#define up (getup())
+
+#define BIGEND
--- /dev/null
+++ b/Plan9/sparc/include/u.h
@@ -1,0 +1,1 @@
+#include "/sparc/include/u.h"
--- /dev/null
+++ b/Solaris/386/include/emu.h
@@ -1,0 +1,21 @@
+/*
+ * system- and machine-specific declarations for emu:
+ * floating-point save and restore, signal handling primitive, and
+ * implementation of the current-process variable `up'.
+ */
+
+extern Proc* getup(void);
+#define up (getup())
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+typedef struct FPU FPU;
+struct FPU
+{
+ uchar env[28];
+};
+
+typedef sigjmp_buf osjmpbuf;
+#define ossetjmp(buf) sigsetjmp(buf, 1)
+
--- /dev/null
+++ b/Solaris/386/include/lib9.h
@@ -1,0 +1,395 @@
+#define _POSIX_SOURCE
+#define _POSIX_C_SOURCE 1
+#define _LARGEFILE64_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+#include <stdlib.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <string.h>
+#include "math.h"
+#include <fcntl.h>
+#include <setjmp.h>
+#include <float.h>
+
+#define getwd infgetwd
+
+/*
+ * math/dtoa.c
+ */
+#define __LITTLE_ENDIAN
+
+#define nil ((void*)0)
+
+typedef unsigned char uchar;
+typedef unsigned int uint;
+typedef unsigned long ulong;
+typedef signed char schar;
+typedef unsigned short ushort;
+typedef unsigned int Rune;
+typedef long long int vlong;
+typedef unsigned long long int uvlong;
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned short u16int;
+typedef unsigned char u8int;
+typedef unsigned long 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;
+
+#define USED(x) if(x);else
+#define SET(x)
+
+#define nelem(x) (sizeof(x)/sizeof((x)[0]))
+
+/*
+ * mem and string routines are declared by ANSI/POSIX files above
+ */
+
+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*);
+
+extern int getfields(char*, char**, int, int, char*);
+extern uintptr getcallerpc(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);
+
+extern char* strdup(const char*);
+extern int tokenize(char*, char**, int);
+extern vlong strtoll(const char*, char**, int);
+#define qsort infqsort
+extern void qsort(void*, long, long, int (*)(void*, void*));
+
+extern int isNaN(double);
+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];
+};
+
+/*
+ * one-of-a-kind
+ */
+extern int getfields(char*, char**, int, int, char*);
+extern char* getuser(void);
+extern char* getwd(char*, int);
+extern double pow10(int);
+extern double ipow10(int);
+extern vlong strtoll(const char*, char**, int);
+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*);
+
+/*
+ * system calls
+ *
+ */
+enum
+{
+ NAMELEN = 28,
+ ERRLEN = 64,
+ ERRMAX = 128,
+ DIRLEN = 116
+};
+
+#define CHDIR 0x80000000 /* mode bit for directories */
+#define CHAPPEND 0x40000000 /* mode bit for append only files */
+#define CHEXCL 0x20000000 /* mode bit for exclusive use files */
+#define CHMOUNT 0x10000000 /* mode bit for mounted channel */
+#define CHREAD 0x4 /* mode bit for read permission */
+#define CHWRITE 0x2 /* mode bit for write permission */
+#define CHEXEC 0x1 /* mode bit for execute permission */
+
+#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 0x0007 /* 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) */
+
+typedef
+struct Qid
+{
+ ulong path;
+ ulong vers;
+} Qid;
+
+typedef
+struct Dir
+{
+ char name[NAMELEN];
+ char uid[NAMELEN];
+ char gid[NAMELEN];
+ Qid qid;
+ ulong mode;
+ int atime;
+ int mtime;
+ vlong length;
+ ushort type;
+ ushort dev;
+} Dir;
+
+extern int dirfstat(int, Dir*);
+extern int dirstat(char*, Dir*);
+extern int dirfwstat(int, Dir*);
+extern int dirwstat(char*, Dir*);
+
+extern char* cleanname(char*);
+extern void exits(char*);
+extern void _exits(char*);
+extern int create(char*, int, int);
+
+extern char* getuser(void);
+extern char* getwd(char*, int);
+
+extern int errstr(char*, uint);
+extern void werrstr(char*, ...);
+
+#define ARGBEGIN for(argv++,argc--;\
+ argv[0] && argv[0][0]=='-' && argv[0][1];\
+ argc--, argv++) {\
+ char *_args, *_argt;\
+ char _argc;\
+ _args = &argv[0][1];\
+ if(_args[0]=='-' && _args[1]==0){\
+ argc--; argv++; break;\
+ }\
+ _argc = 0;\
+ while((_argc = *_args++)!='\0')\
+ switch(_argc)
+#define ARGEND }
+#define ARGF() (_argt=_args, _args="",\
+ (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
+#define ARGC() _argc
+
+/*
+ * Extensions for Inferno to basic libc.h
+ */
+
+#define setbinmode()
+
binary files /dev/null b/Solaris/sparc/bin/data2c differ
binary files /dev/null b/Solaris/sparc/bin/iyacc differ
binary files /dev/null b/Solaris/sparc/bin/mk differ
binary files /dev/null b/Solaris/sparc/bin/mkext differ
--- /dev/null
+++ b/Solaris/sparc/include/emu.h
@@ -1,0 +1,21 @@
+/*
+ * system- and machine-specific declarations for emu:
+ * floating-point save and restore, signal handling primitive, and
+ * implementation of the current-process variable `up'.
+ */
+
+extern Proc* getup(void);
+#define up (getup())
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+typedef struct FPU FPU;
+struct FPU
+{
+ ulong fsr;
+};
+
+typedef sigjmp_buf osjmpbuf;
+#define ossetjmp(buf) sigsetjmp(buf, 1)
+
--- /dev/null
+++ b/Solaris/sparc/include/fpuctl.h
@@ -1,0 +1,75 @@
+/* This code is a little awkward. If somebody who understands Solaris
+ better would tell me an idiomatic way to invoke equivalent
+ behavior, I'd be grateful. ehg@bell-labs.com */
+
+/*
+ * accrued exception bits in the fsr
+ */
+#define FPAINEX (1<<5)
+#define FPAOVFL (1<<8)
+#define FPAUNFL (1<<7)
+#define FPAZDIV (1<<6)
+#define FPAINVAL (1<<9)
+
+/*
+ * exception enable bits in the fsr
+ */
+#define FPINEX (1<<23)
+#define FPOVFL (1<<26)
+#define FPUNFL (1<<25)
+#define FPZDIV (1<<24)
+#define FPINVAL (1<<27)
+
+/*
+ * rounding
+ */
+#define FPRMASK (3<<30)
+#define FPRNR (0<<30)
+#define FPRNINF (3<<30)
+#define FPRPINF (2<<30)
+#define FPRZ (1<<30)
+
+/*
+ * precision
+ */
+#define FPPDBL 0
+
+#define FPFCR (FPRMASK|FPINEX|FPOVFL|FPUNFL|FPZDIV|FPINVAL)
+#define FPFSR (FPAINEX|FPAOVFL|FPAUNFL|FPAZDIV|FPAINVAL)
+
+static ulong
+getfcr(void)
+{
+ ulong v;
+
+ asm(" st %fsr, [%fp-8]");
+ return v;
+}
+
+static void
+setfcr(ulong v)
+{
+ ulong vv;
+
+ vv = (getfcr() & ~FPFCR) | (v & FPFCR);
+ asm(" ld [%fp-4], %fsr");
+}
+
+static ulong
+getfsr(void)
+{
+ ulong v;
+
+ asm(" st %fsr, [%fp-8]");
+ return v;
+}
+
+static void
+setfsr(ulong v)
+{
+ ulong vv;
+
+ vv = (getfsr() & ~FPFSR) | (v & FPFSR);
+ asm(" ld [%fp-4], %fsr");
+}
+
--- /dev/null
+++ b/Solaris/sparc/include/lib9.h
@@ -1,0 +1,470 @@
+#define _POSIX_SOURCE
+#define _POSIX_C_SOURCE 1
+#define _LARGEFILE64_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+#include <sys/types.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#define __EXTENSIONS__
+#include <unistd.h>
+#undef __EXTENSIONS__
+#include <errno.h>
+#include <string.h>
+#include "math.h"
+#include <fcntl.h>
+#include <setjmp.h>
+#include <float.h>
+#include <time.h>
+
+#define getwd infgetwd
+
+#ifndef EMU
+typedef struct Proc Proc;
+#endif
+
+#define nil ((void*)0)
+
+typedef unsigned char uchar;
+typedef unsigned int uint;
+typedef unsigned long ulong;
+typedef signed char schar;
+typedef unsigned short ushort;
+typedef unsigned int Rune;
+typedef long long int vlong;
+typedef unsigned long long int uvlong;
+typedef unsigned int u32int;
+typedef uvlong u64int;
+
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned short u16int;
+typedef unsigned char u8int;
+typedef unsigned long 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;
+
+#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);
+
+/*
+ * random number
+ */
+extern ulong truerand(void);
+extern ulong ntruerand(ulong);
+
+/*
+ * math
+ */
+extern int isNaN(double);
+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 uintptr 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()
+