summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Ushakov <uwe@stderr.spb.ru>2019-03-10 03:44:16 +0200
committerValery Ushakov <uwe@stderr.spb.ru>2019-03-10 03:44:16 +0200
commit594bd56378a3a707845dd8813881c427a3a8d16e (patch)
tree5f18116b77d615f40c50d449a332dafd21347c05
parent9b7850d511c2c910abfb42ece20650b97fba5a72 (diff)
parent55520626f59983d296c98c008af92f7c5c27bf5f (diff)
Merged default into NetBSD/pthreads
-rw-r--r--.hgignore9
-rwxr-xr-xAIX/power/bin/data2cbin0 -> 79583 bytes
-rwxr-xr-xAIX/power/bin/iyaccbin0 -> 198151 bytes
-rwxr-xr-xAIX/power/bin/mkbin0 -> 337445 bytes
-rwxr-xr-xAIX/power/bin/ndatebin0 -> 59026 bytes
-rw-r--r--AIX/power/include/ar.h30
-rw-r--r--AIX/power/include/emu.h25
-rw-r--r--AIX/power/include/lib9.h509
-rw-r--r--NetBSD/386/include/lib9.h1
-rw-r--r--NetBSD/power/include/emu.h22
-rw-r--r--NetBSD/power/include/lib9.h527
-rw-r--r--OpenBSD/386/include/emu.h4
-rw-r--r--OpenBSD/386/include/lib9.h31
-rw-r--r--README.md6
-rw-r--r--appl/acme/ecmd.b4
-rw-r--r--appl/cmd/limbo/limbo.y4
-rw-r--r--appl/cmd/limbo/types.b2
-rw-r--r--appl/cmd/m4.b75
-rw-r--r--appl/math/mersenne.b8
-rw-r--r--appl/math/parts.b8
-rw-r--r--dis/limbo.disbin343678 -> 343687 bytes
-rw-r--r--dis/m4.disbin12287 -> 12809 bytes
-rw-r--r--dis/math/mersenne.disbin1144 -> 1143 bytes
-rw-r--r--dis/math/parts.disbin1539 -> 1538 bytes
-rw-r--r--doc/port.ms2
-rw-r--r--emu/AIX/asm-power.s108
-rw-r--r--emu/AIX/cmd.c213
-rw-r--r--emu/AIX/deveia.c40
-rw-r--r--emu/AIX/devfs.c7
-rw-r--r--emu/AIX/emu104
-rw-r--r--emu/AIX/emu-g100
-rw-r--r--emu/AIX/mkfile52
-rw-r--r--emu/AIX/mkfile-power0
-rw-r--r--emu/AIX/os.c300
-rw-r--r--emu/AIX/segflush-power.c33
-rw-r--r--emu/NetBSD/asm-power.S91
-rw-r--r--emu/NetBSD/emu3
-rw-r--r--emu/NetBSD/emu-g4
-rw-r--r--emu/NetBSD/emu.c88
-rw-r--r--emu/NetBSD/mkfile7
-rw-r--r--emu/NetBSD/os.c8
-rw-r--r--emu/NetBSD/segflush-386.c9
-rw-r--r--emu/NetBSD/segflush-power.c12
-rw-r--r--emu/OpenBSD/asm-386.S2
-rw-r--r--emu/OpenBSD/mkfile3
-rw-r--r--emu/OpenBSD/os.c224
-rw-r--r--emu/OpenBSD/rfork_thread.S104
-rw-r--r--emu/port/devfs-posix.c2
-rw-r--r--emu/port/win-x11a.c40
-rw-r--r--lib/emptydirs1
-rw-r--r--lib9/getcallerpc-AIX-power.c12
-rw-r--r--lib9/getcallerpc-NetBSD-386.S7
-rw-r--r--lib9/getcallerpc-NetBSD-power.S6
-rw-r--r--lib9/setfcr-AIX-power.c39
-rw-r--r--lib9/setfcr-Linux-power.S4
-rw-r--r--lib9/setfcr-NetBSD-386.S15
-rw-r--r--lib9/setfcr-NetBSD-power.S33
-rw-r--r--lib9/setfcr-OpenBSD-386.S34
-rw-r--r--libinterp/comp-power.c45
-rw-r--r--libmath/FPcontrol-AIX.c77
-rw-r--r--libmemdraw/mkfile-AIX1
-rw-r--r--libmemlayer/mkfile-AIX4
-rw-r--r--limbo/lex.c2
-rw-r--r--limbo/limbo.y4
-rw-r--r--limbo/types.c4
-rw-r--r--makemk-AIX.sh78
-rw-r--r--man/1/m419
-rw-r--r--mkconfig4
-rw-r--r--mkfiles/mkfile-AIX-power25
-rw-r--r--mkfiles/mkfile-NetBSD-3861
-rw-r--r--mkfiles/mkfile-NetBSD-power30
-rw-r--r--mkfiles/mkhost-AIX14
-rw-r--r--module/draw.m2
-rw-r--r--services/webget/smallinferno.gifbin0 -> 1787 bytes
-rw-r--r--utils/8l/l.h12
-rw-r--r--utils/mk/archive-AIX.c203
-rw-r--r--utils/mk/mkfile4
77 files changed, 3009 insertions, 492 deletions
diff --git a/.hgignore b/.hgignore
index b933c7d9..bdd6041c 100644
--- a/.hgignore
+++ b/.hgignore
@@ -61,5 +61,14 @@ syntax: regexp
^usr/\.*
^grid/.*
^libinterp/cryptmod.h
+^libinterp/drawmod.h
+^libinterp/freetypemod.h
^libinterp/ipintsmod.h
+^libinterp/keyring.h
^libinterp/keyringif.h
+^libinterp/loadermod.h
+^libinterp/mathmod.h
+^libinterp/runt.h
+^libinterp/sysmod.h
+^libinterp/tkmod.h
+^limbo/runt.h
diff --git a/AIX/power/bin/data2c b/AIX/power/bin/data2c
new file mode 100755
index 00000000..9cdacae0
--- /dev/null
+++ b/AIX/power/bin/data2c
Binary files differ
diff --git a/AIX/power/bin/iyacc b/AIX/power/bin/iyacc
new file mode 100755
index 00000000..c97da6a7
--- /dev/null
+++ b/AIX/power/bin/iyacc
Binary files differ
diff --git a/AIX/power/bin/mk b/AIX/power/bin/mk
new file mode 100755
index 00000000..14d47859
--- /dev/null
+++ b/AIX/power/bin/mk
Binary files differ
diff --git a/AIX/power/bin/ndate b/AIX/power/bin/ndate
new file mode 100755
index 00000000..f5293367
--- /dev/null
+++ b/AIX/power/bin/ndate
Binary files differ
diff --git a/AIX/power/include/ar.h b/AIX/power/include/ar.h
new file mode 100644
index 00000000..f8473172
--- /dev/null
+++ b/AIX/power/include/ar.h
@@ -0,0 +1,30 @@
+#define ARMAG "<bigaf>\n"
+#define SARMAG 8
+
+#define ARFMAG "`\n"
+
+struct fl_hdr /* archive fixed length header - printable ascii */
+{
+ char magic[SARMAG]; /* Archive file magic string */
+ char memoff[20]; /* Offset to member table */
+ char gstoff[20]; /* Offset to 32-bit global sym table */
+ char gst64off[20]; /* Offset to 64-bit global sym table */
+ char fstmoff[20]; /* Offset to first archive member */
+ char lstmoff[20]; /* Offset to last archive member */
+ char freeoff[20]; /* Offset to first mem on free list */
+};
+#define SAR_FLHDR (SARMAG+120)
+
+struct ar_hdr /* archive file member header - printable ascii */
+{
+ char size[20]; /* file member size - decimal */
+ char nxtmem[20]; /* pointer to next member - decimal */
+ char prvmem[20]; /* pointer to previous member - decimal */
+ char date[12]; /* file member date - decimal */
+ char uid[12]; /* file member user id - decimal */
+ char gid[12]; /* file member group id - decimal */
+ char mode[12]; /* file member mode - octal */
+ char namlen[4]; /* file member name length - decimal */
+ /* and variable length name follows*/
+};
+#define SAR_HDR 112
diff --git a/AIX/power/include/emu.h b/AIX/power/include/emu.h
new file mode 100644
index 00000000..94053840
--- /dev/null
+++ b/AIX/power/include/emu.h
@@ -0,0 +1,25 @@
+/*
+ * system- and machine-specific declarations for emu:
+ * floating-point save and restore, signal handling primitive, and
+ * implementation of the current-process variable `up'.
+ */
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+typedef struct FPU FPU;
+struct FPU
+{
+ uchar env[18*8];
+};
+
+#define KSTACK (32 * 1024)
+
+extern Proc* getup(void);
+
+#define up (getup())
+
+typedef sigjmp_buf osjmpbuf;
+#define ossetjmp(buf) sigsetjmp(buf, 1)
+
+#define pthread_yield sched_yield
diff --git a/AIX/power/include/lib9.h b/AIX/power/include/lib9.h
new file mode 100644
index 00000000..b4f1a11a
--- /dev/null
+++ b/AIX/power/include/lib9.h
@@ -0,0 +1,509 @@
+#define _DEFAULT_SOURCE
+#define _BSD_SOURCE
+#define _LINUX_SOURCE_COMPAT
+#define _XOPEN_SOURCE 500
+#define _LARGEFILE_SOURCE 1
+#define _LARGEFILE64_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#define sync __os_sync
+#include <unistd.h>
+#undef sync
+#include <errno.h>
+#define __NO_STRING_INLINES
+#include <string.h>
+#include "math.h"
+#include <fcntl.h>
+#include <setjmp.h>
+#include <float.h>
+
+#define getwd infgetwd
+
+#ifndef EMU
+typedef struct Proc Proc;
+#endif
+
+#undef __LITTLE_ENDIAN
+
+#define nil ((void*)0)
+
+typedef unsigned char uchar;
+typedef signed char schar;
+typedef unsigned int Rune;
+typedef long long int vlong;
+typedef unsigned long long int uvlong;
+typedef unsigned int u32int;
+typedef uvlong u64int;
+typedef unsigned long ulong;
+typedef unsigned short ushort;
+typedef unsigned int uint;
+
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned short u16int;
+typedef unsigned char u8int;
+typedef unsigned long uintptr;
+
+#define USED(x) if(x){}else{}
+#define SET(x)
+
+#undef nelem
+#define nelem(x) (sizeof(x)/sizeof((x)[0]))
+#undef offsetof
+#define offsetof(s, m) (ulong)(&(((s*)0)->m))
+#undef assert
+#define assert(x) if(x){}else _assert("x")
+
+/*
+ * most mem and string routines are declared by ANSI/POSIX files above
+ */
+
+extern char* strecpy(char*, char*, char*);
+extern char* strdup(const char*);
+extern int cistrncmp(char*, char*, int);
+extern int cistrcmp(char*, char*);
+extern char* cistrstr(char*, char*);
+extern int tokenize(char*, char**, int);
+
+enum
+{
+ UTFmax = 4, /* maximum bytes per rune */
+ Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
+ Runeself = 0x80, /* rune and UTF sequences are the same (<) */
+ Runeerror = 0xFFFD, /* decoding error in UTF */
+ Runemax = 0x10FFFF, /* 21-bit rune */
+ Runemask = 0x1FFFFF, /* bits used by runes (see grep) */
+};
+
+/*
+ * rune routines
+ */
+extern int runetochar(char*, Rune*);
+extern int chartorune(Rune*, char*);
+extern int runelen(long);
+extern int runenlen(Rune*, int);
+extern int fullrune(char*, int);
+extern int utflen(char*);
+extern int utfnlen(char*, long);
+extern char* utfrune(char*, long);
+extern char* utfrrune(char*, long);
+extern char* utfutf(char*, char*);
+extern char* utfecpy(char*, char*, char*);
+
+extern Rune* runestrcat(Rune*, Rune*);
+extern Rune* runestrchr(Rune*, Rune);
+extern int runestrcmp(Rune*, Rune*);
+extern Rune* runestrcpy(Rune*, Rune*);
+extern Rune* runestrncpy(Rune*, Rune*, long);
+extern Rune* runestrecpy(Rune*, Rune*, Rune*);
+extern Rune* runestrdup(Rune*);
+extern Rune* runestrncat(Rune*, Rune*, long);
+extern int runestrncmp(Rune*, Rune*, long);
+extern Rune* runestrrchr(Rune*, Rune);
+extern long runestrlen(Rune*);
+extern Rune* runestrstr(Rune*, Rune*);
+
+extern Rune tolowerrune(Rune);
+extern Rune totitlerune(Rune);
+extern Rune toupperrune(Rune);
+extern int isalpharune(Rune);
+extern int islowerrune(Rune);
+extern int isspacerune(Rune);
+extern int istitlerune(Rune);
+extern int isupperrune(Rune);
+
+/*
+ * malloc
+ */
+extern void* malloc(size_t);
+extern void* mallocz(ulong, int);
+extern void free(void*);
+extern ulong msize(void*);
+extern void* calloc(size_t, size_t);
+extern void* realloc(void*, size_t);
+extern void setmalloctag(void*, ulong);
+extern void setrealloctag(void*, ulong);
+extern ulong getmalloctag(void*);
+extern ulong getrealloctag(void*);
+extern void* malloctopoolblock(void*);
+
+/*
+ * print routines
+ */
+typedef struct Fmt Fmt;
+struct Fmt{
+ uchar runes; /* output buffer is runes or chars? */
+ void *start; /* of buffer */
+ void *to; /* current place in the buffer */
+ void *stop; /* end of the buffer; overwritten if flush fails */
+ int (*flush)(Fmt *); /* called when to == stop */
+ void *farg; /* to make flush a closure */
+ int nfmt; /* num chars formatted so far */
+ va_list args; /* args passed to dofmt */
+ int r; /* % format Rune */
+ int width;
+ int prec;
+ ulong flags;
+};
+
+enum{
+ FmtWidth = 1,
+ FmtLeft = FmtWidth << 1,
+ FmtPrec = FmtLeft << 1,
+ FmtSharp = FmtPrec << 1,
+ FmtSpace = FmtSharp << 1,
+ FmtSign = FmtSpace << 1,
+ FmtZero = FmtSign << 1,
+ FmtUnsigned = FmtZero << 1,
+ FmtShort = FmtUnsigned << 1,
+ FmtLong = FmtShort << 1,
+ FmtVLong = FmtLong << 1,
+ FmtComma = FmtVLong << 1,
+ FmtByte = FmtComma << 1,
+
+ FmtFlag = FmtByte << 1
+};
+
+extern int print(char*, ...);
+extern char* seprint(char*, char*, char*, ...);
+extern char* vseprint(char*, char*, char*, va_list);
+extern int snprint(char*, int, char*, ...);
+extern int vsnprint(char*, int, char*, va_list);
+extern char* smprint(char*, ...);
+extern char* vsmprint(char*, va_list);
+extern int sprint(char*, char*, ...);
+extern int fprint(int, char*, ...);
+extern int vfprint(int, char*, va_list);
+
+extern int runesprint(Rune*, char*, ...);
+extern int runesnprint(Rune*, int, char*, ...);
+extern int runevsnprint(Rune*, int, char*, va_list);
+extern Rune* runeseprint(Rune*, Rune*, char*, ...);
+extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
+extern Rune* runesmprint(char*, ...);
+extern Rune* runevsmprint(char*, va_list);
+
+extern int fmtfdinit(Fmt*, int, char*, int);
+extern int fmtfdflush(Fmt*);
+extern int fmtstrinit(Fmt*);
+extern char* fmtstrflush(Fmt*);
+extern int runefmtstrinit(Fmt*);
+extern Rune* runefmtstrflush(Fmt*);
+
+extern int fmtinstall(int, int (*)(Fmt*));
+extern int dofmt(Fmt*, char*);
+extern int dorfmt(Fmt*, Rune*);
+extern int fmtprint(Fmt*, char*, ...);
+extern int fmtvprint(Fmt*, char*, va_list);
+extern int fmtrune(Fmt*, int);
+extern int fmtstrcpy(Fmt*, char*);
+extern int fmtrunestrcpy(Fmt*, Rune*);
+/*
+ * error string for %r
+ * supplied on per os basis, not part of fmt library
+ */
+extern int errfmt(Fmt *f);
+
+/*
+ * quoted strings
+ */
+extern char *unquotestrdup(char*);
+extern Rune *unquoterunestrdup(Rune*);
+extern char *quotestrdup(char*);
+extern Rune *quoterunestrdup(Rune*);
+extern int quotestrfmt(Fmt*);
+extern int quoterunestrfmt(Fmt*);
+extern void quotefmtinstall(void);
+extern int (*doquote)(int);
+
+/*
+ * random number
+ */
+extern ulong truerand(void);
+extern ulong ntruerand(ulong);
+
+/*
+ * math
+ */
+extern int isNaN(double);
+extern double NaN(void);
+extern int isInf(double, int);
+
+/*
+ * Time-of-day
+ */
+
+typedef struct Tm Tm;
+struct Tm {
+ int sec;
+ int min;
+ int hour;
+ int mday;
+ int mon;
+ int year;
+ int wday;
+ int yday;
+ char zone[4];
+ int tzoff;
+};
+extern vlong osnsec(void);
+#define nsec osnsec
+
+/*
+ * one-of-a-kind
+ */
+extern void _assert(char*);
+extern double charstod(int(*)(void*), void*);
+extern char* cleanname(char*);
+extern uintptr getcallerpc(void*);
+extern int getfields(char*, char**, int, int, char*);
+extern char* getuser(void);
+extern char* getwd(char*, int);
+extern double ipow10(int);
+#define pow10 infpow10
+extern double pow10(int);
+extern vlong strtoll(const char*, char**, int);
+#define qsort infqsort
+extern void qsort(void*, long, long, int (*)(void*, void*));
+extern uvlong strtoull(const char*, char**, int);
+extern void sysfatal(char*, ...);
+extern int dec64(uchar*, int, char*, int);
+extern int enc64(char*, int, uchar*, int);
+extern int dec32(uchar*, int, char*, int);
+extern int enc32(char*, int, uchar*, int);
+extern int dec16(uchar*, int, char*, int);
+extern int enc16(char*, int, uchar*, int);
+extern int encodefmt(Fmt*);
+
+/*
+ * synchronization
+ */
+typedef
+struct Lock {
+ int val;
+ int pid;
+} Lock;
+
+extern int _tas(int*);
+
+extern void lock(Lock*);
+extern void unlock(Lock*);
+extern int canlock(Lock*);
+
+typedef struct QLock QLock;
+struct QLock
+{
+ Lock use; /* to access Qlock structure */
+ Proc *head; /* next process waiting for object */
+ Proc *tail; /* last process waiting for object */
+ int locked; /* flag */
+};
+
+extern void qlock(QLock*);
+extern void qunlock(QLock*);
+extern int canqlock(QLock*);
+extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
+
+typedef
+struct RWLock
+{
+ Lock l; /* Lock modify lock */
+ QLock x; /* Mutual exclusion lock */
+ QLock k; /* Lock for waiting writers */
+ int readers; /* Count of readers in lock */
+} RWLock;
+
+extern int canrlock(RWLock*);
+extern int canwlock(RWLock*);
+extern void rlock(RWLock*);
+extern void runlock(RWLock*);
+extern void wlock(RWLock*);
+extern void wunlock(RWLock*);
+
+/*
+ * network dialing
+ */
+#define NETPATHLEN 40
+
+/*
+ * system calls
+ *
+ */
+#define STATMAX 65535U /* max length of machine-independent stat structure */
+#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
+#define ERRMAX 128 /* max length of error string */
+
+#define MORDER 0x0003 /* mask for bits defining order of mounting */
+#define MREPL 0x0000 /* mount replaces object */
+#define MBEFORE 0x0001 /* mount goes before others in union directory */
+#define MAFTER 0x0002 /* mount goes after others in union directory */
+#define MCREATE 0x0004 /* permit creation in mounted directory */
+#define MCACHE 0x0010 /* cache some data */
+#define MMASK 0x0017 /* all bits on */
+
+#define OREAD 0 /* open for read */
+#define OWRITE 1 /* write */
+#define ORDWR 2 /* read and write */
+#define OEXEC 3 /* execute, == read but check execute permission */
+#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
+#define OCEXEC 32 /* or'ed in, close on exec */
+#define ORCLOSE 64 /* or'ed in, remove on close */
+#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
+
+#define AEXIST 0 /* accessible: exists */
+#define AEXEC 1 /* execute access */
+#define AWRITE 2 /* write access */
+#define AREAD 4 /* read access */
+
+/* bits in Qid.type */
+#define QTDIR 0x80 /* type bit for directories */
+#define QTAPPEND 0x40 /* type bit for append only files */
+#define QTEXCL 0x20 /* type bit for exclusive use files */
+#define QTMOUNT 0x10 /* type bit for mounted channel */
+#define QTAUTH 0x08 /* type bit for authentication file */
+#define QTFILE 0x00 /* plain file */
+
+/* bits in Dir.mode */
+#define DMDIR 0x80000000 /* mode bit for directories */
+#define DMAPPEND 0x40000000 /* mode bit for append only files */
+#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
+#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
+#define DMAUTH 0x08000000 /* mode bit for authentication file */
+#define DMREAD 0x4 /* mode bit for read permission */
+#define DMWRITE 0x2 /* mode bit for write permission */
+#define DMEXEC 0x1 /* mode bit for execute permission */
+
+typedef
+struct Qid
+{
+ uvlong path;
+ ulong vers;
+ uchar type;
+} Qid;
+
+typedef
+struct Dir {
+ /* system-modified data */
+ ushort type; /* server type */
+ uint dev; /* server subtype */
+ /* file data */
+ Qid qid; /* unique id from server */
+ ulong mode; /* permissions */
+ ulong atime; /* last read time */
+ ulong mtime; /* last write time */
+ vlong length; /* file length */
+ char *name; /* last element of path */
+ char *uid; /* owner name */
+ char *gid; /* group name */
+ char *muid; /* last modifier name */
+} Dir;
+
+extern Dir* dirstat(char*);
+extern Dir* dirfstat(int);
+extern int dirwstat(char*, Dir*);
+extern int dirfwstat(int, Dir*);
+extern long dirread(int, Dir**);
+extern void nulldir(Dir*);
+extern long dirreadall(int, Dir**);
+
+typedef
+struct Waitmsg
+{
+ int pid; /* of loved one */
+ ulong time[3]; /* of loved one & descendants */
+ char *msg;
+} Waitmsg;
+
+extern void _exits(char*);
+
+extern void exits(char*);
+extern int create(char*, int, int);
+extern int errstr(char*, uint);
+
+extern void perror(const char*);
+extern long readn(int, void*, long);
+extern int remove(const char*);
+extern void rerrstr(char*, uint);
+extern vlong seek(int, vlong, int);
+extern int segflush(void*, ulong);
+extern void werrstr(char*, ...);
+
+extern char *argv0;
+#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
+ argv[0] && argv[0][0]=='-' && argv[0][1];\
+ argc--, argv++) {\
+ char *_args, *_argt;\
+ Rune _argc;\
+ _args = &argv[0][1];\
+ if(_args[0]=='-' && _args[1]==0){\
+ argc--; argv++; break;\
+ }\
+ _argc = 0;\
+ while(*_args && (_args += chartorune(&_argc, _args)))\
+ switch(_argc)
+#define ARGEND SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
+#define ARGF() (_argt=_args, _args="",\
+ (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
+#define EARGF(x) (_argt=_args, _args="",\
+ (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
+
+#define ARGC() _argc
+
+/*
+ * Extensions for Inferno to basic libc.h
+ */
+
+#define setbinmode()
+
+extern void setfcr(ulong);
+extern void setfsr(ulong);
+extern ulong getfcr(void);
+extern ulong getfsr(void);
+
+
+/* FPSCR */
+#define FPSFX (1<<31) /* exception summary (sticky) */
+#define FPSEX (1<<30) /* enabled exception summary */
+#define FPSVX (1<<29) /* invalid operation exception summary */
+#define FPSOX (1<<28) /* overflow exception OX (sticky) */
+#define FPSUX (1<<27) /* underflow exception UX (sticky) */
+#define FPSZX (1<<26) /* zero divide exception ZX (sticky) */
+#define FPSXX (1<<25) /* inexact exception XX (sticky) */
+#define FPSVXSNAN (1<<24) /* invalid operation exception for SNaN (sticky) */
+#define FPSVXISI (1<<23) /* invalid operation exception for ∞-∞ (sticky) */
+#define FPSVXIDI (1<<22) /* invalid operation exception for ∞/∞ (sticky) */
+#define FPSVXZDZ (1<<21) /* invalid operation exception for 0/0 (sticky) */
+#define FPSVXIMZ (1<<20) /* invalid operation exception for ∞*0 (sticky) */
+#define FPSVXVC (1<<19) /* invalid operation exception for invalid compare (sticky) */
+#define FPSFR (1<<18) /* fraction rounded */
+#define FPSFI (1<<17) /* fraction inexact */
+#define FPSFPRF (1<<16) /* floating point result class */
+#define FPSFPCC (0xF<<12) /* <, >, =, unordered */
+#define FPVXCVI (1<<8) /* enable exception for invalid integer convert (sticky) */
+
+/* FCR */
+#define FPVE (1<<7) /* invalid operation exception enable */
+#define FPOVFL (1<<6) /* enable overflow exceptions */
+#define FPUNFL (1<<5) /* enable underflow */
+#define FPZDIV (1<<4) /* enable zero divide */
+#define FPINEX (1<<3) /* enable inexact exceptions */
+#define FPRMASK (3<<0) /* rounding mode */
+#define FPRNR (0<<0)
+#define FPRZ (1<<0)
+#define FPRPINF (2<<0)
+#define FPRNINF (3<<0)
+#define FPPEXT 0
+#define FPPSGL 0
+#define FPPDBL 0
+#define FPPMASK 0
+#define FPINVAL FPVE
+/* FSR */
+#define FPAOVFL FPSOX
+#define FPAINEX FPSXX
+#define FPAUNFL FPSUX
+#define FPAZDIV FPSZX
+#define FPAINVAL FPSVX
+
diff --git a/NetBSD/386/include/lib9.h b/NetBSD/386/include/lib9.h
index c8eb499a..4e1658ac 100644
--- a/NetBSD/386/include/lib9.h
+++ b/NetBSD/386/include/lib9.h
@@ -244,6 +244,7 @@ extern ulong ntruerand(ulong);
* math
*/
extern int isNaN(double);
+extern double NaN(void);
extern int isInf(double, int);
extern double pow(double, double);
diff --git a/NetBSD/power/include/emu.h b/NetBSD/power/include/emu.h
new file mode 100644
index 00000000..7d160b26
--- /dev/null
+++ b/NetBSD/power/include/emu.h
@@ -0,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'.
+ */
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+typedef struct FPU FPU;
+struct FPU
+{
+ uchar env[18*8];
+};
+
+#define KSTACK (32 * 1024)
+
+extern Proc* getup(void);
+#define up (getup())
+
+typedef sigjmp_buf osjmpbuf;
+#define ossetjmp(buf) sigsetjmp(buf, 1)
diff --git a/NetBSD/power/include/lib9.h b/NetBSD/power/include/lib9.h
new file mode 100644
index 00000000..d5ea7a1d
--- /dev/null
+++ b/NetBSD/power/include/lib9.h
@@ -0,0 +1,527 @@
+#include <sys/types.h>
+#include <sys/endian.h>
+#include <sys/stat.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
+#include <math.h>
+#include <fcntl.h>
+#include <setjmp.h>
+#include <float.h>
+#include <time.h>
+
+#define getwd infgetwd
+
+#define round infround
+#define fmax inffmax
+#define log2 inflog2
+
+#ifndef EMU
+typedef struct Proc Proc;
+#endif
+
+/*
+ * math module dtoa
+ */
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+#define __LITTLE_ENDIAN
+#endif
+
+#define nil ((void*)0)
+
+typedef unsigned char uchar;
+typedef signed char schar;
+#if 0 /* XXX: uwe: already defined in <sys/types.h> */
+typedef unsigned long ulong;
+#endif
+
+typedef int64_t vlong;
+typedef uint64_t uvlong;
+
+typedef uint8_t u8int;
+typedef uint16_t u16int;
+typedef uint32_t u32int;
+typedef uvlong u64int;
+
+typedef uintptr_t uintptr;
+
+typedef signed char int8;
+typedef unsigned char uint8;
+typedef short int16;
+typedef unsigned short uint16;
+typedef int int32;
+typedef unsigned int uint32;
+typedef long long int64;
+typedef unsigned long long uint64;
+
+typedef unsigned int Rune;
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+
+
+#define USED(x) if(x){}else{}
+#define SET(x)
+
+#undef nelem
+#define nelem(x) (sizeof(x)/sizeof((x)[0]))
+#undef offsetof
+#define offsetof(s, m) (ulong)(&(((s*)0)->m))
+#undef assert
+#define assert(x) if(x){}else _assert(#x)
+
+/*
+ * most mem and string routines are declared by ANSI/POSIX files above
+ */
+
+extern char* strecpy(char*, char*, char*);
+extern char* strdup(const char*);
+extern int cistrncmp(char*, char*, int);
+extern int cistrcmp(char*, char*);
+extern char* cistrstr(char*, char*);
+extern int tokenize(char*, char**, int);
+
+enum
+{
+ UTFmax = 4, /* maximum bytes per rune */
+ Runesync = 0x80, /* cannot represent part of a UTF sequence (<) */
+ Runeself = 0x80, /* rune and UTF sequences are the same (<) */
+ Runeerror = 0xFFFD, /* decoding error in UTF */
+ Runemax = 0x10FFFF, /* 21-bit rune */
+ Runemask = 0x1FFFFF, /* bits used by runes (see grep) */
+};
+
+/*
+ * rune routines
+ */
+extern int runetochar(char*, Rune*);
+extern int chartorune(Rune*, char*);
+extern int runelen(long);
+extern int runenlen(Rune*, int);
+extern int fullrune(char*, int);
+extern int utflen(char*);
+extern int utfnlen(char*, long);
+extern char* utfrune(char*, long);
+extern char* utfrrune(char*, long);
+extern char* utfutf(char*, char*);
+extern char* utfecpy(char*, char*, char*);
+
+extern Rune* runestrcat(Rune*, Rune*);
+extern Rune* runestrchr(Rune*, Rune);
+extern int runestrcmp(Rune*, Rune*);
+extern Rune* runestrcpy(Rune*, Rune*);
+extern Rune* runestrncpy(Rune*, Rune*, long);
+extern Rune* runestrecpy(Rune*, Rune*, Rune*);
+extern Rune* runestrdup(Rune*);
+extern Rune* runestrncat(Rune*, Rune*, long);
+extern int runestrncmp(Rune*, Rune*, long);
+extern Rune* runestrrchr(Rune*, Rune);
+extern long runestrlen(Rune*);
+extern Rune* runestrstr(Rune*, Rune*);
+
+extern Rune tolowerrune(Rune);
+extern Rune totitlerune(Rune);
+extern Rune toupperrune(Rune);
+extern int isalpharune(Rune);
+extern int islowerrune(Rune);
+extern int isspacerune(Rune);
+extern int istitlerune(Rune);
+extern int isupperrune(Rune);
+
+/*
+ * malloc
+ */
+extern void* malloc(size_t);
+extern void* mallocz(ulong, int);
+extern void free(void*);
+extern ulong msize(void*);
+extern void* calloc(size_t, size_t);
+extern void* realloc(void*, size_t);
+extern void setmalloctag(void*, ulong);
+extern void setrealloctag(void*, ulong);
+extern ulong getmalloctag(void*);
+extern ulong getrealloctag(void*);
+extern void* malloctopoolblock(void*);
+
+/*
+ * print routines
+ */
+typedef struct Fmt Fmt;
+struct Fmt{
+ uchar runes; /* output buffer is runes or chars? */
+ void *start; /* of buffer */
+ void *to; /* current place in the buffer */
+ void *stop; /* end of the buffer; overwritten if flush fails */
+ int (*flush)(Fmt *); /* called when to == stop */
+ void *farg; /* to make flush a closure */
+ int nfmt; /* num chars formatted so far */
+ va_list args; /* args passed to dofmt */
+ int r; /* % format Rune */
+ int width;
+ int prec;
+ ulong flags;
+};
+
+enum{
+ FmtWidth = 1,
+ FmtLeft = FmtWidth << 1,
+ FmtPrec = FmtLeft << 1,
+ FmtSharp = FmtPrec << 1,
+ FmtSpace = FmtSharp << 1,
+ FmtSign = FmtSpace << 1,
+ FmtZero = FmtSign << 1,
+ FmtUnsigned = FmtZero << 1,
+ FmtShort = FmtUnsigned << 1,
+ FmtLong = FmtShort << 1,
+ FmtVLong = FmtLong << 1,
+ FmtComma = FmtVLong << 1,
+ FmtByte = FmtComma << 1,
+
+ FmtFlag = FmtByte << 1
+};
+
+extern int print(char*, ...);
+extern char* seprint(char*, char*, char*, ...);
+extern char* vseprint(char*, char*, char*, va_list);
+extern int snprint(char*, int, char*, ...);
+extern int vsnprint(char*, int, char*, va_list);
+extern char* smprint(char*, ...);
+extern char* vsmprint(char*, va_list);
+extern int sprint(char*, char*, ...);
+extern int fprint(int, char*, ...);
+extern int vfprint(int, char*, va_list);
+
+extern int runesprint(Rune*, char*, ...);
+extern int runesnprint(Rune*, int, char*, ...);
+extern int runevsnprint(Rune*, int, char*, va_list);
+extern Rune* runeseprint(Rune*, Rune*, char*, ...);
+extern Rune* runevseprint(Rune*, Rune*, char*, va_list);
+extern Rune* runesmprint(char*, ...);
+extern Rune* runevsmprint(char*, va_list);
+
+extern int fmtfdinit(Fmt*, int, char*, int);
+extern int fmtfdflush(Fmt*);
+extern int fmtstrinit(Fmt*);
+extern char* fmtstrflush(Fmt*);
+extern int runefmtstrinit(Fmt*);
+extern Rune* runefmtstrflush(Fmt*);
+
+extern int fmtinstall(int, int (*)(Fmt*));
+extern int dofmt(Fmt*, char*);
+extern int dorfmt(Fmt*, Rune*);
+extern int fmtprint(Fmt*, char*, ...);
+extern int fmtvprint(Fmt*, char*, va_list);
+extern int fmtrune(Fmt*, int);
+extern int fmtstrcpy(Fmt*, char*);
+extern int fmtrunestrcpy(Fmt*, Rune*);
+/*
+ * error string for %r
+ * supplied on per os basis, not part of fmt library
+ */
+extern int errfmt(Fmt *f);
+
+/*
+ * quoted strings
+ */
+extern char *unquotestrdup(char*);
+extern Rune *unquoterunestrdup(Rune*);
+extern char *quotestrdup(char*);
+extern Rune *quoterunestrdup(Rune*);
+extern int quotestrfmt(Fmt*);
+extern int quoterunestrfmt(Fmt*);
+extern void quotefmtinstall(void);
+extern int (*doquote)(int);
+
+/*
+ * random number
+ */
+extern int nrand(int);
+extern ulong truerand(void);
+extern ulong ntruerand(ulong);
+
+/*
+ * math
+ */
+extern int isNaN(double);
+extern double NaN(void);
+extern int isInf(double, int);
+extern double pow(double, double);
+
+/*
+ * Time-of-day
+ */
+
+typedef struct Tm Tm;
+struct Tm {
+ int sec;
+ int min;
+ int hour;
+ int mday;
+ int mon;
+ int year;
+ int wday;
+ int yday;
+ char zone[4];
+ int tzoff;
+};
+extern vlong osnsec(void);
+#define nsec osnsec
+
+/*
+ * one-of-a-kind
+ */
+extern void _assert(char*);
+extern double charstod(int(*)(void*), void*);
+extern char* cleanname(char*);
+extern double frexp(double, int*);
+extern ulong getcallerpc(void*);
+extern int getfields(char*, char**, int, int, char*);
+extern char* getuser(void);
+extern char* getwd(char*, int);
+extern double ipow10(int);
+extern double ldexp(double, int);
+extern double modf(double, double*);
+#define pow10 infpow10
+extern double pow10(int);
+extern vlong strtoll(const char*, char**, int);
+#define qsort infqsort
+extern void qsort(void*, long, long, int (*)(void*, void*));
+extern uvlong strtoull(const char*, char**, int);
+extern void sysfatal(char*, ...);
+extern int dec64(uchar*, int, char*, int);
+extern int enc64(char*, int, uchar*, int);
+extern int dec32(uchar*, int, char*, int);
+extern int enc32(char*, int, uchar*, int);
+extern int dec16(uchar*, int, char*, int);
+extern int enc16(char*, int, uchar*, int);
+extern int encodefmt(Fmt*);
+
+/*
+ * synchronization
+ */
+typedef
+struct Lock {
+ int val;
+ int pid;
+} Lock;
+
+extern int _tas(int*);
+
+extern void lock(Lock*);
+extern void unlock(Lock*);
+extern int canlock(Lock*);
+
+typedef struct QLock QLock;
+struct QLock
+{
+ Lock use; /* to access Qlock structure */
+ Proc *head; /* next process waiting for object */
+ Proc *tail; /* last process waiting for object */
+ int locked; /* flag */
+};
+
+extern void qlock(QLock*);
+extern void qunlock(QLock*);
+extern int canqlock(QLock*);
+extern void _qlockinit(ulong (*)(ulong, ulong)); /* called only by the thread library */
+
+typedef
+struct RWLock
+{
+ Lock l; /* Lock modify lock */
+ QLock x; /* Mutual exclusion lock */
+ QLock k; /* Lock for waiting writers */
+ int readers; /* Count of readers in lock */
+} RWLock;
+
+extern int canrlock(RWLock*);
+extern int canwlock(RWLock*);
+extern void rlock(RWLock*);
+extern void runlock(RWLock*);
+extern void wlock(RWLock*);
+extern void wunlock(RWLock*);
+
+/*
+ * network dialing
+ */
+#define NETPATHLEN 40
+
+/*
+ * system calls
+ *
+ */
+#define STATMAX 65535U /* max length of machine-independent stat structure */
+#define DIRMAX (sizeof(Dir)+STATMAX) /* max length of Dir structure */
+#define ERRMAX 128 /* max length of error string */
+
+#define MORDER 0x0003 /* mask for bits defining order of mounting */
+#define MREPL 0x0000 /* mount replaces object */
+#define MBEFORE 0x0001 /* mount goes before others in union directory */
+#define MAFTER 0x0002 /* mount goes after others in union directory */
+#define MCREATE 0x0004 /* permit creation in mounted directory */
+#define MCACHE 0x0010 /* cache some data */
+#define MMASK 0x0017 /* all bits on */
+
+#define OREAD 0 /* open for read */
+#define OWRITE 1 /* write */
+#define ORDWR 2 /* read and write */
+#define OEXEC 3 /* execute, == read but check execute permission */
+#define OTRUNC 16 /* or'ed in (except for exec), truncate file first */
+#define OCEXEC 32 /* or'ed in, close on exec */
+#define ORCLOSE 64 /* or'ed in, remove on close */
+#define OEXCL 0x1000 /* or'ed in, exclusive use (create only) */
+
+#define AEXIST 0 /* accessible: exists */
+#define AEXEC 1 /* execute access */
+#define AWRITE 2 /* write access */
+#define AREAD 4 /* read access */
+
+/* bits in Qid.type */
+#define QTDIR 0x80 /* type bit for directories */
+#define QTAPPEND 0x40 /* type bit for append only files */
+#define QTEXCL 0x20 /* type bit for exclusive use files */
+#define QTMOUNT 0x10 /* type bit for mounted channel */
+#define QTAUTH 0x08 /* type bit for authentication file */
+#define QTFILE 0x00 /* plain file */
+
+/* bits in Dir.mode */
+#define DMDIR 0x80000000 /* mode bit for directories */
+#define DMAPPEND 0x40000000 /* mode bit for append only files */
+#define DMEXCL 0x20000000 /* mode bit for exclusive use files */
+#define DMMOUNT 0x10000000 /* mode bit for mounted channel */
+#define DMAUTH 0x08000000 /* mode bit for authentication file */
+#define DMREAD 0x4 /* mode bit for read permission */
+#define DMWRITE 0x2 /* mode bit for write permission */
+#define DMEXEC 0x1 /* mode bit for execute permission */
+
+typedef
+struct Qid
+{
+ uvlong path;
+ ulong vers;
+ uchar type;
+} Qid;
+
+typedef
+struct Dir {
+ /* system-modified data */
+ ushort type; /* server type */
+ uint dev; /* server subtype */
+ /* file data */
+ Qid qid; /* unique id from server */
+ ulong mode; /* permissions */
+ ulong atime; /* last read time */
+ ulong mtime; /* last write time */
+ vlong length; /* file length */
+ char *name; /* last element of path */
+ char *uid; /* owner name */
+ char *gid; /* group name */
+ char *muid; /* last modifier name */
+} Dir;
+
+extern Dir* dirstat(char*);
+extern Dir* dirfstat(int);
+extern int dirwstat(char*, Dir*);
+extern int dirfwstat(int, Dir*);
+extern long dirread(int, Dir**);
+extern void nulldir(Dir*);
+extern long dirreadall(int, Dir**);
+
+typedef
+struct Waitmsg
+{
+ int pid; /* of loved one */
+ ulong time[3]; /* of loved one & descendants */
+ char *msg;
+} Waitmsg;
+
+extern void _exits(char*);
+
+extern void exits(char*);
+extern int create(char*, int, int);
+extern int errstr(char*, uint);
+
+extern void perror(const char*);
+extern long readn(int, void*, long);
+extern int remove(const char*);
+extern void rerrstr(char*, uint);
+extern vlong seek(int, vlong, int);
+extern int segflush(void*, ulong);
+extern void werrstr(char*, ...);
+
+extern char *argv0;
+#define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
+ argv[0] && argv[0][0]=='-' && argv[0][1];\
+ argc--, argv++) {\
+ char *_args, *_argt;\
+ Rune _argc;\
+ _args = &argv[0][1];\
+ if(_args[0]=='-' && _args[1]==0){\
+ argc--; argv++; break;\
+ }\
+ _argc = 0;\
+ while(*_args && (_args += chartorune(&_argc, _args)))\
+ switch(_argc)
+#define ARGEND SET(_argt);USED(_argt);USED(_argc); USED(_args);}USED(argv); USED(argc);
+#define ARGF() (_argt=_args, _args="",\
+ (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
+#define EARGF(x) (_argt=_args, _args="",\
+ (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
+
+#define ARGC() _argc
+
+/*
+ * Extensions for Inferno to basic libc.h
+ */
+
+#define setbinmode()
+
+extern void setfcr(ulong);
+extern void setfsr(ulong);
+extern ulong getfcr(void);
+extern ulong getfsr(void);
+
+
+/* FPSCR */
+#define FPSFX (1<<31) /* exception summary (sticky) */
+#define FPSEX (1<<30) /* enabled exception summary */
+#define FPSVX (1<<29) /* invalid operation exception summary */
+#define FPSOX (1<<28) /* overflow exception OX (sticky) */
+#define FPSUX (1<<27) /* underflow exception UX (sticky) */
+#define FPSZX (1<<26) /* zero divide exception ZX (sticky) */
+#define FPSXX (1<<25) /* inexact exception XX (sticky) */
+#define FPSVXSNAN (1<<24) /* invalid operation exception for SNaN (sticky) */
+#define FPSVXISI (1<<23) /* invalid operation exception for ∞-∞ (sticky) */
+#define FPSVXIDI (1<<22) /* invalid operation exception for ∞/∞ (sticky) */
+#define FPSVXZDZ (1<<21) /* invalid operation exception for 0/0 (sticky) */
+#define FPSVXIMZ (1<<20) /* invalid operation exception for ∞*0 (sticky) */
+#define FPSVXVC (1<<19) /* invalid operation exception for invalid compare (sticky) */
+#define FPSFR (1<<18) /* fraction rounded */
+#define FPSFI (1<<17) /* fraction inexact */
+#define FPSFPRF (1<<16) /* floating point result class */
+#define FPSFPCC (0xF<<12) /* <, >, =, unordered */
+#define FPVXCVI (1<<8) /* enable exception for invalid integer convert (sticky) */
+
+/* FCR */
+#define FPVE (1<<7) /* invalid operation exception enable */
+#define FPOVFL (1<<6) /* enable overflow exceptions */
+#define FPUNFL (1<<5) /* enable underflow */
+#define FPZDIV (1<<4) /* enable zero divide */
+#define FPINEX (1<<3) /* enable inexact exceptions */
+#define FPRMASK (3<<0) /* rounding mode */
+#define FPRNR (0<<0)
+#define FPRZ (1<<0)
+#define FPRPINF (2<<0)
+#define FPRNINF (3<<0)
+#define FPPEXT 0
+#define FPPSGL 0
+#define FPPDBL 0
+#define FPPMASK 0
+#define FPINVAL FPVE
+/* FSR */
+#define FPAOVFL FPSOX
+#define FPAINEX FPSXX
+#define FPAUNFL FPSUX
+#define FPAZDIV FPSZX
+#define FPAINVAL FPSVX
diff --git a/OpenBSD/386/include/emu.h b/OpenBSD/386/include/emu.h
index 5e03489b..5392e2a4 100644
--- a/OpenBSD/386/include/emu.h
+++ b/OpenBSD/386/include/emu.h
@@ -15,6 +15,7 @@ struct FPU
#define KSTACK (32 * 1024)
+#ifndef USE_PTHREADS
static __inline Proc *getup(void) {
Proc *p;
__asm__( "movl %%esp, %%eax\n\t"
@@ -22,6 +23,9 @@ static __inline Proc *getup(void) {
);
return *(Proc **)((unsigned long)p & ~(KSTACK - 1));
};
+#else
+extern Proc* getup(void);
+#endif
#define up (getup())
diff --git a/OpenBSD/386/include/lib9.h b/OpenBSD/386/include/lib9.h
index 69c310e9..377e19f6 100644
--- a/OpenBSD/386/include/lib9.h
+++ b/OpenBSD/386/include/lib9.h
@@ -1,10 +1,15 @@
/* define _BSD_SOURCE to use ISO C, POSIX, and 4.3BSD things. */
+#define USE_PTHREADS
#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
+
+#ifdef USE_PTHREADS
+#define _REENTRANT 1
+#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
@@ -473,3 +478,29 @@ extern char *argv0;
#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);
diff --git a/README.md b/README.md
index 84be1156..9074dc7b 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,7 @@
Inferno® is a distributed operating system, originally developed at Bell Labs, but now developed and maintained by Vita Nuova® as Free Software. Applications written in Inferno's concurrent programming language, Limbo, are compiled to its portable virtual machine code (Dis), to run anywhere on a network in the portable environment that Inferno provides. Unusually, that environment looks and acts like a complete operating system.
-The use of a high-level language and virtual machine is sensible but mundane. The interesting thing is the system's representation of services and resources. They are represented in a file-like name hiearchy. Programs access them using only the file operations open, read/write, and close. The 'files' may of course represent stored data, but may also be devices, network and protocol interfaces, dynamic data sources, and services. The approach unifies and provides basic naming, structuring, and access control mechanisms for all system resources. A single file-service protocol (the same as Plan 9's 9P) makes all those resources available for import or export throughout the network in a uniform way, independent of location. An application simply attaches the resources it needs to its own per-process name hierarchy ('name space').
+Inferno represents services and resrouces in a file-like name hiearchy. Programs access them using only the file operations open, read/write, and close. `Files' are not just stored data, but represent devices, network and protocol interfaces, dynamic data sources, and services. The approach unifies and provides basic naming, structuring, and access control mechanisms for all system resources. A single file-service protocol (the same as Plan 9's 9P) makes all those resources available for import or export throughout the network in a uniform way, independent of location. An application simply attaches the resources it needs to its own per-process name hierarchy ('name space').
-The system can be used to build portable client and server applications. It makes it straightforward to build lean applications that share all manner of resources over a network, without the cruft of much of the 'Grid' software one sees.
-
-Inferno can run 'native' on various ARM, PowerPC, SPARC and x86 platforms but also 'hosted', under an existing operating system (including FreeBSD, Irix, Linux, MacOS X, Plan 9, and Solaris), again on various processor types.
+Inferno can run 'native' on various ARM, PowerPC, SPARC and x86 platforms but also 'hosted', under an existing operating system (including AIX, FreeBSD, Irix, Linux, MacOS X, Plan 9, and Solaris), again on various processor types.
This Bitbucket project includes source for the basic applications, Inferno itself (hosted and native), all supporting software, including the native compiler suite, essential executables and supporting files.
diff --git a/appl/acme/ecmd.b b/appl/acme/ecmd.b
index e05c4e47..19e38eb3 100644
--- a/appl/acme/ecmd.b
+++ b/appl/acme/ecmd.b
@@ -1192,7 +1192,7 @@ filematch(f: ref File, r: ref String): int
{
buf: string;
w: ref Window;
- match, i, dirty: int;
+ match, dirty: int;
s: Rangeset;
# compile expr first so if we get an error, we haven't allocated anything
@@ -1203,7 +1203,7 @@ filematch(f: ref File, r: ref String): int
dirty = !w.isdir && !w.isscratch && f.mod;
buf = sprint("%c%c%c %s\n", " '"[dirty],
'+', " ."[curtext!=nil && curtext.file==f], f.name);
- (match, s) = rxexecute(nil, buf, 0, i);
+ (match, s) = rxexecute(nil, buf, 0, len buf);
buf = nil;
return match;
}
diff --git a/appl/cmd/limbo/limbo.y b/appl/cmd/limbo/limbo.y
index 2f7d3ba8..4eb4af8a 100644
--- a/appl/cmd/limbo/limbo.y
+++ b/appl/cmd/limbo/limbo.y
@@ -655,13 +655,13 @@ ftype : nids ':' type
{
$$ = mkids($1.src, enter("junk", 0), $3, nil);
$$.store = Darg;
- yyerror("illegal argument declaraion");
+ yyerror("illegal argument declaration");
}
| idterms ':' adtk
{
$$ = mkids($1.src, enter("junk", 0), $3, nil);
$$.store = Darg;
- yyerror("illegal argument declaraion");
+ yyerror("illegal argument declaration");
}
;
diff --git a/appl/cmd/limbo/types.b b/appl/cmd/limbo/types.b
index 6b1802e5..2ee207b3 100644
--- a/appl/cmd/limbo/types.b
+++ b/appl/cmd/limbo/types.b
@@ -1775,7 +1775,7 @@ cycfield(base: ref Type, id: ref Decl)
+id.sym.name+" of "+stypeconv(base));
id.cycerr = byte 1;
}else if(arc & ArcCyc){
- if((arc & ArcArray) && id.cyc == byte 0 && !(arc & ArcPolycyc)){
+ if((arc & ArcArray) && oldcycles && id.cyc == byte 0 && !(arc & ArcPolycyc)){
if(id.cycerr == byte 0)
error(base.src.start, "illegal circular reference to type "+typeconv(id.ty)
+" in field "+id.sym.name+" of "+stypeconv(base));
diff --git a/appl/cmd/m4.b b/appl/cmd/m4.b
index bc992b4f..a4648d4c 100644
--- a/appl/cmd/m4.b
+++ b/appl/cmd/m4.b
@@ -52,8 +52,11 @@ lquote := '`';
rquote := '\'';
initcom := "#";
endcom := "\n";
+prefix := "";
bout: ref Iobuf;
sh: Sh;
+stderr: ref Sys->FD;
+tracing := 0;
init(nil: ref Draw->Context, args: list of string)
{
@@ -61,9 +64,27 @@ init(nil: ref Draw->Context, args: list of string)
bufio = load Bufio Bufio->PATH;
bout = bufio->fopen(sys->fildes(1), Sys->OWRITE);
+ stderr = sys->fildes(2);
define("inferno", "inferno", 0);
+ arg := load Arg Arg->PATH;
+ arg->setusage("m4 [-t] [-pprefix] [-Dname[=value]] [-Qname[=value]] [-Uname] [file ...]");
+ arg->init(args);
+
+ while((o := arg->opt()) != 0){
+ case o {
+ 'D' or 'Q' or 'U' =>
+ ; # for second pass
+ 'p' =>
+ prefix = arg->earg();
+ 't' =>
+ tracing = 1;
+ * =>
+ arg->usage();
+ }
+ }
+
builtin("changecom", dochangecom);
builtin("changequote", dochangequote);
builtin("copydef", docopydef);
@@ -88,11 +109,9 @@ init(nil: ref Draw->Context, args: list of string)
builtin("undefine", doundefine);
builtin("undivert", doundivert);
- arg := load Arg Arg->PATH;
- arg->setusage("m4 [-Dname[=value]] [-Qname[=value]] [-Uname] [file ...]");
arg->init(args);
- while((o := arg->opt()) != 0){
+ while((o = arg->opt()) != 0){
case o {
'D' =>
argdefine(arg->earg(), 0);
@@ -100,6 +119,10 @@ init(nil: ref Draw->Context, args: list of string)
argdefine(arg->earg(), 1);
'U' =>
undefine(arg->earg());
+ 'p' =>
+ arg->earg();
+ 't' =>
+ ;
* =>
arg->usage();
}
@@ -157,7 +180,8 @@ error(s: string)
ios := hd instack;
where = sys->sprint(" %s:%d:", ios.name, ios.line);
}
- sys->fprint(sys->fildes(2), "m4:%s %s\n", where, s);
+ bout.flush();
+ sys->fprint(stderr, "m4:%s %s\n", where, s);
raise "fail:error";
}
@@ -191,9 +215,12 @@ called(c: int)
curarg = ref Param("");
nesting := 0; # () depth
skipws();
+ mark := instack;
for(;;){
- if((c = getc()) < 0)
+ if((c = getc()) < 0) {
+ instack = mark;
error("EOF in parameters");
+ }
if(isalpha(c))
called(c);
else if(c == lquote)
@@ -228,9 +255,12 @@ called(c: int)
quoted()
{
nesting :=0;
+ mark := instack;
while((c := getc()) != rquote || nesting > 0){
- if(c < 0)
+ if(c < 0) {
+ instack = mark;
error("EOF in string");
+ }
if(c == rquote)
nesting--;
else if(c == lquote)
@@ -276,19 +306,9 @@ isspace(c: int): int
return c == ' ' || c == '\t' || c == '\n' || c == '\r';
}
-isname(s: string): int
-{
- if(s == nil || !isalpha(s[0]))
- return 0;
- for(i := 1; i < len s; i++)
- if(!(isalpha(s[i]) || s[i]>='0' && s[i]<='9'))
- return 0;
- return 1;
-}
-
isalpha(c: int): int
{
- return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c > 16rA0;
+ return c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c > 16rA0 && c != lquote && c != rquote;
}
hash(name: string): int
@@ -301,6 +321,13 @@ hash(name: string): int
builtin(name: string, impl: ref fn(nil: array of string))
{
+ if(prefix != "")
+ name = prefix+name;
+ ibuiltin(name, impl);
+}
+
+ibuiltin(name: string, impl: ref fn(nil: array of string))
+{
h := hash(name);
n := ref Name(name, nil, impl, 0, 0);
names[h] = n :: names[h];
@@ -418,6 +445,12 @@ putc(c: int)
expand(def: ref Name, args: array of string)
{
+ if(tracing){
+ sys->fprint(stderr, "expand %s [%s]", args[0], def.name);
+ for(i := 1; i < len args; i++)
+ sys->fprint(stderr, " %d: [%s]", i, args[i]);
+ sys->fprint(stderr, "\n");
+ }
if(def.impl != nil){
def.impl(args);
return;
@@ -474,7 +507,7 @@ docopydef(args: array of string)
if(n.impl == nil)
define(args[2], n.repl, n.asis);
else
- builtin(args[2], n.impl);
+ ibuiltin(args[2], n.impl);
}else
define(args[2], "", 0);
}
@@ -524,12 +557,12 @@ doundivert(args: array of string)
doifdef(args: array of string)
{
- if(len args < 2)
+ if(len args < 3)
return;
n := lookup(args[1]);
if(n != nil)
pushs(args[2]);
- else if(len args > 2)
+ else if(len args > 3)
pushs(args[3]);
}
@@ -642,7 +675,7 @@ doerrprint(args: array of string)
for(i := 1; i < len args; i++)
s += " "+args[i];
if(s != nil)
- sys->fprint(sys->fildes(2), "m4:%s\n", s);
+ sys->fprint(stderr, "m4:%s\n", s);
}
dolen(args: array of string)
diff --git a/appl/math/mersenne.b b/appl/math/mersenne.b
index c90254b0..7efc4a97 100644
--- a/appl/math/mersenne.b
+++ b/appl/math/mersenne.b
@@ -3,9 +3,9 @@ implement Mersenne;
include "sys.m";
sys : Sys;
include "draw.m";
-include "keyring.m";
- keyring: Keyring;
- IPint: import keyring;
+include "ipints.m";
+ ipints: IPints;
+ IPint: import ipints;
# Test primality of Mersenne numbers
@@ -17,7 +17,7 @@ Mersenne: module
init(nil: ref Draw->Context, argv: list of string)
{
sys = load Sys Sys->PATH;
- keyring = load Keyring Keyring->PATH;
+ ipints = load IPints IPints->PATH;
p := 3;
if(tl argv != nil)
p = int hd tl argv;
diff --git a/appl/math/parts.b b/appl/math/parts.b
index 36c36d8e..be5cd1bb 100644
--- a/appl/math/parts.b
+++ b/appl/math/parts.b
@@ -3,9 +3,9 @@ implement Partitions;
include "sys.m";
sys : Sys;
include "draw.m";
-include "keyring.m";
- keyring: Keyring;
- IPint: import keyring;
+include "ipints.m";
+ ipints: IPints;
+ IPint: import ipints;
#
# the number p(n) of partitions of n
@@ -25,7 +25,7 @@ Partitions: module
init(nil: ref Draw->Context, argv: list of string)
{
sys = load Sys Sys->PATH;
- keyring = load Keyring Keyring->PATH;
+ ipints = load IPints IPints->PATH;
argv = tl argv;
while(argv != nil){
s := hd argv;
diff --git a/dis/limbo.dis b/dis/limbo.dis
index b4e3acac..d6e949ed 100644
--- a/dis/limbo.dis
+++ b/dis/limbo.dis
Binary files differ
diff --git a/dis/m4.dis b/dis/m4.dis
index f3d48da9..b4f33d37 100644
--- a/dis/m4.dis
+++ b/dis/m4.dis
Binary files differ
diff --git a/dis/math/mersenne.dis b/dis/math/mersenne.dis
index 6a3b0ebc..8a388809 100644
--- a/dis/math/mersenne.dis
+++ b/dis/math/mersenne.dis
Binary files differ
diff --git a/dis/math/parts.dis b/dis/math/parts.dis
index ee7632cb..7eb56ba2 100644
--- a/dis/math/parts.dis
+++ b/dis/math/parts.dis
Binary files differ
diff --git a/doc/port.ms b/doc/port.ms
index 21ae2830..cb56ae1e 100644
--- a/doc/port.ms
+++ b/doc/port.ms
@@ -189,6 +189,7 @@ There are currently four main variants of hosted Inferno: Plan 9, Unix (and clon
The source is held in directory
.CW emu ,
with a subdirectory for each hosted platform:
+.CW AIX ,
.CW FreeBSD ,
.CW Irix ,
.CW Linux ,
@@ -246,6 +247,7 @@ threads efficiently.
.PP
There are working emu versions
for
+AIX/power,
FreeBSD/386,
Irix/mips,
Linux/386,
diff --git a/emu/AIX/asm-power.s b/emu/AIX/asm-power.s
new file mode 100644
index 00000000..024c058b
--- /dev/null
+++ b/emu/AIX/asm-power.s
@@ -0,0 +1,108 @@
+.set r0,0; .set SP,1; .set RTOC,2; .set r3,3; .set r4,4
+.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
+.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
+.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
+.set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
+.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
+.set r30,30; .set r31,31
+.set fp0,0; .set fp1,1; .set fp2,2; .set fp3,3; .set fp4,4
+.set fp5,5; .set fp6,6; .set fp7,7; .set fp8,8; .set fp9,9
+.set fp10,10; .set fp11,11; .set fp12,12; .set fp13,13; .set fp14,14
+.set fp15,15; .set fp16,16; .set fp17,17; .set fp18,18; .set fp19,19
+.set fp20,20; .set fp21,21; .set fp22,22; .set fp23,23; .set fp24,24
+.set fp25,25; .set fp26,26; .set fp27,27; .set fp28,28; .set fp29,29
+.set fp30,30; .set fp31,31
+.set v0,0; .set v1,1; .set v2,2; .set v3,3; .set v4,4
+.set v5,5; .set v6,6; .set v7,7; .set v8,8; .set v9,9
+.set v10,10; .set v11,11; .set v12,12; .set v13,13; .set v14,14
+.set v15,15; .set v16,16; .set v17,17; .set v18,18; .set v19,19
+.set v20,20; .set v21,21; .set v22,22; .set v23,23; .set v24,24
+.set v25,25; .set v26,26; .set v27,27; .set v28,28; .set v29,29
+.set v30,30; .set v31,31
+.set LR,8; .set CTR,9; .set TID,17; .set DSISR,18; .set DAR,19; .set TO_RTCU,20
+
+.machine "ppc"
+
+ .align 2
+ .globl .FPsave
+.FPsave:
+ stfd fp14,0*8(r3)
+ stfd fp15,1*8(r3)
+ stfd fp16,2*8(r3)
+ stfd fp17,3*8(r3)
+ stfd fp18,4*8(r3)
+ stfd fp19,5*8(r3)
+ stfd fp20,6*8(r3)
+ stfd fp21,7*8(r3)
+ stfd fp22,8*8(r3)
+ stfd fp23,9*8(r3)
+ stfd fp24,10*8(r3)
+ stfd fp25,11*8(r3)
+ stfd fp26,12*8(r3)
+ stfd fp27,13*8(r3)
+ stfd fp28,14*8(r3)
+ stfd fp29,15*8(r3)
+ stfd fp30,16*8(r3)
+ stfd fp31,17*8(r3)
+ blr
+
+ .align 2
+ .globl .FPrestore
+.FPrestore:
+ lfd fp14,0*8(r3)
+ lfd fp15,1*8(r3)
+ lfd fp16,2*8(r3)
+ lfd fp17,3*8(r3)
+ lfd fp18,4*8(r3)
+ lfd fp19,5*8(r3)
+ lfd fp20,6*8(r3)
+ lfd fp21,7*8(r3)
+ lfd fp22,8*8(r3)
+ lfd fp23,9*8(r3)
+ lfd fp24,10*8(r3)
+ lfd fp25,11*8(r3)
+ lfd fp26,12*8(r3)
+ lfd fp27,13*8(r3)
+ lfd fp28,14*8(r3)
+ lfd fp29,15*8(r3)
+ lfd fp30,16*8(r3)
+ lfd fp31,17*8(r3)
+ blr
+
+ .align 2
+ .globl ._tas
+._tas:
+ sync
+ mr r4, r3
+ addi r5,0,0x1
+_tas_1:
+ lwarx r3, 0, r4
+ cmpwi r3, 0
+ bne- _tas_2
+ stwcx. r5, 0, r4
+ bne- _tas_1
+_tas_2:
+ sync
+ blr
+
+ .align 2
+ .globl .executeonnewstack
+.executeonnewstack:
+ mr SP,r3 # change stacks
+ stwu LR,-16(SP) # save lr to aid the traceback
+ li r0,0
+ stw r0,20(SP)
+ mr r3,r5
+ mtctr r4
+ bctrl # tramp(arg)
+ br
+
+ .align 2
+ .globl .unlockandexit
+.unlockandexit:
+ li r0,0x0
+ stw r0,0(r3) # unlock
+ li r0,1 # sys exit; 234 is exit group
+ li r3,0 # exit status
+ sc
+ br
diff --git a/emu/AIX/cmd.c b/emu/AIX/cmd.c
new file mode 100644
index 00000000..ed4cabab
--- /dev/null
+++ b/emu/AIX/cmd.c
@@ -0,0 +1,213 @@
+#include <sys/types.h>
+#include <signal.h>
+#include <pwd.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+#include <fcntl.h>
+
+#include "dat.h"
+#include "fns.h"
+#include "error.h"
+
+enum
+{
+ Debug = 0
+};
+
+/*
+ * os-specific devcmd support.
+ * this version should be reasonably portable across Unix systems.
+ */
+typedef struct Targ Targ;
+struct Targ
+{
+ int fd[3]; /* fd[0] is standard input, fd[1] is standard output, fd[2] is standard error */
+ char** args;
+ char* dir;
+ int pid;
+ int wfd; /* child writes errors that occur after the fork or on exec */
+ int uid;
+ int gid;
+};
+
+extern int gidnobody;
+extern int uidnobody;
+
+static int
+childproc(Targ *t)
+{
+ int i, nfd;
+
+ if(Debug)
+ print("devcmd: '%s'", t->args[0]);
+
+ nfd = getdtablesize();
+ for(i = 0; i < nfd; i++)
+ if(i != t->fd[0] && i != t->fd[1] && i != t->fd[2] && i != t->wfd)
+ close(i);
+
+ dup2(t->fd[0], 0);
+ dup2(t->fd[1], 1);
+ dup2(t->fd[2], 2);
+ close(t->fd[0]);
+ close(t->fd[1]);
+ close(t->fd[2]);
+
+ /* should have an auth file to do host-specific authorisation? */
+ if(t->gid != -1){
+ if(setgid(t->gid) < 0 && getegid() == 0){
+ fprint(t->wfd, "can't set gid %d: %s", t->gid, strerror(errno));
+ _exit(1);
+ }
+ }
+
+ if(t->uid != -1){
+ if(setuid(t->uid) < 0 && geteuid() == 0){
+ fprint(t->wfd, "can't set uid %d: %s", t->uid, strerror(errno));
+ _exit(1);
+ }
+ }
+
+ if(t->dir != nil && chdir(t->dir) < 0){
+ fprint(t->wfd, "can't chdir to %s: %s", t->dir, strerror(errno));
+ _exit(1);
+ }
+
+ signal(SIGPIPE, SIG_DFL);
+
+ execvp(t->args[0], t->args);
+ if(Debug)
+ print("execvp: %s\n",strerror(errno));
+ fprint(t->wfd, "exec failed: %s", strerror(errno));
+
+ _exit(1);
+}
+
+void*
+oscmd(char **args, int nice, char *dir, int *fd)
+{
+ Targ *t;
+ int r, fd0[2], fd1[2], fd2[2], wfd[2], n, pid;
+
+ t = mallocz(sizeof(*t), 1);
+ if(t == nil)
+ return nil;
+
+ fd0[0] = fd0[1] = -1;
+ fd1[0] = fd1[1] = -1;
+ fd2[0] = fd2[1] = -1;
+ wfd[0] = wfd[1] = -1;
+ if(pipe(fd0) < 0 || pipe(fd1) < 0 || pipe(fd2) < 0 || pipe(wfd) < 0)
+ goto Error;
+ if(fcntl(wfd[1], F_SETFD, FD_CLOEXEC) < 0) /* close on exec to give end of file on success */
+ goto Error;
+
+ t->fd[0] = fd0[0];
+ t->fd[1] = fd1[1];
+ t->fd[2] = fd2[1];
+ t->wfd = wfd[1];
+ t->args = args;
+ t->dir = dir;
+ t->gid = up->env->gid;
+ if(t->gid == -1)
+ t->gid = gidnobody;
+ t->uid = up->env->uid;
+ if(t->uid == -1)
+ t->uid = uidnobody;
+
+ signal(SIGCHLD, SIG_DFL);
+ switch(pid = fork()) {
+ case -1:
+ goto Error;
+ case 0:
+ setpgid(0, getpid());
+ if(nice)
+ oslopri();
+ childproc(t);
+ _exit(1);
+ default:
+ t->pid = pid;
+ if(Debug)
+ print("cmd pid %d\n", t->pid);
+ break;
+ }
+
+ close(fd0[0]);
+ close(fd1[1]);
+ close(fd2[1]);
+ close(wfd[1]);
+
+ n = read(wfd[0], up->genbuf, sizeof(up->genbuf)-1);
+ close(wfd[0]);
+ if(n > 0){
+ close(fd0[1]);
+ close(fd1[0]);
+ close(fd2[0]);
+ free(t);
+ up->genbuf[n] = 0;
+ if(Debug)
+ print("oscmd: bad exec: %q\n", up->genbuf);
+ error(up->genbuf);
+ return nil;
+ }
+
+ fd[0] = fd0[1];
+ fd[1] = fd1[0];
+ fd[2] = fd2[0];
+ return t;
+
+Error:
+ r = errno;
+ if(Debug)
+ print("oscmd: %q\n",strerror(r));
+ close(fd0[0]);
+ close(fd0[1]);
+ close(fd1[0]);
+ close(fd1[1]);
+ close(fd2[0]);
+ close(fd2[1]);
+ close(wfd[0]);
+ close(wfd[1]);
+ error(strerror(r));
+ return nil;
+}
+
+int
+oscmdkill(void *a)
+{
+ Targ *t = a;
+
+ if(Debug)
+ print("kill: %d\n", t->pid);
+ return kill(-t->pid, SIGTERM);
+}
+
+int
+oscmdwait(void *a, char *buf, int n)
+{
+ Targ *t = a;
+ int s;
+
+ if(waitpid(t->pid, &s, 0) == -1){
+ if(Debug)
+ print("wait error: %d [in %d] %q\n", t->pid, getpid(), strerror(errno));
+ return -1;
+ }
+ if(WIFEXITED(s)){
+ if(WEXITSTATUS(s) == 0)
+ return snprint(buf, n, "%d 0 0 0 ''", t->pid);
+ return snprint(buf, n, "%d 0 0 0 'exit: %d'", t->pid, WEXITSTATUS(s));
+ }
+ if(WIFSIGNALED(s)){
+ if(WTERMSIG(s) == SIGTERM || WTERMSIG(s) == SIGKILL)
+ return snprint(buf, n, "%d 0 0 0 killed", t->pid);
+ return snprint(buf, n, "%d 0 0 0 'signal: %d'", t->pid, WTERMSIG(s));
+ }
+ return snprint(buf, n, "%d 0 0 0 'odd status: 0x%x'", t->pid, s);
+}
+
+void
+oscmdfree(void *a)
+{
+ free(a);
+}
diff --git a/emu/AIX/deveia.c b/emu/AIX/deveia.c
new file mode 100644
index 00000000..3e00ca3f
--- /dev/null
+++ b/emu/AIX/deveia.c
@@ -0,0 +1,40 @@
+/*
+ * AIX serial port definitions
+ */
+
+static char *sysdev[] = {
+ "/dev/tty0",
+ "/dev/tty1",
+ "/dev/tty2",
+ "/dev/tty3",
+ "/dev/tty4",
+ "/dev/tty5",
+ "/dev/tty6",
+ "/dev/tty7",
+};
+
+#include <sys/ioctl.h>
+#include "deveia-posix.c"
+#include "deveia-bsd.c"
+
+
+static struct tcdef_t bps[] = {
+ {0, B0},
+ {50, B50},
+ {75, B75},
+ {110, B110},
+ {134, B134},
+ {150, B150},
+ {200, B200},
+ {300, B300},
+ {600, B600},
+ {1200, B1200},
+ {1800, B1800},
+ {2400, B2400},
+ {4800, B4800},
+ {9600, B9600},
+ {19200, B19200},
+ {38400, B38400},
+ {-1, -1}
+};
+
diff --git a/emu/AIX/devfs.c b/emu/AIX/devfs.c
new file mode 100644
index 00000000..194c1090
--- /dev/null
+++ b/emu/AIX/devfs.c
@@ -0,0 +1,7 @@
+#include "devfs-posix.c"
+
+static vlong
+osdisksize(int fd)
+{
+ return 0;
+}
diff --git a/emu/AIX/emu b/emu/AIX/emu
new file mode 100644
index 00000000..43f6e128
--- /dev/null
+++ b/emu/AIX/emu
@@ -0,0 +1,104 @@
+dev
+ root
+ cons
+ env
+ mnt
+ pipe
+ prog
+ prof
+ srv
+ dup
+ ssl
+ cap
+ fs
+ cmd cmd
+ indir
+
+ draw win-x11a
+ pointer
+ snarf
+
+ ip ipif6-posix ipaux
+ eia
+ mem
+
+lib
+ interp
+ tk
+ freetype
+ math
+ draw
+
+ memlayer
+ memdraw
+ keyring
+ sec
+ mp
+
+ 9
+
+link
+
+mod
+ sys
+ draw
+
+ tk
+ math
+ srv srv
+ keyring
+ crypt
+ ipints
+ loader
+ freetype
+
+port
+ alloc
+ cache
+ chan
+ dev
+ devtab
+
+ dial
+ dis
+ discall
+ env
+ error
+ errstr
+ exception
+ exportfs
+ inferno
+ latin1
+ main
+ parse
+ pgrp
+ print
+ proc
+ qio
+ random
+ sysfile
+ uqid
+
+code
+
+init
+ emuinit
+
+root
+ /dev /
+ /fd /
+ /prog /
+ /prof /
+ /net /
+ /net.alt /
+ /chan /
+ /nvfs /
+ /env /
+# /dis
+# /n
+# /icons
+# /osinit.dis
+# /dis/emuinit.dis
+# /dis/lib/auth.dis
+# /dis/lib/ssl.dis
+# /n/local /
diff --git a/emu/AIX/emu-g b/emu/AIX/emu-g
new file mode 100644
index 00000000..41831fa9
--- /dev/null
+++ b/emu/AIX/emu-g
@@ -0,0 +1,100 @@
+env
+ X11LIBS=
+dev
+ root
+ cons
+ env
+ mnt
+ pipe
+ prog
+ prof
+ srv
+ dup
+ ssl
+ cap
+ fs
+ cmd cmd
+ indir
+
+ ip ipif6-posix ipaux
+ eia
+ mem
+
+lib
+ interp
+ math
+ keyring
+ sec
+ mp
+
+ 9
+
+link
+
+mod
+ sys
+ math
+ srv srv
+ keyring
+ crypt
+ ipints
+ loader
+
+port
+ alloc
+ cache
+ chan
+ dev
+ devtab
+
+ dial
+ dis
+ discall
+ env
+ error
+ errstr
+ exception
+ exportfs
+ inferno
+ latin1
+ main
+ parse
+ pgrp
+ print
+ proc
+ qio
+ random
+ sysfile
+ uqid
+
+code
+ void setpointer(int x, int y){USED(x); USED(y);}
+ ulong strtochan(char *s){USED(s); return ~0;}
+
+init
+ emuinit
+
+root
+ /dev /
+ /fd /
+ /prog /
+ /prof /
+ /net /
+ /net.alt /
+ /chan /
+ /nvfs /
+ /env /
+# /chan
+# /dev
+# /dis
+# /env
+# /n
+# /net
+# /nvfs /
+# /prog
+# /icons
+# /osinit.dis
+# /dis/emuinit.dis
+# /dis/lib/auth.dis
+# /dis/lib/ssl.dis
+# /n/local /
diff --git a/emu/AIX/mkfile b/emu/AIX/mkfile
new file mode 100644
index 00000000..2089bd28
--- /dev/null
+++ b/emu/AIX/mkfile
@@ -0,0 +1,52 @@
+SYSTARG=AIX
+<../../mkconfig
+SYSTARG=AIX
+
+#Configurable parameters
+
+CONF=emu #default configuration
+CONFLIST=emu
+CLEANCONFLIST=
+
+INSTALLDIR=$ROOT/$SYSTARG/$OBJTYPE/bin #path of directory where kernel is installed
+
+#end configurable parameters
+
+X11LIBS= -lX11 -lXext
+
+<$ROOT/mkfiles/mkfile-$SYSTARG-$OBJTYPE #set vars based on target system
+
+<| $SHELLNAME ../port/mkdevlist $CONF #sets $IP, $DEVS, $PORT, $LIBS
+<mkfile-$OBJTYPE
+
+OBJ=\
+ asm-$OBJTYPE.$O\
+ $ARCHFILES\
+ os.$O\
+ kproc-pthreads.$O\
+ segflush-$OBJTYPE.$O\
+ $CONF.root.$O\
+ lock.$O\
+ $DEVS\
+ $PORT\
+
+LIBNAMES=${LIBS:%=lib%.a}
+
+HFILES=\
+
+CFLAGS='-DROOT="'$ROOT'"' -DEMU -I. -I../port -I$ROOT/$SYSTARG/$OBJTYPE/include -I$ROOT/include -I$ROOT/libinterp $CTHREADFLAGS $CFLAGS $EMUOPTIONS
+SYSLIBS= $X11LIBS -lm -lpthread
+KERNDATE=`{$NDATE}
+
+default:V: $O.$CONF
+
+$O.$CONF: $OBJ $CONF.c $CONF.root.h $LIBNAMES
+ $CC $CFLAGS '-DKERNDATE='$KERNDATE $CONF.c
+ $LD $LDFLAGS -o $target $OBJ $CONF.$O $LIBFILES $SYSLIBS
+
+install:V: $O.$CONF
+ cp $O.$CONF $INSTALLDIR/$CONF
+
+<../port/portmkfile
+
+devfs.$O: ../port/devfs-posix.c
diff --git a/emu/AIX/mkfile-power b/emu/AIX/mkfile-power
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/emu/AIX/mkfile-power
diff --git a/emu/AIX/os.c b/emu/AIX/os.c
new file mode 100644
index 00000000..83bf0901
--- /dev/null
+++ b/emu/AIX/os.c
@@ -0,0 +1,300 @@
+#include <sys/types.h>
+#include <time.h>
+#include <termios.h>
+#include <signal.h>
+#include <pwd.h>
+#include <sched.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+#include <sys/time.h>
+
+#include <stdint.h>
+
+#include "dat.h"
+#include "fns.h"
+#include "error.h"
+
+#include <semaphore.h>
+
+#include <raise.h>
+
+enum
+{
+ DELETE = 0x7f,
+ CTRLC = 'C'-'@',
+ NSTACKSPERALLOC = 16,
+ X11STACK= 256*1024
+};
+char *hosttype = "Linux";
+
+typedef sem_t Sem;
+
+extern int dflag;
+
+int gidnobody = -1;
+int uidnobody = -1;
+static struct termios tinit;
+
+static void
+sysfault(char *what, void *addr)
+{
+ char buf[64];
+
+ snprint(buf, sizeof(buf), "sys: %s%#p", what, addr);
+ disfault(nil, buf);
+}
+
+static void
+trapILL(int signo, siginfo_t *si, void *a)
+{
+ USED(signo);
+ USED(a);
+ sysfault("illegal instruction pc=", si->si_addr);
+}
+
+static int
+isnilref(siginfo_t *si)
+{
+ return si != 0 && (si->si_addr == (void*)~(uintptr_t)0 || (uintptr_t)si->si_addr < 512);
+}
+
+static void
+trapmemref(int signo, siginfo_t *si, void *a)
+{
+ USED(a); /* ucontext_t*, could fetch pc in machine-dependent way */
+ if(isnilref(si))
+ disfault(nil, exNilref);
+ else if(signo == SIGBUS)
+ sysfault("bad address addr=", si->si_addr); /* eg, misaligned */
+ else
+ sysfault("segmentation violation addr=", si->si_addr);
+}
+
+static void
+trapFPE(int signo, siginfo_t *si, void *a)
+{
+ char buf[64];
+
+ USED(signo);
+ USED(a);
+ snprint(buf, sizeof(buf), "sys: fp: exception status=%.4lux pc=%#p", getfsr(), si->si_addr);
+ disfault(nil, buf);
+}
+
+static void
+trapUSR1(int signo)
+{
+ int intwait;
+
+ USED(signo);
+
+ intwait = up->intwait;
+ up->intwait = 0; /* clear it to let proc continue in osleave */
+
+ if(up->type != Interp) /* Used to unblock pending I/O */
+ return;
+
+ if(intwait == 0) /* Not posted so it's a sync error */
+ disfault(nil, Eintr); /* Should never happen */
+}
+
+void
+oslongjmp(void *regs, osjmpbuf env, int val)
+{
+ USED(regs);
+ siglongjmp(env, val);
+}
+
+static void
+termset(void)
+{
+ struct termios t;
+
+ tcgetattr(0, &t);
+ tinit = t;
+ t.c_lflag &= ~(ICANON|ECHO|ISIG);
+ t.c_cc[VMIN] = 1;
+ t.c_cc[VTIME] = 0;
+ tcsetattr(0, TCSANOW, &t);
+}
+
+static void
+termrestore(void)
+{
+ tcsetattr(0, TCSANOW, &tinit);
+}
+
+void
+cleanexit(int x)
+{
+ USED(x);
+
+ if(up->intwait) {
+ up->intwait = 0;
+ return;
+ }
+
+ if(dflag == 0)
+ termrestore();
+
+ kill(0, SIGKILL);
+ exit(0);
+}
+
+void
+osreboot(char *file, char **argv)
+{
+ if(dflag == 0)
+ termrestore();
+ execvp(file, argv);
+ error("reboot failure");
+}
+
+void
+libinit(char *imod)
+{
+ struct sigaction act;
+ struct passwd *pw;
+ Proc *p;
+ char sys[64];
+
+ setsid();
+
+ gethostname(sys, sizeof(sys));
+ kstrdup(&ossysname, sys);
+ pw = getpwnam("nobody");
+ if(pw != nil) {
+ uidnobody = pw->pw_uid;
+ gidnobody = pw->pw_gid;
+ }
+
+ if(dflag == 0)
+ termset();
+
+ memset(&act, 0, sizeof(act));
+ act.sa_handler = trapUSR1;
+ sigaction(SIGUSR1, &act, nil);
+
+ act.sa_handler = SIG_IGN;
+ sigaction(SIGCHLD, &act, nil);
+
+ /*
+ * For the correct functioning of devcmd in the
+ * face of exiting slaves
+ */
+ signal(SIGPIPE, SIG_IGN);
+ if(signal(SIGTERM, SIG_IGN) != SIG_IGN)
+ signal(SIGTERM, cleanexit);
+ if(signal(SIGINT, SIG_IGN) != SIG_IGN)
+ signal(SIGINT, cleanexit);
+
+ if(sflag == 0) {
+ act.sa_flags = SA_SIGINFO;
+ act.sa_sigaction = trapILL;
+ sigaction(SIGILL, &act, nil);
+ act.sa_sigaction = trapFPE;
+ sigaction(SIGFPE, &act, nil);
+ act.sa_sigaction = trapmemref;
+ sigaction(SIGBUS, &act, nil);
+ sigaction(SIGSEGV, &act, nil);
+ act.sa_flags &= ~SA_SIGINFO;
+ }
+
+ p = newproc();
+ kprocinit(p);
+
+ pw = getpwuid(getuid());
+ if(pw != nil)
+ kstrdup(&eve, pw->pw_name);
+ else
+ print("cannot getpwuid\n");
+
+ p->env->uid = getuid();
+ p->env->gid = getgid();
+
+ emuinit(imod);
+}
+
+int
+readkbd(void)
+{
+ int n;
+ char buf[1];
+
+ n = read(0, buf, sizeof(buf));
+ if(n < 0)
+ print("keyboard close (n=%d, %s)\n", n, strerror(errno));
+ if(n <= 0)
+ pexit("keyboard thread", 0);
+
+ switch(buf[0]) {
+ case '\r':
+ buf[0] = '\n';
+ break;
+ case DELETE:
+ buf[0] = 'H' - '@';
+ break;
+ case CTRLC:
+ cleanexit(0);
+ break;
+ }
+ return buf[0];
+}
+
+/*
+ * Return an abitrary millisecond clock time
+ */
+long
+osmillisec(void)
+{
+ static long sec0 = 0, usec0;
+ struct timeval t;
+
+ if(gettimeofday(&t,(struct timezone*)0)<0)
+ return 0;
+
+ if(sec0 == 0) {
+ sec0 = t.tv_sec;
+ usec0 = t.tv_usec;
+ }
+ return (t.tv_sec-sec0)*1000+(t.tv_usec-usec0+500)/1000;
+}
+
+/*
+ * Return the time since the epoch in nanoseconds and microseconds
+ * The epoch is defined at 1 Jan 1970
+ */
+vlong
+osnsec(void)
+{
+ struct timeval t;
+
+ gettimeofday(&t, nil);
+ return (vlong)t.tv_sec*1000000000L + t.tv_usec*1000;
+}
+
+vlong
+osusectime(void)
+{
+ struct timeval t;
+
+ gettimeofday(&t, nil);
+ return (vlong)t.tv_sec * 1000000 + t.tv_usec;
+}
+
+int
+osmillisleep(ulong milsec)
+{
+ struct timespec time;
+
+ time.tv_sec = milsec/1000;
+ time.tv_nsec= (milsec%1000)*1000000;
+ nanosleep(&time, NULL);
+ return 0;
+}
+
+int
+limbosleep(ulong milsec)
+{
+ return osmillisleep(milsec);
+}
diff --git a/emu/AIX/segflush-power.c b/emu/AIX/segflush-power.c
new file mode 100644
index 00000000..5029b0aa
--- /dev/null
+++ b/emu/AIX/segflush-power.c
@@ -0,0 +1,33 @@
+#include <sys/types.h>
+
+#include "dat.h"
+
+
+/*
+ * from geoff collyer's port
+ * invalidate instruction cache and write back data cache from a to a+n-1,
+ * at least.
+ */
+int
+segflush(void *a, ulong n)
+{
+ ulong *p;
+
+ // cache blocks are often eight words (32 bytes) long, sometimes 16 bytes.
+ // need to determine it dynamically?
+ for (p = (ulong *)((ulong)a & ~7UL); (char *)p < (char *)a + n; p++)
+ __asm__("dcbst 0,r0\n\t" // not dcbf, which writes back, then invalidates
+ "icbi 0,r0\n\t"
+ : // no output
+ : "ar" (p)
+ );
+ __asm__("sync\n\t"
+ : // no output
+ :
+ );
+ __asm__("isync\n\t"
+ : // no output
+ :
+ );
+ return 0;
+}
diff --git a/emu/NetBSD/asm-power.S b/emu/NetBSD/asm-power.S
new file mode 100644
index 00000000..da40e825
--- /dev/null
+++ b/emu/NetBSD/asm-power.S
@@ -0,0 +1,91 @@
+#include <machine/asm.h>
+
+ENTRY_NOPROFILE(FPsave)
+ stfd %f14,0*8(%r3)
+ stfd %f15,1*8(%r3)
+ stfd %f16,2*8(%r3)
+ stfd %f17,3*8(%r3)
+ stfd %f18,4*8(%r3)
+ stfd %f19,5*8(%r3)
+ stfd %f20,6*8(%r3)
+ stfd %f21,7*8(%r3)
+ stfd %f22,8*8(%r3)
+ stfd %f23,9*8(%r3)
+ stfd %f24,10*8(%r3)
+ stfd %f25,11*8(%r3)
+ stfd %f26,12*8(%r3)
+ stfd %f27,13*8(%r3)
+ stfd %f28,14*8(%r3)
+ stfd %f29,15*8(%r3)
+ stfd %f30,16*8(%r3)
+ stfd %f31,17*8(%r3)
+ blr
+ END(FPsave)
+
+ENTRY_NOPROFILE(FPrestore)
+ lfd %f14,0*8(%r3)
+ lfd %f15,1*8(%r3)
+ lfd %f16,2*8(%r3)
+ lfd %f17,3*8(%r3)
+ lfd %f18,4*8(%r3)
+ lfd %f19,5*8(%r3)
+ lfd %f20,6*8(%r3)
+ lfd %f21,7*8(%r3)
+ lfd %f22,8*8(%r3)
+ lfd %f23,9*8(%r3)
+ lfd %f24,10*8(%r3)
+ lfd %f25,11*8(%r3)
+ lfd %f26,12*8(%r3)
+ lfd %f27,13*8(%r3)
+ lfd %f28,14*8(%r3)
+ lfd %f29,15*8(%r3)
+ lfd %f30,16*8(%r3)
+ lfd %f31,17*8(%r3)
+ blr
+ END(FPrestore)
+
+ENTRY_NOPROFILE(_tas)
+ sync
+ mr %r4, %r3
+ addi %r5,0,0x1
+1:
+ lwarx %r3, 0, %r4
+ cmpwi %r3, 0
+ bne- 2f
+ stwcx. %r5, 0, %r4
+ bne- 1b
+2:
+ sync
+ blr
+ END(_tas)
+
+/*
+ * void
+ * executeonnewstack(void *tos, void (*tramp)(void *arg), void *arg)
+ */
+ENTRY_NOPROFILE(executeonnewstack)
+ mr %r1,%r3 /* change stacks */
+ stwu %lr,-16(%r1) /* save lr to aid the traceback */
+ li %r0,0
+ stw %r0,20(%r1)
+ mr %r3,%r5
+ mtctr %r4
+ bctrl /* tramp(arg) */
+ br
+ END(executeonnewstack)
+
+/*
+ * void unlockandexit(int *key)
+ *
+ * NB: the return status may be garbaged if the stack is reused
+ * between the unlock and the system call, but this should
+ * not matter since no task is waiting for the result
+ */
+ENTRY_NOPROFILE(unlockandexit)
+ li %r0,0x0
+ stw %r0,0(%r3) /* unlock */
+ li %r0,1 /* sys exit; 234 is exit group */
+ li %r3,0 /* exit status */
+ sc
+ br
+ END(unlockandexit)
diff --git a/emu/NetBSD/emu b/emu/NetBSD/emu
index 55705a2b..d89c5bc5 100644
--- a/emu/NetBSD/emu
+++ b/emu/NetBSD/emu
@@ -81,6 +81,9 @@ port
uqid
code
+ #ifdef __powerpc__
+ int macjit = 1; /* tell compiler it's not plan9 abi */
+ #endif
init
emuinit
diff --git a/emu/NetBSD/emu-g b/emu/NetBSD/emu-g
index e662b4c1..6e87297a 100644
--- a/emu/NetBSD/emu-g
+++ b/emu/NetBSD/emu-g
@@ -70,6 +70,10 @@ port
uqid
code
+ #ifdef __powerpc__
+ int macjit = 1; /* tell compiler it's not plan9 abi */
+ #endif
+
void setpointer(int x, int y){USED(x); USED(y);}
ulong strtochan(char *s){USED(s); return ~0;}
diff --git a/emu/NetBSD/emu.c b/emu/NetBSD/emu.c
deleted file mode 100644
index 69e1139d..00000000
--- a/emu/NetBSD/emu.c
+++ /dev/null
@@ -1,88 +0,0 @@
-#include "dat.h"
-#include "fns.h"
-#include "error.h"
-#include "interp.h"
-
-
-#include "emu.root.h"
-
-ulong ndevs = 29;
-
-extern Dev rootdevtab;
-extern Dev consdevtab;
-extern Dev envdevtab;
-extern Dev mntdevtab;
-extern Dev pipedevtab;
-extern Dev progdevtab;
-extern Dev profdevtab;
-extern Dev srvdevtab;
-extern Dev dupdevtab;
-extern Dev ssldevtab;
-extern Dev capdevtab;
-extern Dev fsdevtab;
-extern Dev cmddevtab;
-extern Dev indirdevtab;
-extern Dev drawdevtab;
-extern Dev pointerdevtab;
-extern Dev snarfdevtab;
-extern Dev ipdevtab;
-extern Dev eiadevtab;
-extern Dev audiodevtab;
-extern Dev memdevtab;
-Dev* devtab[]={
- &rootdevtab,
- &consdevtab,
- &envdevtab,
- &mntdevtab,
- &pipedevtab,
- &progdevtab,
- &profdevtab,
- &srvdevtab,
- &dupdevtab,
- &ssldevtab,
- &capdevtab,
- &fsdevtab,
- &cmddevtab,
- &indirdevtab,
- &drawdevtab,
- &pointerdevtab,
- &snarfdevtab,
- &ipdevtab,
- &eiadevtab,
- &audiodevtab,
- &memdevtab,
- nil,
- nil,
- nil,
- nil,
- nil,
- nil,
- nil,
- nil,
- nil,
-};
-
-void links(void){
-}
-
-extern void sysmodinit(void);
-extern void drawmodinit(void);
-extern void tkmodinit(void);
-extern void mathmodinit(void);
-extern void srvmodinit(void);
-extern void keyringmodinit(void);
-extern void loadermodinit(void);
-extern void freetypemodinit(void);
-void modinit(void){
- sysmodinit();
- drawmodinit();
- tkmodinit();
- mathmodinit();
- srvmodinit();
- keyringmodinit();
- loadermodinit();
- freetypemodinit();
-}
-
-char* conffile = "emu";
-ulong kerndate = KERNDATE;
diff --git a/emu/NetBSD/mkfile b/emu/NetBSD/mkfile
index 8eda46f3..17516997 100644
--- a/emu/NetBSD/mkfile
+++ b/emu/NetBSD/mkfile
@@ -1,8 +1,6 @@
SYSTARG=NetBSD
-OBJTYPE=386
<../../mkconfig
SYSTARG=NetBSD
-OBJTYPE=386
#Configurable parameters
@@ -24,6 +22,7 @@ X11LIBS= -L/usr/X11R7/lib -R/usr/X11R7/lib -lXext -lX11
OBJ=\
asm-$OBJTYPE.$O\
os.$O\
+ segflush-$OBJTYPE.$O\
kproc-pthreads.$O\
$CONF.root.$O\
lock.$O\
@@ -38,8 +37,6 @@ KERNDATE=`{$NDATE}
default:V: $O.$CONF
-<../port/portmkfile
-
$O.$CONF: $OBJ $CONF.c $CONF.root.h $LIBFILES
$CC $CFLAGS '-DKERNDATE='$KERNDATE $CONF.c
$LD $LDFLAGS -o $target $OBJ $CONF.$O $LIBFILES $SYSLIBS
@@ -47,4 +44,6 @@ $O.$CONF: $OBJ $CONF.c $CONF.root.h $LIBFILES
install:V: $O.$CONF
cp $O.$CONF $INSTALLDIR/$CONF
+<../port/portmkfile
+
devfs.$O: ../port/devfs-posix.c
diff --git a/emu/NetBSD/os.c b/emu/NetBSD/os.c
index 3aa95975..8ffce24e 100644
--- a/emu/NetBSD/os.c
+++ b/emu/NetBSD/os.c
@@ -301,11 +301,3 @@ limbosleep(ulong milsec)
{
return osmillisleep(milsec);
}
-
-int
-segflush(void *a, ulong n)
-{
- USED(a);
- USED(n);
- return 0;
-}
diff --git a/emu/NetBSD/segflush-386.c b/emu/NetBSD/segflush-386.c
new file mode 100644
index 00000000..cdf0496b
--- /dev/null
+++ b/emu/NetBSD/segflush-386.c
@@ -0,0 +1,9 @@
+#include "dat.h"
+
+int
+segflush(void *a, ulong n)
+{
+ USED(a);
+ USED(n);
+ return 0;
+}
diff --git a/emu/NetBSD/segflush-power.c b/emu/NetBSD/segflush-power.c
new file mode 100644
index 00000000..845d74f6
--- /dev/null
+++ b/emu/NetBSD/segflush-power.c
@@ -0,0 +1,12 @@
+#include <sys/types.h>
+#include <machine/cpu.h>
+
+#include "dat.h"
+
+
+int
+segflush(void *a, ulong n)
+{
+ __syncicache(a, n);
+ return 0;
+}
diff --git a/emu/OpenBSD/asm-386.S b/emu/OpenBSD/asm-386.S
index f3a3f9cf..e7c9fa3e 100644
--- a/emu/OpenBSD/asm-386.S
+++ b/emu/OpenBSD/asm-386.S
@@ -3,8 +3,6 @@
#include <sys/syscall.h>
#include <machine/asm.h>
-#include "rfork_thread.S"
-
/*
* executeonnewstack(void *tos, void (*tramp)(void *arg), void *arg)
*/
diff --git a/emu/OpenBSD/mkfile b/emu/OpenBSD/mkfile
index ad4e3155..a030c95e 100644
--- a/emu/OpenBSD/mkfile
+++ b/emu/OpenBSD/mkfile
@@ -19,6 +19,7 @@ INSTALLDIR=$ROOT/$SYSTARG/$OBJTYPE/bin #path of directory where kernel is instal
OBJ=\
asm-$OBJTYPE.$O\
os.$O\
+ kproc-pthreads.$O\
win-x11a.$O\
$CONF.root.$O\
lock.$O\
@@ -28,7 +29,7 @@ OBJ=\
HFILES=\
CFLAGS='-DROOT="'$ROOT'"' -DEMU -I. -I../port -I$ROOT/$SYSTARG/$OBJTYPE/include -I$ROOT/include -I$ROOT/libinterp $CTHREADFLAGS $CFLAGS $EMUOPTIONS
-SYSLIBS= -lm -lX11 -lXext -lossaudio
+SYSLIBS= -lm -lX11 -lXext -lossaudio -lpthread
KERNDATE=`{$NDATE}
default:V: $O.$CONF
diff --git a/emu/OpenBSD/os.c b/emu/OpenBSD/os.c
index f45e69d6..fc16cc30 100644
--- a/emu/OpenBSD/os.c
+++ b/emu/OpenBSD/os.c
@@ -24,60 +24,16 @@ enum
};
char *hosttype = "OpenBSD";
-int rfork_thread(int, void *, void (*)(void *), void *);
-
-extern void unlockandexit(int*);
-extern void executeonnewstack(void*, void (*f)(void*), void*);
-static void *stackalloc(Proc *p, void **tos);
-static void stackfreeandexit(void *stack);
-
extern int dflag;
void
-pexit(char *msg, int t)
-{
- Osenv *e;
- Proc *p;
- void *kstack;
-
- lock(&procs.l);
- p = up;
- if(p->prev)
- p->prev->next = p->next;
- else
- procs.head = p->next;
-
- if(up->next)
- p->next->prev = p->prev;
- else
- procs.tail = p->prev;
- unlock(&procs.l);
-
- if(0)
- print("pexit: %s: %s\n", up->text, msg);
-
- e = up->env;
- if(e != nil) {
- closefgrp(e->fgrp);
- closepgrp(e->pgrp);
- closeegrp(e->egrp);
- closesigs(e->sigs);
- }
- kstack = p->kstack;
- free(p->prog);
- free(p);
- if(kstack != nil)
- stackfreeandexit(kstack);
-}
-
-void
trapBUS(int signo, siginfo_t *info, void *context)
{
if(info)
print("trapBUS: signo: %d code: %d addr: %lx\n",
info->si_signo, info->si_code, info->si_addr);
else
- print("trapBUS: no info\n");
+ print("trapBUS: no info\n");
disfault(nil, "Bus error");
}
@@ -135,7 +91,7 @@ setsigs(void)
memset(&act, 0 , sizeof(act));
sigemptyset(&initmask);
-
+
signal(SIGPIPE, SIG_IGN); /* prevent signal when devcmd child exits */
if(signal(SIGTERM, SIG_IGN) != SIG_IGN)
signal(SIGTERM, cleanexit);
@@ -180,101 +136,6 @@ setsigs(void)
panic("sigprocmask");
}
-static void
-tramp(void *arg)
-{
- Proc *p;
-
- p = arg;
- p->pid = p->sigid = getpid();
- sigprocmask(SIG_BLOCK, &initmask, nil); /* in 5.3, rfork_thread doesn't copy from parent, contrary to docs? */
- (*p->func)(p->arg);
- pexit("{Tramp}", 0);
- _exit(0);
-}
-
-void
-kproc(char *name, void (*func)(void*), void *arg, int flags)
-{
- Proc *p;
- Pgrp *pg;
- Fgrp *fg;
- Egrp *eg;
- int pid;
- void *tos;
-
- p = newproc();
-
- if(flags & KPDUPPG) {
- pg = up->env->pgrp;
- incref(&pg->r);
- p->env->pgrp = pg;
- }
- if(flags & KPDUPFDG) {
- fg = up->env->fgrp;
- incref(&fg->r);
- p->env->fgrp = fg;
- }
- if(flags & KPDUPENVG) {
- eg = up->env->egrp;
- incref(&eg->r);
- p->env->egrp = eg;
- }
-
- p->env->uid = up->env->uid;
- p->env->gid = up->env->gid;
- kstrdup(&p->env->user, up->env->user);
-
- strcpy(p->text, name);
-
- p->func = func;
- p->arg = arg;
-
- lock(&procs.l);
- if(procs.tail != nil) {
- p->prev = procs.tail;
- procs.tail->next = p;
- }
- else {
- procs.head = p;
- p->prev = nil;
- }
- procs.tail = p;
- unlock(&procs.l);
-
- if(flags & KPX11){
- p->kstack = nil; /* never freed; also up not defined */
- tos = (char*)mallocz(X11STACK, 0) + X11STACK - sizeof(void*);
- }else
- p->kstack = stackalloc(p, &tos);
- pid = rfork_thread(RFPROC|RFMEM|RFNOWAIT, tos, tramp, p);
- if(pid < 0)
- panic("rfork");
-}
-
-void
-oshostintr(Proc *p)
-{
- kill(p->sigid, SIGUSR1);
-}
-
-void
-osblock(void)
-{
- sigset_t mask;
-
- sigprocmask(SIG_SETMASK, NULL, &mask);
- sigdelset(&mask, SIGUSR2);
- sigsuspend(&mask);
-}
-
-void
-osready(Proc *p)
-{
- if(kill(p->sigid, SIGUSR2) < 0)
- fprint(2, "emu: osready failed: pid %d: %s\n", p->sigid, strerror(errno));
-}
-
void
oslongjmp(void *regs, osjmpbuf env, int val)
{
@@ -335,7 +196,7 @@ void
getnobody()
{
struct passwd *pwd;
-
+
if(pwd = getpwnam("nobody")) {
uidnobody = pwd->pw_uid;
gidnobody = pwd->pw_gid;
@@ -347,7 +208,6 @@ libinit(char *imod)
{
struct passwd *pw;
Proc *p;
- void *tos;
char sys[64];
setsid();
@@ -362,18 +222,18 @@ libinit(char *imod)
setsigs();
p = newproc();
- p->kstack = stackalloc(p, &tos);
+ kprocinit(p);
pw = getpwuid(getuid());
if(pw != nil)
kstrdup(&eve, pw->pw_name);
else
print("cannot getpwuid\n");
-
+
p->env->uid = getuid();
p->env->gid = getgid();
- executeonnewstack(tos, emuinit, imod);
+ emuinit(imod);
}
int
@@ -440,7 +300,7 @@ vlong
osusectime(void)
{
struct timeval t;
-
+
gettimeofday(&t, nil);
return (vlong)t.tv_sec * 1000000 + t.tv_usec;
}
@@ -456,76 +316,6 @@ osmillisleep(ulong milsec)
return 0;
}
-void
-osyield(void)
-{
- sched_yield();
-}
-
-void
-ospause(void)
-{
- for(;;)
- pause();
-}
-
-void
-oslopri(void)
-{
- setpriority(PRIO_PROCESS, 0, getpriority(PRIO_PROCESS,0)+4);
-}
-
-static struct {
- Lock l;
- void *free;
-} stacklist;
-
-static void
-_stackfree(void *stack)
-{
- *((void **)stack) = stacklist.free;
- stacklist.free = stack;
-}
-
-static void
-stackfreeandexit(void *stack)
-{
- lock(&stacklist.l);
- _stackfree(stack);
- unlockandexit(&stacklist.l.val);
-}
-
-static void *
-stackalloc(Proc *p, void **tos)
-{
- void *rv;
- lock(&stacklist.l);
- if (stacklist.free == 0) {
- int x;
- /*
- * obtain some more by using sbrk()
- */
- void *more = sbrk(KSTACK * (NSTACKSPERALLOC + 1));
- if (more == 0)
- panic("stackalloc: no more stacks");
- /*
- * align to KSTACK
- */
- more = (void *)((((unsigned long)more) + (KSTACK - 1)) & ~(KSTACK - 1));
- /*
- * free all the new stacks onto the freelist
- */
- for (x = 0; x < NSTACKSPERALLOC; x++)
- _stackfree((char *)more + KSTACK * x);
- }
- rv = stacklist.free;
- stacklist.free = *(void **)rv;
- unlock(&stacklist.l);
- *tos = rv + KSTACK - sizeof(void*);
- *(Proc **)rv = p;
- return rv;
-}
-
int
segflush(void *p, ulong n)
{
diff --git a/emu/OpenBSD/rfork_thread.S b/emu/OpenBSD/rfork_thread.S
deleted file mode 100644
index bb7cd010..00000000
--- a/emu/OpenBSD/rfork_thread.S
+++ /dev/null
@@ -1,104 +0,0 @@
-/*-
- * Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * 8 12 16 20
- * rfork_thread(flags, stack_addr, start_fnc, start_arg);
- *
- * flags: Flags to rfork system call. See rfork(2).
- * stack_addr: Top of stack for thread.
- * start_fnc: Address of thread function to call in child.
- * start_arg: Argument to pass to the thread function in child.
- */
-
-ENTRY(rfork_thread)
- pushl %ebp
- movl %esp, %ebp
- pushl %esi
-
- /*
- * Push thread info onto the new thread's stack
- */
- movl 12(%ebp), %esi # get stack addr
-
- subl $4, %esi
- movl 20(%ebp), %eax # get start argument
- movl %eax, (%esi)
-
- subl $4, %esi
- movl 16(%ebp), %eax # get start thread address
- movl %eax, (%esi)
-
- /*
- * Prepare and execute the thread creation syscall
- */
- pushl 8(%ebp)
- pushl $0
- movl $SYS_rfork, %eax
- int $0x80
- jb 2f
-
- /*
- * Check to see if we are in the parent or child
- */
- cmpl $0, %edx
- jnz 1f
- addl $8, %esp
- popl %esi
- movl %ebp, %esp
- popl %ebp
- ret
- .p2align 2
-
- /*
- * If we are in the child (new thread), then
- * set-up the call to the internal subroutine. If it
- * returns, then call __exit.
- */
-1:
- movl %esi,%esp
- popl %eax
- call *%eax
- addl $4, %esp
-
- /*
- * Exit system call
- */
- pushl %eax
- pushl $0
- movl $SYS_threxit, %eax
- int $0x80
-
- /*
- * Branch here if the thread creation fails:
- */
-2:
- addl $8, %esp
- popl %esi
- movl %ebp, %esp
- popl %ebp
- PIC_PROLOGUE
- jmp PIC_PLT(_C_LABEL(__cerror))
diff --git a/emu/port/devfs-posix.c b/emu/port/devfs-posix.c
index 02c842f4..14cce877 100644
--- a/emu/port/devfs-posix.c
+++ b/emu/port/devfs-posix.c
@@ -9,7 +9,7 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include <sys/fcntl.h>
+#include <fcntl.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <utime.h>
diff --git a/emu/port/win-x11a.c b/emu/port/win-x11a.c
index 4fdd295a..569287b6 100644
--- a/emu/port/win-x11a.c
+++ b/emu/port/win-x11a.c
@@ -304,7 +304,7 @@ copy32to32(Rectangle r)
lp = dp + width;
while(dp < lp){
v = *dp++;
- w = infernortox11[(v>>16)&0xff]<<16|infernogtox11[(v>>8)&0xff]<<8|infernobtox11[(v>>0)&0xff]<<0;
+ w = v&(0xff<<24)|infernortox11[(v>>16)&0xff]<<16|infernogtox11[(v>>8)&0xff]<<8|infernobtox11[(v>>0)&0xff]<<0;
*wp++ = w;
}
dp += dx;
@@ -313,6 +313,33 @@ copy32to32(Rectangle r)
}
static void
+copy16to16(Rectangle r)
+{
+ int dx, width;
+ u16int *dp, *wp, *edp, *lp;
+
+ width = Dx(r);
+ dx = Xsize - width;
+ dp = (u16int*)(gscreendata + ((r.min.y * Xsize) + r.min.x) * 2);
+ wp = (u16int*)(xscreendata + ((r.min.y * Xsize) + r.min.x) * 2);
+ edp = (u16int*)(gscreendata + ((r.max.y * Xsize) + r.max.x) * 2);
+
+ /* The pixel format should be the same as the underlying X display (see
+ the xtruevisual function) unless a different channel format is
+ explicitly specified on the command line, so just copy the pixel data
+ without any processing. */
+
+ while(dp < edp) {
+ lp = dp + width;
+ while(dp < lp){
+ *wp++ = *dp++;
+ }
+ dp += dx;
+ wp += dx;
+ }
+}
+
+static void
copy8to32(Rectangle r)
{
int dx, width;
@@ -435,6 +462,17 @@ flushmemscreen(Rectangle r)
case 32:
copy32to32(r);
break;
+ case 16:
+ switch(xscreendepth){
+ case 16:
+ copy16to16(r);
+ break;
+ default:
+ fprint(2, "emu: bad display depth %d chan %s xscreendepth %d\n", displaydepth,
+ chantostr(chanbuf, displaychan), xscreendepth);
+ cleanexit(0);
+ }
+ break;
case 8:
switch(xscreendepth){
case 24:
diff --git a/lib/emptydirs b/lib/emptydirs
index 9fbf988d..10234dc1 100644
--- a/lib/emptydirs
+++ b/lib/emptydirs
@@ -1,3 +1,4 @@
+AIX/power/lib
FreeBSD/386/lib
Inferno/386/bin
Inferno/386/lib
diff --git a/lib9/getcallerpc-AIX-power.c b/lib9/getcallerpc-AIX-power.c
new file mode 100644
index 00000000..4a4e4fb5
--- /dev/null
+++ b/lib9/getcallerpc-AIX-power.c
@@ -0,0 +1,12 @@
+#include <lib9.h>
+
+ulong
+getcallerpc(void *x)
+{
+ulong *lp;
+
+ lp = x;
+
+ return lp[-1];
+}
+
diff --git a/lib9/getcallerpc-NetBSD-386.S b/lib9/getcallerpc-NetBSD-386.S
index 09148627..08ea057e 100644
--- a/lib9/getcallerpc-NetBSD-386.S
+++ b/lib9/getcallerpc-NetBSD-386.S
@@ -1,8 +1,7 @@
- .file "getcallerpc-NetBSD-386.S"
+#include <machine/asm.h>
- .type getcallerpc,@function
- .global getcallerpc
-getcallerpc:
+NENTRY(getcallerpc)
movl 4(%esp), %eax
movl -4(%eax), %eax
ret
+ END(getcallerpc)
diff --git a/lib9/getcallerpc-NetBSD-power.S b/lib9/getcallerpc-NetBSD-power.S
new file mode 100644
index 00000000..cacbbc11
--- /dev/null
+++ b/lib9/getcallerpc-NetBSD-power.S
@@ -0,0 +1,6 @@
+#include <machine/asm.h>
+
+ENTRY_NOPROFILE(getcallerpc)
+ mflr %r3
+ blr
+ END(getcallerpc)
diff --git a/lib9/setfcr-AIX-power.c b/lib9/setfcr-AIX-power.c
new file mode 100644
index 00000000..60939a27
--- /dev/null
+++ b/lib9/setfcr-AIX-power.c
@@ -0,0 +1,39 @@
+#include "lib9.h"
+
+ulong
+getfcr(void)
+{
+ double fpscr;
+
+ fpscr = __readflm();
+ return ((ulong*)&fpscr)[1];
+}
+
+ulong
+getfsr(void)
+{
+ double fpscr;
+
+ fpscr = __readflm();
+ return ((ulong*)&fpscr)[1];
+}
+
+void
+setfsr(ulong fsr)
+{
+ double fpscr;
+
+ fpscr = __readflm();
+ (((ulong*)&fpscr)[1]) = fsr;
+ __setflm(fpscr);
+}
+
+void
+setfcr(ulong fcr)
+{
+ double fpscr;
+
+ fpscr = __readflm();
+ (((ulong*)&fpscr)[1]) = fcr;
+ __setflm(fpscr);
+}
diff --git a/lib9/setfcr-Linux-power.S b/lib9/setfcr-Linux-power.S
index 6a2acfa0..f6bd7433 100644
--- a/lib9/setfcr-Linux-power.S
+++ b/lib9/setfcr-Linux-power.S
@@ -3,13 +3,13 @@
FN(getfcr):
mffs %f0
- stfdu %f0,-16(%r1)
+ stfd %f0,-16(%r1)
lw %r3,-12(%r1)
blr
FN(getfsr):
mffs %f0
- stfdu %f0,-16(%r1)
+ stfd %f0,-16(%r1)
lw %r3,-12(%r1)
blr
diff --git a/lib9/setfcr-NetBSD-386.S b/lib9/setfcr-NetBSD-386.S
index d981f36a..06a6b78d 100644
--- a/lib9/setfcr-NetBSD-386.S
+++ b/lib9/setfcr-NetBSD-386.S
@@ -1,18 +1,18 @@
+#include <machine/asm.h>
-#define FN(x) .type x,@function; .global x; x
#define ENT subl $16, %esp
#define RET addl $16, %esp; ret
- .file "setfcr-Linux-386.S"
-FN(setfcr):
+NENTRY(setfcr)
ENT
xorb $0x3f, %al
movl %eax, (%esp)
fwait
fldcw (%esp)
RET
+ END(setfcr)
-FN(getfcr):
+NENTRY(getfcr)
ENT
fwait
fstcw (%esp)
@@ -20,15 +20,18 @@ FN(getfcr):
andl $0xffff, %eax
xorb $0x3f, %al
RET
+ END(getfcr)
-FN(getfsr):
+NENTRY(getfsr)
ENT
fwait
fstsw (%esp)
movw (%esp), %ax
andl $0xffff, %eax
RET
+ END(getfsr)
-FN(setfsr):
+NENTRY(setfsr)
fclex
ret
+ END(setfsr)
diff --git a/lib9/setfcr-NetBSD-power.S b/lib9/setfcr-NetBSD-power.S
new file mode 100644
index 00000000..820fb29f
--- /dev/null
+++ b/lib9/setfcr-NetBSD-power.S
@@ -0,0 +1,33 @@
+#include <machine/asm.h>
+
+ENTRY_NOPROFILE(getfcr)
+ mffs %f0
+ stfd %f0,-16(%r1)
+ lwz %r3,-12(%r1)
+ blr
+ END(getfcr)
+
+ENTRY_NOPROFILE(getfsr)
+ mffs %f0
+ stfd %f0,-16(%r1)
+ lwz %r3,-12(%r1)
+ blr
+ END(getfsr)
+
+ENTRY_NOPROFILE(setfsr)
+ sync
+ stw %r3,-12(%r1)
+ lfd %f0,-16(%r1)
+ mtfsf 0xff, %f0
+ isync
+ blr
+ END(setfsr)
+
+ENTRY_NOPROFILE(setfcr)
+ sync
+ stw %r3,-12(%r1)
+ lfd %f0,-16(%r1)
+ mtfsf 0xff, %f0
+ isync
+ blr
+ END(setfcr)
diff --git a/lib9/setfcr-OpenBSD-386.S b/lib9/setfcr-OpenBSD-386.S
new file mode 100644
index 00000000..d981f36a
--- /dev/null
+++ b/lib9/setfcr-OpenBSD-386.S
@@ -0,0 +1,34 @@
+
+#define FN(x) .type x,@function; .global x; x
+#define ENT subl $16, %esp
+#define RET addl $16, %esp; ret
+
+ .file "setfcr-Linux-386.S"
+FN(setfcr):
+ ENT
+ xorb $0x3f, %al
+ movl %eax, (%esp)
+ fwait
+ fldcw (%esp)
+ RET
+
+FN(getfcr):
+ ENT
+ fwait
+ fstcw (%esp)
+ movw (%esp), %ax
+ andl $0xffff, %eax
+ xorb $0x3f, %al
+ RET
+
+FN(getfsr):
+ ENT
+ fwait
+ fstsw (%esp)
+ movw (%esp), %ax
+ andl $0xffff, %eax
+ RET
+
+FN(setfsr):
+ fclex
+ ret
diff --git a/libinterp/comp-power.c b/libinterp/comp-power.c
index a53b0bf8..993542d7 100644
--- a/libinterp/comp-power.c
+++ b/libinterp/comp-power.c
@@ -31,6 +31,10 @@
#define MFSPR(s, d) gen(XO(31,339) | ((d)<<21) | ((s)<<11))
#define MTSPR(s, d) gen(XO(31,467) | ((s)<<21) | ((d)<<11));
+#define MFCR(d) gen(XO(31,19) | ((d)<<21))
+#define MTCRF(s, mask) gen(XO(31,144) | ((s)<<21) | ((mask)<<12))
+#define MTCR(s) MTCRF(s, 0xff)
+
#define SLWI(d,a,n) gen(slw((d),(a),(n),0))
#define LRET() gen(Oblr)
@@ -1636,7 +1640,7 @@ comp(Inst *i)
}
enum {
- PREFLEN = 20, /* max instruction words in comvec */
+ PREFLEN = 64, /* max instruction words in comvec */
};
static void
@@ -1649,6 +1653,45 @@ preamble(void)
s = code = malloc(PREFLEN*sizeof(*code));
if(s == nil)
error(exNomem);
+
+#ifdef __ELF__
+ if(macjit) {
+ ulong *cp;
+ int r;
+
+ /*
+ * ELF frame:
+ * 0(%sp) - back chain
+ * 4(%sp) - callee's LR save slot
+ * 8(%sp) to 36(%sp) - 8 words of parameter list area
+ * 40(%sp) to 48(%sp) - pad to 16 byte alignment/local vars
+ */
+ mfspr(Ro1, Rlr);
+ AIRR(Ostw, Ro1, Rsp,4);
+ AIRR(Ostwu, Rsp, Rsp,-128);
+
+ MFCR(Ro1);
+ AIRR(Ostw, Ro1, Rsp,52);
+ for (r = 14; r < 32; ++r)
+ AIRR(Ostw, r, Rsp,r*4);
+
+ cp = code;
+ gen(Ob | Lk);
+
+ AIRR(Olwz, Ro1, Rsp,52);
+ MTCR(Ro1);
+ for (r = 14; r < 32; ++r)
+ AIRR(Olwz, r, Rsp,r*4);
+ AIRR(Oaddi, Rsp, Rsp, 128);
+
+ AIRR(Olwz, Ro1, Rsp,4);
+ mtspr(Rlr, Ro1);
+ LRET();
+
+ PATCH(cp);
+ }
+#endif /* __ELF__ */
+
ldc((ulong)&R, Rreg);
SETR0();
mfspr(Rlink, Rlr);
diff --git a/libmath/FPcontrol-AIX.c b/libmath/FPcontrol-AIX.c
new file mode 100644
index 00000000..180c8bde
--- /dev/null
+++ b/libmath/FPcontrol-AIX.c
@@ -0,0 +1,77 @@
+#include "lib9.h"
+#include "mathi.h"
+
+void
+FPinit(void)
+{
+ setfsr(0); /* Clear pending exceptions */
+ setfcr(FPPDBL|FPRNR|FPINVAL|FPZDIV|FPUNFL|FPOVFL);
+}
+
+ulong
+getFPstatus(void)
+{
+ ulong fsr = 0, fsr9 = getfsr();
+ /* on specific machines, could be table lookup */
+ if(fsr9&FPAINEX) fsr |= INEX;
+ if(fsr9&FPAOVFL) fsr |= OVFL;
+ if(fsr9&FPAUNFL) fsr |= UNFL;
+ if(fsr9&FPAZDIV) fsr |= ZDIV;
+ if(fsr9&FPAINVAL) fsr |= INVAL;
+ return fsr;
+}
+
+ulong
+FPstatus(ulong fsr, ulong mask)
+{
+ ulong fsr9 = 0;
+ ulong old = getFPstatus();
+ fsr = (fsr&mask) | (old&~mask);
+ if(fsr&INEX) fsr9 |= FPAINEX;
+ if(fsr&OVFL) fsr9 |= FPAOVFL;
+ if(fsr&UNFL) fsr9 |= FPAUNFL;
+ if(fsr&ZDIV) fsr9 |= FPAZDIV;
+ if(fsr&INVAL) fsr9 |= FPAINVAL;
+ setfsr(fsr9);
+ return(old&mask);
+}
+
+ulong
+getFPcontrol(void)
+{
+ ulong fcr = 0, fcr9 = getfcr();
+ switch(fcr9&FPRMASK){
+ case FPRNR: fcr = RND_NR; break;
+ case FPRNINF: fcr = RND_NINF; break;
+ case FPRPINF: fcr = RND_PINF; break;
+ case FPRZ: fcr = RND_Z; break;
+ }
+ if(fcr9&FPINEX) fcr |= INEX;
+ if(fcr9&FPOVFL) fcr |= OVFL;
+ if(fcr9&FPUNFL) fcr |= UNFL;
+ if(fcr9&FPZDIV) fcr |= ZDIV;
+ if(fcr9&FPINVAL) fcr |= INVAL;
+ return fcr;
+}
+
+ulong
+FPcontrol(ulong fcr, ulong mask)
+{
+ ulong fcr9 = FPPDBL;
+ ulong old = getFPcontrol();
+ fcr = (fcr&mask) | (old&~mask);
+ if(fcr&INEX) fcr9 |= FPINEX;
+ if(fcr&OVFL) fcr9 |= FPOVFL;
+ if(fcr&UNFL) fcr9 |= FPUNFL;
+ if(fcr&ZDIV) fcr9 |= FPZDIV;
+ if(fcr&INVAL) fcr9 |= FPINVAL;
+ switch(fcr&RND_MASK){
+ case RND_NR: fcr9 |= FPRNR; break;
+ case RND_NINF: fcr9 |= FPRNINF; break;
+ case RND_PINF: fcr9 |= FPRPINF; break;
+ case RND_Z: fcr9 |= FPRZ; break;
+ }
+ setfcr(fcr9);
+ return(old&mask);
+}
+
diff --git a/libmemdraw/mkfile-AIX b/libmemdraw/mkfile-AIX
new file mode 100644
index 00000000..a83c8dfe
--- /dev/null
+++ b/libmemdraw/mkfile-AIX
@@ -0,0 +1 @@
+<mkfile-Inferno
diff --git a/libmemlayer/mkfile-AIX b/libmemlayer/mkfile-AIX
new file mode 100644
index 00000000..d772cd4e
--- /dev/null
+++ b/libmemlayer/mkfile-AIX
@@ -0,0 +1,4 @@
+#
+# System dependent objects for Posix model systems
+#
+SYSFILES=lalloc.$O
diff --git a/limbo/lex.c b/limbo/lex.c
index d75e28f2..c6af1988 100644
--- a/limbo/lex.c
+++ b/limbo/lex.c
@@ -1434,7 +1434,7 @@ allocmem(ulong n)
{
void *p;
- p = malloc(n);
+ p = malloc(n != 0? n: 1);
if(p == nil)
fatal("out of memory");
return p;
diff --git a/limbo/limbo.y b/limbo/limbo.y
index a6ccab90..f869f01c 100644
--- a/limbo/limbo.y
+++ b/limbo/limbo.y
@@ -582,13 +582,13 @@ ftype : nids ':' type
{
$$ = mkids(&$1->src, enter("junk", 0), $3, nil);
$$->store = Darg;
- yyerror("illegal argument declaraion");
+ yyerror("illegal argument declaration");
}
| idterms ':' adtk
{
$$ = mkids(&$1->src, enter("junk", 0), $3, nil);
$$->store = Darg;
- yyerror("illegal argument declaraion");
+ yyerror("illegal argument declaration");
}
;
diff --git a/limbo/types.c b/limbo/types.c
index 6d231115..c8105d5a 100644
--- a/limbo/types.c
+++ b/limbo/types.c
@@ -2024,7 +2024,7 @@ cycfield(Type *base, Decl *id)
id->sym->name, base);
id->cycerr = 1;
}else if(arc & ArcCyc){
- if((arc & ArcArray) && id->cyc == 0 && !(arc & ArcPolycyc)){
+ if((arc & ArcArray) && oldcycles && id->cyc == 0 && !(arc & ArcPolycyc)){
if(id->cycerr == 0)
error(base->src.start, "illegal circular reference to type %T in field %s of %t",
id->ty, id->sym->name, base);
@@ -3466,7 +3466,7 @@ expandtype(Type *t, Type *instt, Decl *adtt, Tpair **tp)
if(t == nil)
return nil;
-if(debug['w']) print("expandtype %d %lux %T\n", t->kind, (ulong)t, t);
+if(debug['w']) print("expandtype %d %#p %T\n", t->kind, t, t);
if(!toccurs(t, tp))
return t;
if(debug['w']) print("\texpanding\n");
diff --git a/makemk-AIX.sh b/makemk-AIX.sh
new file mode 100644
index 00000000..51745b1d
--- /dev/null
+++ b/makemk-AIX.sh
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+# this file is used only to bootstrap mk onto a platform
+# that currently lacks a binary for mk. after that, mk can
+# look after itself.
+
+# support@vitanuova.com
+
+# change these defines as appropriate here or in mkconfig
+# ROOT should be the root of the Inferno tree
+ROOT=/usr/inferno
+SYSTARG=AIX
+OBJTYPE=power
+SYSTYPE=posix
+
+# if you have already changed mkconfig from the distribution, we'll use the definitions from that
+grep -s 'SYSTARG=Plan9' mkconfig || . ./mkconfig
+
+PLAT=$ROOT/$SYSTARG/$OBJTYPE
+
+# you might need to adjust the CC, LD, AR, and RANLIB definitions after this point
+CC="p xlc -g -O -qsuppress=1506-224 -c -I$PLAT/include -I$ROOT/include -I$ROOT/utils/include"
+LD="p xlc"
+AR="p ar crvs"
+RANLIB=":" # some systems still require `ranlib'
+
+error() {
+ echo $* >&2
+ exit 1
+}
+
+ofiles() {
+ echo $* | sed 's/\.c/.o/g'
+}
+
+p() {
+ echo $*
+ "$@"
+}
+
+# make sure we start off clean
+echo removing old libraries and binaries
+rm -f $PLAT/lib/*.a $PLAT/bin/*
+rm -f utils/cc/y.tab.?
+
+# ensure the output directories exist
+mkdir -p $PLAT/lib $PLAT/bin
+
+# libregexp
+cd $ROOT/utils/libregexp || error cannot find libregexp directory
+CFILES="regaux.c regcomp.c regerror.c regexec.c regsub.c rregexec.c rregsub.c"
+$CC $CFILES || error libregexp compilation failed
+$AR $PLAT/lib/libregexp.a `ofiles $CFILES` || error libregexp ar failed
+$RANLIB $PLAT/lib/libregexp.a || error libregexp ranlib failed
+
+# libbio
+cd $ROOT/libbio || error cannot find libbio directory
+$CC *.c || error libbio compilation failed
+$AR $PLAT/lib/libbio.a *.o || error libbio ar failed
+$RANLIB $PLAT/lib/libbio.a || error libbio ranlib failed
+
+# lib9
+cd $ROOT/lib9 || error cannot find lib9 directory
+CFILES="dirstat-$SYSTYPE.c rerrstr.c errstr-$SYSTYPE.c getuser-$SYSTYPE.c" # system specific
+CFILES="$CFILES charstod.c cleanname.c create.c dirwstat.c *print*.c *fmt*.c exits.c getfields.c pow10.c print.c qsort.c rune.c runestrlen.c seek.c strdup.c strtoll.c utflen.c utfrrune.c utfrune.c utf*.c *str*cpy*.c"
+$CC $CFILES || error lib9 compilation failed
+$AR $PLAT/lib/lib9.a `ofiles $CFILES` || error lib9 ar failed
+$RANLIB $PLAT/lib/lib9.a || error lib9 ranlib failed
+
+# mk itself
+cd $ROOT/utils/mk
+CFILES="Posix.c sh.c" # system specific
+CFILES="$CFILES arc.c archive-AIX.c bufblock.c env.c file.c graph.c job.c lex.c main.c match.c mk.c parse.c recipe.c rule.c run.c shprint.c symtab.c var.c varsub.c word.c"
+$CC $CFILES || error mk compilation failed
+$LD -o mk `ofiles $CFILES` $PLAT/lib/libregexp.a $PLAT/lib/libbio.a $PLAT/lib/lib9.a || error mk link failed
+cp mk $PLAT/bin || error mk binary install failed
+
+echo mk binary built successfully!
diff --git a/man/1/m4 b/man/1/m4
index ef0670a3..08a50990 100644
--- a/man/1/m4
+++ b/man/1/m4
@@ -4,6 +4,12 @@ m4 \- macro processor
.SH SYNOPSIS
.B m4
[
+.BI -p prefix
+]
+[
+.B -t
+]
+[
.BI -D name = value
] [
.BI -Q name = value
@@ -236,7 +242,20 @@ Text may be undiverted into another diversion.
Undiverting discards the diverted text.
.PD
.PP
+The
+.B -p
+option causes
+.I m4
+to add the given prefix character to the names of predefined macros;
+typically the
+.I prefix
+is a Unicode character, to reduce the chance of a clash with macro names in the input text.
+The
+.B -t
+option produces a trace on standard error.
+.PP
.I M4
+otherwise
interprets its command line options after installing the predefined macro set.
The
.B -D
diff --git a/mkconfig b/mkconfig
index 08fc3a8c..f189dca6 100644
--- a/mkconfig
+++ b/mkconfig
@@ -14,8 +14,8 @@ TKSTYLE=std
#
# Except for building kernels, SYSTARG must always be the same as SYSHOST
#
-SYSHOST=Plan9 # build system OS type (Hp, Inferno, Irix, Linux, MacOSX, Nt, Plan9, Solaris)
-SYSTARG=$SYSHOST # target system OS type (Hp, Inferno, Irix, Linux, Nt, Plan9, Solaris)
+SYSHOST=Plan9 # build system OS type (AIX, Hp, Inferno, Irix, Linux, MacOSX, Nt, Plan9, Solaris)
+SYSTARG=$SYSHOST # target system OS type (AIX, Hp, Inferno, Irix, Linux, Nt, Plan9, Solaris)
#
# specify the architecture of the target system - Plan 9 imports it from the
diff --git a/mkfiles/mkfile-AIX-power b/mkfiles/mkfile-AIX-power
new file mode 100644
index 00000000..3faf4286
--- /dev/null
+++ b/mkfiles/mkfile-AIX-power
@@ -0,0 +1,25 @@
+TARGMODEL= Posix
+TARGSHTYPE= sh
+CPUS= power
+
+O= o
+OS= o
+
+AR= ar
+ARFLAGS= crvs
+
+AS= xlc -c
+ASFLAGS=
+
+CC= xlc_r -c
+CFLAGS= -q32 -g -O -qsuppress=1506-224\
+ -I$ROOT/$SYSTARG/$OBJTYPE/include\
+ -I$ROOT/include\
+
+ANSICPP=
+LD= xlc_r
+LDFLAGS= -bmaxdata:0x80000000
+SYSLIBS= -lm
+
+YACC= iyacc
+YFLAGS= -d
diff --git a/mkfiles/mkfile-NetBSD-386 b/mkfiles/mkfile-NetBSD-386
index 46d633d9..99ae6687 100644
--- a/mkfiles/mkfile-NetBSD-386
+++ b/mkfiles/mkfile-NetBSD-386
@@ -14,6 +14,7 @@ ASFLAGS=
CC= cc -c
CFLAGS= -g\
-O\
+ -fno-strict-aliasing\
-Wno-deprecated-declarations -Wuninitialized -Wunused -Wreturn-type -Wimplicit\
-I$ROOT/NetBSD/386/include\
-I$ROOT/include\
diff --git a/mkfiles/mkfile-NetBSD-power b/mkfiles/mkfile-NetBSD-power
new file mode 100644
index 00000000..1ac7e58e
--- /dev/null
+++ b/mkfiles/mkfile-NetBSD-power
@@ -0,0 +1,30 @@
+TARGMODEL= Posix
+TARGSHTYPE= sh
+CPUS= power
+
+O= o
+OS= o
+
+AR= ar
+ARFLAGS= ruvs
+
+AS= cc -c
+ASFLAGS=
+
+CC= cc -c
+CFLAGS= -g\
+ -O\
+ -fno-strict-aliasing\
+ -Wno-deprecated-declarations -Wuninitialized -Wunused -Wreturn-type -Wimplicit\
+ -I$ROOT/NetBSD/power/include\
+ -I$ROOT/include\
+ -I/usr/X11R7/include
+
+ANSICPP=
+LD= cc
+LDFLAGS=
+
+SYSLIBS=
+
+YACC= iyacc
+YFLAGS= -d
diff --git a/mkfiles/mkhost-AIX b/mkfiles/mkhost-AIX
new file mode 100644
index 00000000..3c1a86c3
--- /dev/null
+++ b/mkfiles/mkhost-AIX
@@ -0,0 +1,14 @@
+
+# Variables for host system type = AIX
+
+SHELLTYPE= sh
+SHELLNAME= /bin/sh
+HOSTMODEL= Posix
+OSTARG= os
+
+DATA2S= data2s
+NDATE= ndate
+KSIZE= ksize
+AWK= awk
+
+MKAR= archive-$SYSTARG
diff --git a/module/draw.m b/module/draw.m
index 730e62ac..a9dabd8f 100644
--- a/module/draw.m
+++ b/module/draw.m
@@ -91,7 +91,7 @@ Draw: module
RGB15: con Chans(((CIgnore<<4)|1)<<24 | ((CRed<<4)|5)<<16 | ((CGreen<<4)|5)<<8 | ((CBlue<<4)|5));
RGB16: con Chans(((CRed<<4)|5)<<16 | ((CGreen<<4)|6)<<8 | ((CBlue<<4)|5));
RGB24: con Chans(((CRed<<4)|8)<<16 | ((CGreen<<4)|8)<<8 | ((CBlue<<4)|8));
- RGBA32: con Chans((((CRed<<4)|8)<<16 | ((CGreen<<4)|8)<<8 | ((CBlue<<4)|8))<<8 | ((CAlpha<<4)|8));
+ RGBA32: con Chans((((CRed<<4)|8)<<24 | ((CGreen<<4)|8)<<16 | ((CBlue<<4)|8))<<8 | ((CAlpha<<4)|8));
ARGB32: con Chans(((CAlpha<<4)|8)<<24 | ((CRed<<4)|8)<<16 | ((CGreen<<4)|8)<<8 | ((CBlue<<4)|8)); # stupid VGAs
XRGB32: con Chans(((CIgnore<<4)|8)<<24 | ((CRed<<4)|8)<<16 | ((CGreen<<4)|8)<<8 | ((CBlue<<4)|8)); # stupid VGAs
diff --git a/services/webget/smallinferno.gif b/services/webget/smallinferno.gif
new file mode 100644
index 00000000..07fac5a3
--- /dev/null
+++ b/services/webget/smallinferno.gif
Binary files differ
diff --git a/utils/8l/l.h b/utils/8l/l.h
index da151014..85964bc3 100644
--- a/utils/8l/l.h
+++ b/utils/8l/l.h
@@ -195,7 +195,7 @@ EXTERN union
uchar obuf[MAXIO]; /* output buffer */
uchar ibuf[MAXIO]; /* input buffer */
} u;
- char dbuf[1];
+ char dbuf[2*MAXIO];
} buf;
#define cbuf u.obuf
@@ -236,8 +236,8 @@ EXTERN char debug[128];
EXTERN char literal[32];
EXTERN Prog* etextp;
EXTERN Prog* firstp;
-EXTERN char fnuxi8[8];
-EXTERN char fnuxi4[4];
+EXTERN uchar fnuxi8[8];
+EXTERN uchar fnuxi4[4];
EXTERN Sym* hash[NHASH];
EXTERN Sym* histfrog[MAXHIST];
EXTERN int histfrogp;
@@ -247,9 +247,9 @@ EXTERN char* libraryobj[50];
EXTERN int libraryp;
EXTERN int xrefresolv;
EXTERN char* hunk;
-EXTERN char inuxi1[1];
-EXTERN char inuxi2[2];
-EXTERN char inuxi4[4];
+EXTERN uchar inuxi1[1];
+EXTERN uchar inuxi2[2];
+EXTERN uchar inuxi4[4];
EXTERN char ycover[Ymax*Ymax];
EXTERN uchar* andptr;
EXTERN uchar and[30];
diff --git a/utils/mk/archive-AIX.c b/utils/mk/archive-AIX.c
new file mode 100644
index 00000000..a4327a96
--- /dev/null
+++ b/utils/mk/archive-AIX.c
@@ -0,0 +1,203 @@
+#include "mk.h"
+#include <ar.h>
+
+static int dolong;
+
+static void atimes(char *);
+static char *split(char*, char**);
+
+long
+atimeof(int force, char *name)
+{
+ Symtab *sym;
+ long t;
+ char *archive, *member, buf[512];
+
+ archive = split(name, &member);
+ if(archive == 0)
+ Exit();
+
+ t = mtime(archive);
+ sym = symlook(archive, S_AGG, 0);
+ if(sym){
+ if(force || (t > (long)sym->value)){
+ atimes(archive);
+ sym->value = (void *)t;
+ }
+ }
+ else{
+ atimes(archive);
+ /* mark the aggegate as having been done */
+ symlook(strdup(archive), S_AGG, "")->value = (void *)t;
+ }
+ snprint(buf, sizeof(buf), "%s(%s)", archive, member);
+ sym = symlook(buf, S_TIME, 0);
+ if (sym)
+ return (long)sym->value; /* uggh */
+ return 0;
+}
+
+void
+atouch(char *name)
+{
+ char *archive, *member;
+ int fd, i, namelen;
+ struct fl_hdr g;
+ struct ar_hdr h;
+ long t;
+ char memname[256];
+
+ archive = split(name, &member);
+ if(archive == 0)
+ Exit();
+
+ fd = open(archive, ORDWR);
+ if(fd < 0){
+ fd = create(archive, OWRITE, 0666);
+ if(fd < 0){
+ perror(archive);
+ Exit();
+ }
+ write(fd, ARMAG, SARMAG);
+ for(i = 0; i < 6; i++)
+ fprint(fd, "%-20ld", 0);
+ }
+ if(symlook(name, S_TIME, 0)){
+ /* hoon off and change it in situ */
+ LSEEK(fd, 0, 0);
+ if(read(fd, &g, SAR_FLHDR) != SAR_FLHDR){
+ close(fd);
+ return;
+ }
+ t = atol(g.fstmoff);
+ if(t == 0){
+ close(fd);
+ return;
+ }
+ for(;;){
+ LSEEK(fd, t, 0);
+ if(read(fd, (char *)&h, SAR_HDR) != SAR_HDR)
+ break;
+
+ namelen = atol(h.namlen);
+ if(namelen == 0 || namelen >= sizeof memname){
+ namelen = 0;
+ goto skip;
+ }
+ if(read(fd, memname, namelen) != namelen)
+ break;
+ memname[namelen] = 0;
+
+ if(strcmp(member, memname) == 0){
+ snprint(h.date, sizeof(h.date), "%-12ld", time(0));
+ LSEEK(fd, t, 0);
+ write(fd, (char *)&h, SAR_HDR);
+ break;
+ }
+ skip:
+ t = atol(h.nxtmem);
+ if(t == 0)
+ break;
+ }
+ }
+ close(fd);
+}
+
+static void
+atimes(char *ar)
+{
+ struct fl_hdr g;
+ struct ar_hdr h;
+ long o, t;
+ int fd, i, namelen;
+ char buf[2048], *p, *strings;
+ char name[1024];
+ Symtab *sym;
+
+ strings = nil;
+ fd = open(ar, OREAD);
+ if(fd < 0)
+ return;
+
+ if(read(fd, &g, SAR_FLHDR) != SAR_FLHDR){
+ close(fd);
+ return;
+ }
+ o = atol(g.fstmoff);
+ if(o == 0){
+ close(fd);
+ return;
+ }
+ for(;;){
+ LSEEK(fd, o, 0);
+ if(read(fd, (char *)&h, SAR_HDR) != SAR_HDR)
+ break;
+
+ t = atol(h.date);
+ if(t == 0) /* as it sometimes happens; thanks ken */
+ t = 1;
+
+ namelen = atol(h.namlen);
+ if(namelen == 0 || namelen >= sizeof name){
+ namelen = 0;
+ goto skip;
+ }
+ if(read(fd, name, namelen) != namelen)
+ break;
+ name[namelen] = 0;
+
+ snprint(buf, sizeof buf, "%s(%s)", ar, name);
+ sym = symlook(strdup(buf), S_TIME, (void *)t);
+ sym->value = (void *)t;
+ skip:
+ o = atol(h.nxtmem);
+ if(o == 0)
+ break;
+ }
+ close(fd);
+ free(strings);
+}
+
+static int
+type(char *file)
+{
+ int fd;
+ char buf[SARMAG];
+
+ fd = open(file, OREAD);
+ if(fd < 0){
+ if(symlook(file, S_BITCH, 0) == 0){
+ Bprint(&bout, "%s doesn't exist: assuming it will be an archive\n", file);
+ symlook(file, S_BITCH, (void *)file);
+ }
+ return 1;
+ }
+ if(read(fd, buf, SARMAG) != SARMAG){
+ close(fd);
+ return 0;
+ }
+ close(fd);
+ return strncmp(ARMAG, buf, SARMAG) == 0;
+}
+
+static char*
+split(char *name, char **member)
+{
+ char *p, *q;
+
+ p = strdup(name);
+ q = utfrune(p, '(');
+ if(q){
+ *q++ = 0;
+ if(member)
+ *member = q;
+ q = utfrune(q, ')');
+ if (q)
+ *q = 0;
+ if(type(p))
+ return p;
+ free(p);
+ fprint(2, "mk: '%s' is not an archive\n", name);
+ }
+ return 0;
+}
diff --git a/utils/mk/mkfile b/utils/mk/mkfile
index 9d4deea8..2aecf006 100644
--- a/utils/mk/mkfile
+++ b/utils/mk/mkfile
@@ -1,9 +1,11 @@
+MKAR= archive
+
<../../mkconfig
TARG=mk
OFILES= arc.$O\
- archive.$O\
+ $MKAR.$O\
bufblock.$O\
env.$O\
file.$O\