aboutsummaryrefslogtreecommitdiff
path: root/Nt
diff options
context:
space:
mode:
Diffstat (limited to 'Nt')
-rw-r--r--Nt/386/bin/5a.exebin0 -> 131072 bytes
-rw-r--r--Nt/386/bin/5c.exebin0 -> 287232 bytes
-rw-r--r--Nt/386/bin/5coff.exebin0 -> 257536 bytes
-rw-r--r--Nt/386/bin/5cv.exebin0 -> 249344 bytes
-rw-r--r--Nt/386/bin/5l.exebin0 -> 156160 bytes
-rw-r--r--Nt/386/bin/8a.exebin0 -> 129024 bytes
-rw-r--r--Nt/386/bin/8c.exebin0 -> 315904 bytes
-rw-r--r--Nt/386/bin/8l.exebin0 -> 153600 bytes
-rw-r--r--Nt/386/bin/acid.exebin0 -> 343552 bytes
-rw-r--r--Nt/386/bin/awk.exebin0 -> 272896 bytes
-rw-r--r--Nt/386/bin/c2l.exebin0 -> 244736 bytes
-rw-r--r--Nt/386/bin/cat.exebin0 -> 56832 bytes
-rw-r--r--Nt/386/bin/cp.exebin0 -> 70656 bytes
-rw-r--r--Nt/386/bin/data2c.exebin0 -> 59392 bytes
-rw-r--r--Nt/386/bin/data2s.exebin0 -> 59392 bytes
-rw-r--r--Nt/386/bin/echo.exebin0 -> 50176 bytes
-rw-r--r--Nt/386/bin/emu.exebin0 -> 1488384 bytes
-rw-r--r--Nt/386/bin/format.exebin0 -> 78848 bytes
-rw-r--r--Nt/386/bin/ftl.exebin0 -> 71168 bytes
-rw-r--r--Nt/386/bin/gzip.exebin0 -> 90112 bytes
-rw-r--r--Nt/386/bin/iar.exebin0 -> 100864 bytes
-rw-r--r--Nt/386/bin/idea.exebin0 -> 61440 bytes
-rw-r--r--Nt/386/bin/infdb.exebin0 -> 88064 bytes
-rw-r--r--Nt/386/bin/inm.exebin0 -> 114176 bytes
-rw-r--r--Nt/386/bin/iyacc.exebin0 -> 95232 bytes
-rw-r--r--Nt/386/bin/ka.exebin0 -> 133632 bytes
-rw-r--r--Nt/386/bin/kc.exebin0 -> 277504 bytes
-rw-r--r--Nt/386/bin/kl.exebin0 -> 142336 bytes
-rw-r--r--Nt/386/bin/kprof.exebin0 -> 102912 bytes
-rw-r--r--Nt/386/bin/ksize.exebin0 -> 84992 bytes
-rw-r--r--Nt/386/bin/kstrip.exebin0 -> 85504 bytes
-rw-r--r--Nt/386/bin/limbo.exebin0 -> 381952 bytes
-rw-r--r--Nt/386/bin/md5sum.exebin0 -> 59904 bytes
-rw-r--r--Nt/386/bin/mk.exebin0 -> 166912 bytes
-rw-r--r--Nt/386/bin/mkdir.exebin0 -> 52224 bytes
-rw-r--r--Nt/386/bin/mkext.exebin0 -> 80384 bytes
-rw-r--r--Nt/386/bin/mkppcimage.exebin0 -> 60416 bytes
-rw-r--r--Nt/386/bin/ms2.exebin0 -> 88064 bytes
-rw-r--r--Nt/386/bin/mv.exebin0 -> 72192 bytes
-rw-r--r--Nt/386/bin/ndate.exebin0 -> 50176 bytes
-rw-r--r--Nt/386/bin/ntsrv.exebin0 -> 56320 bytes
-rw-r--r--Nt/386/bin/qa.exebin0 -> 148480 bytes
-rw-r--r--Nt/386/bin/qc.exebin0 -> 295936 bytes
-rw-r--r--Nt/386/bin/ql.exebin0 -> 180736 bytes
-rw-r--r--Nt/386/bin/rcsh.exebin0 -> 176640 bytes
-rw-r--r--Nt/386/bin/rm.exebin0 -> 64512 bytes
-rw-r--r--Nt/386/bin/sed.exebin0 -> 81408 bytes
-rw-r--r--Nt/386/bin/sqz.exebin0 -> 64512 bytes
-rw-r--r--Nt/386/bin/srclist.exebin0 -> 102912 bytes
-rw-r--r--Nt/386/bin/styxtest.exebin0 -> 78336 bytes
-rw-r--r--Nt/386/bin/test.exebin0 -> 67072 bytes
-rw-r--r--Nt/386/bin/tr.exebin0 -> 55808 bytes
-rw-r--r--Nt/386/bin/va.exebin0 -> 128512 bytes
-rw-r--r--Nt/386/bin/vc.exebin0 -> 281088 bytes
-rw-r--r--Nt/386/bin/vl.exebin0 -> 155136 bytes
-rw-r--r--Nt/386/include/emu.h29
-rw-r--r--Nt/386/include/lib9.h501
57 files changed, 530 insertions, 0 deletions
diff --git a/Nt/386/bin/5a.exe b/Nt/386/bin/5a.exe
new file mode 100644
index 0000000..759c228
--- /dev/null
+++ b/Nt/386/bin/5a.exe
Binary files differ
diff --git a/Nt/386/bin/5c.exe b/Nt/386/bin/5c.exe
new file mode 100644
index 0000000..4306250
--- /dev/null
+++ b/Nt/386/bin/5c.exe
Binary files differ
diff --git a/Nt/386/bin/5coff.exe b/Nt/386/bin/5coff.exe
new file mode 100644
index 0000000..19a4b20
--- /dev/null
+++ b/Nt/386/bin/5coff.exe
Binary files differ
diff --git a/Nt/386/bin/5cv.exe b/Nt/386/bin/5cv.exe
new file mode 100644
index 0000000..74974d4
--- /dev/null
+++ b/Nt/386/bin/5cv.exe
Binary files differ
diff --git a/Nt/386/bin/5l.exe b/Nt/386/bin/5l.exe
new file mode 100644
index 0000000..db64d87
--- /dev/null
+++ b/Nt/386/bin/5l.exe
Binary files differ
diff --git a/Nt/386/bin/8a.exe b/Nt/386/bin/8a.exe
new file mode 100644
index 0000000..cf3c4a7
--- /dev/null
+++ b/Nt/386/bin/8a.exe
Binary files differ
diff --git a/Nt/386/bin/8c.exe b/Nt/386/bin/8c.exe
new file mode 100644
index 0000000..5f39898
--- /dev/null
+++ b/Nt/386/bin/8c.exe
Binary files differ
diff --git a/Nt/386/bin/8l.exe b/Nt/386/bin/8l.exe
new file mode 100644
index 0000000..100a845
--- /dev/null
+++ b/Nt/386/bin/8l.exe
Binary files differ
diff --git a/Nt/386/bin/acid.exe b/Nt/386/bin/acid.exe
new file mode 100644
index 0000000..8f7f355
--- /dev/null
+++ b/Nt/386/bin/acid.exe
Binary files differ
diff --git a/Nt/386/bin/awk.exe b/Nt/386/bin/awk.exe
new file mode 100644
index 0000000..6cfc878
--- /dev/null
+++ b/Nt/386/bin/awk.exe
Binary files differ
diff --git a/Nt/386/bin/c2l.exe b/Nt/386/bin/c2l.exe
new file mode 100644
index 0000000..ee8df3d
--- /dev/null
+++ b/Nt/386/bin/c2l.exe
Binary files differ
diff --git a/Nt/386/bin/cat.exe b/Nt/386/bin/cat.exe
new file mode 100644
index 0000000..6e30bc0
--- /dev/null
+++ b/Nt/386/bin/cat.exe
Binary files differ
diff --git a/Nt/386/bin/cp.exe b/Nt/386/bin/cp.exe
new file mode 100644
index 0000000..c3a4d96
--- /dev/null
+++ b/Nt/386/bin/cp.exe
Binary files differ
diff --git a/Nt/386/bin/data2c.exe b/Nt/386/bin/data2c.exe
new file mode 100644
index 0000000..110cf9a
--- /dev/null
+++ b/Nt/386/bin/data2c.exe
Binary files differ
diff --git a/Nt/386/bin/data2s.exe b/Nt/386/bin/data2s.exe
new file mode 100644
index 0000000..7e13ebb
--- /dev/null
+++ b/Nt/386/bin/data2s.exe
Binary files differ
diff --git a/Nt/386/bin/echo.exe b/Nt/386/bin/echo.exe
new file mode 100644
index 0000000..70d9a0c
--- /dev/null
+++ b/Nt/386/bin/echo.exe
Binary files differ
diff --git a/Nt/386/bin/emu.exe b/Nt/386/bin/emu.exe
new file mode 100644
index 0000000..b7c827f
--- /dev/null
+++ b/Nt/386/bin/emu.exe
Binary files differ
diff --git a/Nt/386/bin/format.exe b/Nt/386/bin/format.exe
new file mode 100644
index 0000000..c11b833
--- /dev/null
+++ b/Nt/386/bin/format.exe
Binary files differ
diff --git a/Nt/386/bin/ftl.exe b/Nt/386/bin/ftl.exe
new file mode 100644
index 0000000..f1ff290
--- /dev/null
+++ b/Nt/386/bin/ftl.exe
Binary files differ
diff --git a/Nt/386/bin/gzip.exe b/Nt/386/bin/gzip.exe
new file mode 100644
index 0000000..54c02ae
--- /dev/null
+++ b/Nt/386/bin/gzip.exe
Binary files differ
diff --git a/Nt/386/bin/iar.exe b/Nt/386/bin/iar.exe
new file mode 100644
index 0000000..6b5c926
--- /dev/null
+++ b/Nt/386/bin/iar.exe
Binary files differ
diff --git a/Nt/386/bin/idea.exe b/Nt/386/bin/idea.exe
new file mode 100644
index 0000000..16dcc60
--- /dev/null
+++ b/Nt/386/bin/idea.exe
Binary files differ
diff --git a/Nt/386/bin/infdb.exe b/Nt/386/bin/infdb.exe
new file mode 100644
index 0000000..f34a0d7
--- /dev/null
+++ b/Nt/386/bin/infdb.exe
Binary files differ
diff --git a/Nt/386/bin/inm.exe b/Nt/386/bin/inm.exe
new file mode 100644
index 0000000..e21d4d2
--- /dev/null
+++ b/Nt/386/bin/inm.exe
Binary files differ
diff --git a/Nt/386/bin/iyacc.exe b/Nt/386/bin/iyacc.exe
new file mode 100644
index 0000000..9051f50
--- /dev/null
+++ b/Nt/386/bin/iyacc.exe
Binary files differ
diff --git a/Nt/386/bin/ka.exe b/Nt/386/bin/ka.exe
new file mode 100644
index 0000000..02164d4
--- /dev/null
+++ b/Nt/386/bin/ka.exe
Binary files differ
diff --git a/Nt/386/bin/kc.exe b/Nt/386/bin/kc.exe
new file mode 100644
index 0000000..42a2f4e
--- /dev/null
+++ b/Nt/386/bin/kc.exe
Binary files differ
diff --git a/Nt/386/bin/kl.exe b/Nt/386/bin/kl.exe
new file mode 100644
index 0000000..24b335f
--- /dev/null
+++ b/Nt/386/bin/kl.exe
Binary files differ
diff --git a/Nt/386/bin/kprof.exe b/Nt/386/bin/kprof.exe
new file mode 100644
index 0000000..e888318
--- /dev/null
+++ b/Nt/386/bin/kprof.exe
Binary files differ
diff --git a/Nt/386/bin/ksize.exe b/Nt/386/bin/ksize.exe
new file mode 100644
index 0000000..9f1c0ee
--- /dev/null
+++ b/Nt/386/bin/ksize.exe
Binary files differ
diff --git a/Nt/386/bin/kstrip.exe b/Nt/386/bin/kstrip.exe
new file mode 100644
index 0000000..3ea13d8
--- /dev/null
+++ b/Nt/386/bin/kstrip.exe
Binary files differ
diff --git a/Nt/386/bin/limbo.exe b/Nt/386/bin/limbo.exe
new file mode 100644
index 0000000..71fd6a0
--- /dev/null
+++ b/Nt/386/bin/limbo.exe
Binary files differ
diff --git a/Nt/386/bin/md5sum.exe b/Nt/386/bin/md5sum.exe
new file mode 100644
index 0000000..1f3a132
--- /dev/null
+++ b/Nt/386/bin/md5sum.exe
Binary files differ
diff --git a/Nt/386/bin/mk.exe b/Nt/386/bin/mk.exe
new file mode 100644
index 0000000..20a11af
--- /dev/null
+++ b/Nt/386/bin/mk.exe
Binary files differ
diff --git a/Nt/386/bin/mkdir.exe b/Nt/386/bin/mkdir.exe
new file mode 100644
index 0000000..d18ac75
--- /dev/null
+++ b/Nt/386/bin/mkdir.exe
Binary files differ
diff --git a/Nt/386/bin/mkext.exe b/Nt/386/bin/mkext.exe
new file mode 100644
index 0000000..92f8e5a
--- /dev/null
+++ b/Nt/386/bin/mkext.exe
Binary files differ
diff --git a/Nt/386/bin/mkppcimage.exe b/Nt/386/bin/mkppcimage.exe
new file mode 100644
index 0000000..fc676db
--- /dev/null
+++ b/Nt/386/bin/mkppcimage.exe
Binary files differ
diff --git a/Nt/386/bin/ms2.exe b/Nt/386/bin/ms2.exe
new file mode 100644
index 0000000..778d6b6
--- /dev/null
+++ b/Nt/386/bin/ms2.exe
Binary files differ
diff --git a/Nt/386/bin/mv.exe b/Nt/386/bin/mv.exe
new file mode 100644
index 0000000..d26d801
--- /dev/null
+++ b/Nt/386/bin/mv.exe
Binary files differ
diff --git a/Nt/386/bin/ndate.exe b/Nt/386/bin/ndate.exe
new file mode 100644
index 0000000..5590119
--- /dev/null
+++ b/Nt/386/bin/ndate.exe
Binary files differ
diff --git a/Nt/386/bin/ntsrv.exe b/Nt/386/bin/ntsrv.exe
new file mode 100644
index 0000000..e15f610
--- /dev/null
+++ b/Nt/386/bin/ntsrv.exe
Binary files differ
diff --git a/Nt/386/bin/qa.exe b/Nt/386/bin/qa.exe
new file mode 100644
index 0000000..ab2ece4
--- /dev/null
+++ b/Nt/386/bin/qa.exe
Binary files differ
diff --git a/Nt/386/bin/qc.exe b/Nt/386/bin/qc.exe
new file mode 100644
index 0000000..473168a
--- /dev/null
+++ b/Nt/386/bin/qc.exe
Binary files differ
diff --git a/Nt/386/bin/ql.exe b/Nt/386/bin/ql.exe
new file mode 100644
index 0000000..e83f99b
--- /dev/null
+++ b/Nt/386/bin/ql.exe
Binary files differ
diff --git a/Nt/386/bin/rcsh.exe b/Nt/386/bin/rcsh.exe
new file mode 100644
index 0000000..947e3cb
--- /dev/null
+++ b/Nt/386/bin/rcsh.exe
Binary files differ
diff --git a/Nt/386/bin/rm.exe b/Nt/386/bin/rm.exe
new file mode 100644
index 0000000..99341c4
--- /dev/null
+++ b/Nt/386/bin/rm.exe
Binary files differ
diff --git a/Nt/386/bin/sed.exe b/Nt/386/bin/sed.exe
new file mode 100644
index 0000000..741d35a
--- /dev/null
+++ b/Nt/386/bin/sed.exe
Binary files differ
diff --git a/Nt/386/bin/sqz.exe b/Nt/386/bin/sqz.exe
new file mode 100644
index 0000000..eaa8cab
--- /dev/null
+++ b/Nt/386/bin/sqz.exe
Binary files differ
diff --git a/Nt/386/bin/srclist.exe b/Nt/386/bin/srclist.exe
new file mode 100644
index 0000000..2fe82b1
--- /dev/null
+++ b/Nt/386/bin/srclist.exe
Binary files differ
diff --git a/Nt/386/bin/styxtest.exe b/Nt/386/bin/styxtest.exe
new file mode 100644
index 0000000..e37de5c
--- /dev/null
+++ b/Nt/386/bin/styxtest.exe
Binary files differ
diff --git a/Nt/386/bin/test.exe b/Nt/386/bin/test.exe
new file mode 100644
index 0000000..0936ac0
--- /dev/null
+++ b/Nt/386/bin/test.exe
Binary files differ
diff --git a/Nt/386/bin/tr.exe b/Nt/386/bin/tr.exe
new file mode 100644
index 0000000..a0de71b
--- /dev/null
+++ b/Nt/386/bin/tr.exe
Binary files differ
diff --git a/Nt/386/bin/va.exe b/Nt/386/bin/va.exe
new file mode 100644
index 0000000..07bba0b
--- /dev/null
+++ b/Nt/386/bin/va.exe
Binary files differ
diff --git a/Nt/386/bin/vc.exe b/Nt/386/bin/vc.exe
new file mode 100644
index 0000000..b3d6982
--- /dev/null
+++ b/Nt/386/bin/vc.exe
Binary files differ
diff --git a/Nt/386/bin/vl.exe b/Nt/386/bin/vl.exe
new file mode 100644
index 0000000..7191f50
--- /dev/null
+++ b/Nt/386/bin/vl.exe
Binary files differ
diff --git a/Nt/386/include/emu.h b/Nt/386/include/emu.h
new file mode 100644
index 0000000..ebf6d79
--- /dev/null
+++ b/Nt/386/include/emu.h
@@ -0,0 +1,29 @@
+#ifndef _EMU_H
+#define _EMU_H
+
+
+/*
+ * system- and machine-specific declarations for emu:
+ * floating-point save and restore, signal handling primitive, and
+ * implementation of the current-process variable `up'.
+ */
+
+/*
+ * This structure must agree with FPsave and FPrestore asm routines
+ */
+typedef struct FPU FPU;
+struct FPU
+{
+ uchar env[28];
+};
+
+extern void sleep(int);
+
+/* Set up private thread space */
+extern __declspec(thread) Proc* up;
+#define Sleep NTsleep
+
+typedef jmp_buf osjmpbuf;
+#define ossetjmp(buf) setjmp(buf)
+
+#endif
diff --git a/Nt/386/include/lib9.h b/Nt/386/include/lib9.h
new file mode 100644
index 0000000..e9a4a6c
--- /dev/null
+++ b/Nt/386/include/lib9.h
@@ -0,0 +1,501 @@
+#ifndef _LIB9_H
+#define _LIB9_H
+
+#define _POSIX_SOURCE
+#include <stdlib.h>
+#include <stdarg.h>
+#include <errno.h>
+#include <string.h>
+#include "math.h"
+#include <fcntl.h>
+#include <setjmp.h>
+#include <float.h>
+#include <time.h>
+#include <process.h>
+#include <io.h>
+#include <direct.h>
+
+#define getwd infgetwd
+#define strtod infstrtod
+#define strtoll infstrtoll
+#define strtoull infstrtoull
+#ifndef INFERNO_KEEPENVIRON
+/* environ is perfectly legal as the name of a local, field name or struct, but windows redefines it */
+/* the extern char** environ is only needed by two programs, so #undef it for everything else */
+#undef environ
+#endif
+
+/* do-it-yourself isinf and isnan */
+#ifndef isnan
+#define isnan(x) _isnan(x)
+#endif
+#ifndef isinf
+#define isinf(x) (!_finite(x))
+#endif
+
+#ifndef EMU
+typedef struct Proc Proc;
+#endif
+
+/*
+ * math module dtoa
+ */
+#define __LITTLE_ENDIAN
+
+ /* there must be a Win32 header macro for endian-ness!!! */
+
+/*
+ * disable various silly warnings
+ * 4018 signed/unsigned comparison
+ * 4245 signed/unsigned conversion
+ * 4244 long to char conversion
+ * 4068 unknown pragma
+ * 4090 different volatile quals
+ * 4554 operator precedence
+ * 4146 unary - on unsigned type
+ * 4996 `deprecated' functions: they often suggest non-portable replacements
+ */
+#pragma warning( disable : 4305 4244 4102 4761 4018 4245 4244 4068 4090 4554 4146 4996)
+
+#define nil ((void*)0)
+
+typedef unsigned char uchar;
+typedef unsigned int uint;
+typedef unsigned long ulong;
+typedef signed char schar;
+typedef unsigned short ushort;
+typedef unsigned int Rune;
+typedef __int64 vlong;
+typedef unsigned __int64 uvlong;
+typedef unsigned int u32int;
+typedef uvlong u64int;
+
+typedef unsigned int mpdigit; /* for /sys/include/mp.h */
+typedef unsigned short u16int;
+typedef unsigned char u8int;
+typedef unsigned long uintptr;
+
+typedef signed char int8;
+typedef unsigned char uint8;
+typedef short int16;
+typedef unsigned short uint16;
+typedef int int32;
+typedef unsigned int uint32;
+typedef long long int64;
+typedef unsigned long long uint64;
+
+#define USED(x) if(x){}else{}
+#define SET(x)
+
+#undef nelem
+#define nelem(x) (sizeof(x)/sizeof((x)[0]))
+#undef offsetof
+#define offsetof(s, m) (ulong)(&(((s*)0)->m))
+#undef assert
+#define assert(x) if(x){}else _assert("x")
+
+/*
+ * most mem and string routines are declared by ANSI/POSIX files above
+ */
+
+extern char* strecpy(char*, char*, char*);
+extern char* strdup(const char*);
+extern int cistrncmp(char*, char*, int);
+extern int cistrcmp(char*, char*);
+extern char* cistrstr(char*, char*);
+extern int tokenize(char*, char**, int);
+extern double strtod(const char*, char**);
+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);
+
+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 int isInf(double, int);
+
+#define PIO2 1.570796326794896619231e0
+#define PI (PIO2+PIO2)
+
+/*
+ * 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* getuser(void);
+extern char* getwd(char*, int);
+extern char* getwd(char*, int);
+extern double ipow10(int);
+extern double pow10(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 long readn(int, void*, long);
+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 (_argt=0);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
+ */
+
+extern void setbinmode(void);
+extern void* sbrk(int);
+
+#endif