summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-02 13:12:59 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-02 13:12:59 -0500
commitaa2c7727b1ee7b3747681f6b78f9ef0d36beb749 (patch)
tree2d637999ffbf3661fa5ef2e6e93bf40bff13672f
parenta4bd7a9c848d024ecb9c2bd9af0facaec728ba30 (diff)
trim old nonstd
-rw-r--r--.gitmodules3
-rw-r--r--nonstd/FILE.h46
-rw-r--r--nonstd/libc.c112
-rw-r--r--nonstd/man.h6
-rw-r--r--nonstd/public/setjmp.h7
-rw-r--r--nonstd/static/fopen.h12
-rw-r--r--nonstd/static/locale.h75
-rw-r--r--nonstd/static/printf.h318
-rw-r--r--nonstd/static/scanf.h7
-rw-r--r--nonstd/static/thread.h39
-rw-r--r--nonstd/static/wctrans.h5
-rw-r--r--nonstd/static/wctype.h15
-rw-r--r--nonstd/stubs/fcntl.h48
-rw-r--r--nonstd/stubs/inttypes.h6
-rw-r--r--nonstd/stubs/sys/mman.h13
-rw-r--r--nonstd/stubs/sys/stat.h0
-rw-r--r--nonstd/stubs/sys/types.h1
-rw-r--r--nonstd/stubs/unistd.h15
-rw-r--r--nonstd/stubs/wchar.h9
-rw-r--r--nonstd/syscall.h38
-rw-r--r--nonstd/types.h149
-rw-r--r--nonstd/x86-32.s18
-rw-r--r--nonstd/x86-64.s19
m---------src/9899-19900
m---------src/9899-19990
25 files changed, 3 insertions, 958 deletions
diff --git a/.gitmodules b/.gitmodules
index 75a0586a..92c25d91 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -10,3 +10,6 @@
[submodule "std/9899-1990-AMD1"]
path = src/9899-1990-AMD1
url = git@gitlab.com:ung.org/lib/9899-1990-AMD1.git
+[submodule "src/9899-1999"]
+ path = src/9899-1999
+ url = git@gitlab.com:ung.org/lib/9899-1999.git
diff --git a/nonstd/FILE.h b/nonstd/FILE.h
deleted file mode 100644
index 263fe1ab..00000000
--- a/nonstd/FILE.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef __NONSTD_FILE_H__
-#define __NONSTD_FILE_H__
-
-#include "stdio.h" /* for fpos_t */
-#include "sys/types.h" /* for pid_t */
-
-#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 199309L
-# define flockfile(x)
-# define ftrylockfile(x)
-# define funlockfile(x)
-#endif
-
-struct __FILE {
- fpos_t pos;
- char *buf;
- enum { SUPPLIED, ALLOCED, UNSET } buftype;
- int buffering;
- int bsize;
- int isopen;
- int flags;
- int lastop;
-
- /* verified necessary */
- int fd;
- int oflag;
- int orientation;
- int eof;
- int err;
- int nlocks;
- int thread;
- pid_t pipe_pid;
-
- struct {
- char *buf;
- size_t size;
- int allocated;
- } mem;
-
- struct __FILE *prev;
- struct __FILE *next;
-};
-
-int getc_unlocked(FILE *);
-int putc_unlocked(FILE *, int);
-
-#endif
diff --git a/nonstd/libc.c b/nonstd/libc.c
deleted file mode 100644
index 5dc0f818..00000000
--- a/nonstd/libc.c
+++ /dev/null
@@ -1,112 +0,0 @@
-#include <stddef.h>
-#include <locale.h>
-
-#include "nonstd/types.h"
-
-#include "nonstd/public/setjmp.h"
-
-#include "nonstd/static/locale.h"
-#include "nonstd/static/thread.h"
-/*
-#include "nonstd/static/wctype.h"
-#include "nonstd/static/wctrans.h"
-*/
-#include "nonstd/static/printf.h"
-#include "nonstd/static/scanf.h"
-#include "nonstd/static/fopen.h"
-
-#include "nonstd/syscall.h"
-
-#include "__linux.h"
-
-/*
-static int __syscall_byname(const char *name, ...)
-{
- int ret = -1;
- int sc = __libc.syscall_lookup(name);
- va_list ap;
- va_start(ap, name);
- ret = __libc.syscall_arglist(sc, ap);
- va_end(ap);
- return ret;
-}
-
-static int __syscall_bynum(int call, ...)
-{
- int ret = -1;
- va_list ap;
- va_start(ap, call);
- ret = __libc.syscall_arglist(call, ap);
- va_end(ap);
- return ret;
-}
-*/
-
-struct libc __libc = {
- .ctype = {
- .ctattr = 0,
- .ctolower = 1,
- .ctoupper = 2,
- .lower = 1 << 1,
- .punct = 1 << 2,
- .space = 1 << 3,
- .upper = 1 << 4,
- .xdigit = 1 << 5,
- .getmap = __getmap,
- },
- .stdio.printf = __common_printf,
- .stdio.scanf = __common_scanf,
- .stdio.fopen = __common_fopen,
- .stdlib.rand = 1,
- .stdlib.atexit_max = 32,
- .syscall_lookup = __syscall_lookup,
- .syscall = __syscall,
- .per_thread = per_thread,
-};
-
-extern int main();
-
-void __libc_start(int argc, char **argv)
-{
- struct __fopen_options fo = {0};
- fo.fd = 0;
- stdin = __libc.stdio.fopen(&fo);
- fo.fd = 1;
- stdout = __libc.stdio.fopen(&fo);
- fo.fd = 2;
- stderr = __libc.stdio.fopen(&fo);
-
- #if defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || defined _XOPEN_SOURCE
- setlocale(LC_ALL, "POSIX");
- #else
- setlocale(LC_ALL, "C");
- #endif
-
- exit(main(argc, argv));
-}
-
-
-#include <stdio.h>
-#include <stdlib.h>
-
-/* TODO: i18n */
-
-void __assert(const char *expr, const char *file, int line, const char *func)
-{
- if (func) {
- fprintf(stderr, "Assertion failed: %s (%s:%d:%s())\n", expr,
- file, line, func);
- } else {
- fprintf(stderr, "Assertion failed: %s (%s:%d)\n", expr, file,
- line);
- }
- abort();
-}
-
-int *__errno(void)
-{
- return &__libc.per_thread()->err;
-}
-
-
-FILE *stdin, *stdout, *stderr;
diff --git a/nonstd/man.h b/nonstd/man.h
deleted file mode 100644
index f6edc35b..00000000
--- a/nonstd/man.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#define RETURN_ALWAYS(x, ...)
-#define OBSOLETE(x, ...)
-#define RETURN(x, ...)
-#define RETURN_SUCCESS(x, ...)
-#define RETURN_FAILURE(x, ...)
-#define IMPLEMENTATION(x, ...)
diff --git a/nonstd/public/setjmp.h b/nonstd/public/setjmp.h
deleted file mode 100644
index fb510bdc..00000000
--- a/nonstd/public/setjmp.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <setjmp.h>
-
-int __setjmp(jmp_buf env)
-{
- (void)env;
- return 0;
-}
diff --git a/nonstd/static/fopen.h b/nonstd/static/fopen.h
deleted file mode 100644
index 64d30f1e..00000000
--- a/nonstd/static/fopen.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "nonstd/FILE.h"
-
-static FILE *__common_fopen(struct __fopen_options *opt)
-{
- FILE *f = NULL;
- if (__libc.stdio.nopen < FOPEN_MAX) {
- f = __libc.stdio.files + __libc.stdio.nopen;
- __libc.stdio.nopen++;
- }
- f->fd = opt->fd;
- return f;
-}
diff --git a/nonstd/static/locale.h b/nonstd/static/locale.h
deleted file mode 100644
index e96b0376..00000000
--- a/nonstd/static/locale.h
+++ /dev/null
@@ -1,75 +0,0 @@
-#include <limits.h>
-#include "nonstd/types.h"
-
-#ifndef LC_GLOBAL_LOCALE
-typedef void * locale_t;
-#define LC_GLOBAL_LOCALE ((locale_t)(-1))
-#endif
-
-static unsigned char *__getmap(int map)
-{
- static unsigned char c_attr[UCHAR_MAX + 1] = {0};
- static unsigned char c_lower[UCHAR_MAX + 1] = {0};
- static unsigned char c_upper[UCHAR_MAX + 1] = {0};
- struct __locale_t c;
- struct __locale_t *locale = __libc.per_thread()->locale;
-
- if (!locale || locale == LC_GLOBAL_LOCALE || !locale->ctype) {
- locale = __libc.locale.global;
- }
-
- if (!locale || !locale->ctype) {
- unsigned char lower[] = "abcdefghijklmnopqrstuvwxyz";
- unsigned char upper[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- /* $@` are in ASCII but not 9899 */
- unsigned char punct[] = "!\"#%&'()*+,-./:;<=>?[\\]^_{|}~$@`";
- unsigned char space[] = " \f\n\r\t\v";
- unsigned char xdigit[] = "0123456789abcdefABCDEF";
-
- locale = &c;
- c.ctattr = c_attr;
- c.ctolower = c_lower;
- c.ctoupper = c_upper;
-
- if (c_attr['a'] == 0) {
- unsigned int i;
- for (i = 0; i <= UCHAR_MAX; i++) {
- c_attr[i] = 0;
- c_lower[i] = i;
- c_upper[i] = i;
- }
-
- for (i = 0; i < sizeof(lower); i++) {
- c_attr[lower[i]] = __libc.ctype.lower;
- c_upper[lower[i]] = upper[i];
- }
-
- for (i = 0; i < sizeof(upper); i++) {
- c_attr[upper[i]] = __libc.ctype.upper;
- c_lower[upper[i]] = lower[i];
- }
-
- for (i = 0; i < sizeof(xdigit); i++) {
- c_attr[xdigit[i]] |= __libc.ctype.xdigit;
- }
-
- for (i = 0; i < sizeof(punct); i++) {
- c_attr[punct[i]] = __libc.ctype.punct;
- }
-
- for (i = 0; i < sizeof(space); i++) {
- c_attr[space[i]] = __libc.ctype.space;
- }
-
- c_attr[0] = 0;
- }
- }
-
- if (map == __libc.ctype.ctolower) {
- return locale->ctolower;
- } else if (map == __libc.ctype.ctoupper) {
- return locale->ctoupper;
- }
-
- return locale->ctattr;
-}
diff --git a/nonstd/static/printf.h b/nonstd/static/printf.h
deleted file mode 100644
index 9ad3a76d..00000000
--- a/nonstd/static/printf.h
+++ /dev/null
@@ -1,318 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <inttypes.h>
-#include <stdarg.h>
-#include <stddef.h>
-#include "nonstd/types.h"
-
-#include <unistd.h>
-
-#define NUMBUFLEN 64
-
-#define LEFT (1 << 0)
-#define SIGN (1 << 1)
-#define SPACE (1 << 2)
-#define ALT (1 << 3)
-#define ZERO (1 << 4)
-#define UPPER (1 << 5)
-#define UNSIGNED (1 << 6)
-
-/* TODO: remove this */
-uintmax_t strtoumax(const char *s, char **n, int base)
-{
- (void)base;
- *n = (char*)s;
- return 0;
-}
-
-static int __append(char *s, char *argstring, int nout, size_t n)
-{
- s += nout;
- while (*argstring) {
- if (nout < (int)n) {
- *s++ = *argstring;
- }
- nout++;
- argstring++;
- }
- return nout;
-}
-
-static void __itos(char *s, intmax_t n, int flags, int precision, int base)
-{
- char digits[] = "0123456789abcdef";
- char sign = n < 0 ? '-' : '+';
- char buf[NUMBUFLEN];
- char *out = buf + NUMBUFLEN;
- if (flags & UPPER && base > 10) {
- size_t i;
- for (i = 0; i < sizeof(digits); i++) {
- digits[i] = (char)toupper(digits[i]);
- }
- }
- *out = '\0';
- out--;
- while (n > 0) {
- precision--;
- *out = digits[n % base];
- n /= base;
- out--;
- }
- if (flags & SIGN || sign == '-') {
- *out = sign;
- out--;
- }
- out++;
- while ((*s++ = *out++) != 0) {
- continue;
- }
-}
-
-static int __common_printf(struct priscn_options *opt,
- const char * restrict format, va_list arg)
-{
- char buf[BUFSIZ];
- int nout = 0;
- int fd = -1;
- FILE *f = NULL;
-
- intmax_t argint = 0;
- void *argptr = NULL;
- char numbuf[NUMBUFLEN];
-
- size_t i;
- size_t n = 0;
- char *s = NULL;
-
- if (opt->stream) {
- /* file based */
- f = opt->stream;
- s = buf;
- n = BUFSIZ;
- flockfile(f);
- } else if (opt->string) {
- /* memory buffer */
- s = opt->string;
- n = opt->maxlen;
- } else {
- /* file descriptor */
- s = buf;
- n = BUFSIZ;
- fd = opt->fd;
- }
-
- for (i = 0; format[i] != 0; i++) {
- if (format[i] != '%') {
- if (nout < (int)n) {
- s[nout] = format[i];
- }
- nout++;
- continue;
- }
-
- /*
- // zero of more flags "-+ #0"
- // optional width "*" or decimal integer
- // optional precision ".*" or ".[decimal]"
- // optional length modifier "hh", "h", "l", "ll", "j",
- // "z", "t", "L"
- // conversion specifier "diouxXfFeEgGaAcspn%"
- */
- int flags = 0;
- /* uintmax_t width = 0; */
- int step = 0;
- int precision = 0;
- int base = 10;
- enum { def, hh, h, l, ll, j, z, t, L } length = def;
-
- while (step == 0) {
- i++;
- switch (format[i]) {
- case '-': flags |= LEFT; break;
- case '+': flags |= SIGN; break;
- case ' ': flags |= SPACE; break;
- case '#': flags |= ALT; break;
- case '0': flags |= ZERO; break;
- default: step = 1; break;
- }
- }
-
- if (format[i] == '*') {
- i++;
- } else if (isdigit(format[i])) {
- /*
- char *end;
- width = strtoumax(format + i, &end, 10);
- i = end - format;
- */
- }
-
- if (format[i] == '.') {
- i++;
- if (format[i] == '*') {
- i++;
- } else if (isdigit(format[i])) {
- char *end;
- precision = (int)strtoumax(format + i, &end, 10);
- i = end - format;
- } else {
- /* invalid precision */
- nout = -nout;
- goto end;
- }
- }
-
- if (format[i] == 'h') {
- i++;
- if (format[i] == 'h') {
- i++;
- length = hh;
- } else {
- length = h;
- }
- } else if (format[i] == 'l') {
- i++;
- if (format[i] == 'l') {
- i++;
- length = ll;
- } else {
- length = l;
- }
- } else if (format[i] == 'j') {
- i++;
- length = j;
- } else if (format[i] == 'z') {
- i++;
- length = z;
- } else if (format[i] == 't') {
- i++;
- length = t;
- } else if (format[i] == 'L') {
- i++;
- length = L;
- }
-
- if (isupper(format[i])) {
- flags |= UPPER;
- }
-
- switch (format[i]) {
- case 'o': /* unsigned int */
- case 'u':
- case 'x':
- case 'X':
- flags |= UNSIGNED;
-
- case 'd': /* int */
- case 'i':
- switch (length) {
- case hh: argint = (signed char)va_arg(arg, int); break;
- case h: argint = (short int)va_arg(arg, int); break;
- case l: argint = va_arg(arg, long int); break;
- case ll: argint = va_arg(arg, long long int); break;
- case j: argint = va_arg(arg, intmax_t); break;
- case z: argint = va_arg(arg, size_t); break;
- case t: argint = va_arg(arg, ptrdiff_t); break;
- case L: nout = -nout; goto end;
- default: argint = va_arg(arg, int); break;
- }
- if (format[i] == 'o') {
- base = 8;
- } else if (format[i] == 'x') {
- base = 16;
- } else if (format[i] == 'X') {
- base = 16;
- flags |= UPPER;
- } else {
- base = 10;
- }
- __itos(numbuf, (long int)argint, flags, precision, base);
- nout = __append(s, numbuf, nout, n);
- break;
-
-
- case 'f': /* double [-]ddd.ddd */
- case 'F':
- break;
-
- case 'e': /* double [-]d.ddde+/-dd */
- case 'E':
- break;
-
- case 'g': /* double f or e see docs */
- case 'G':
- break;
-
- case 'a': /* double as hex */
- case 'A':
- break;
-
- case 'c': /* char */
- if (length == def) {
- char c = va_arg(arg, int);
- if (nout < (int)n) {
- s[nout] = c;
- }
- nout++;
- } else if (length == l) {
- /* wint_t wc = va_arg(arg, wint_t); */
- /* char mb[MB_CUR_MAX + 1] = "WC"; */
- /* wctomb(mb, wc); */
- /* nout = __append(s, mb, nout, n); */
- } else {
- nout = -nout;
- goto end;
- }
- break;
-
- case 's': /* string */
- if (length == def) {
- char *string = va_arg(arg, char *);
- nout = __append(s, string, nout, n);
- } else if (length == l) {
- /*wchar_t *ws = va_arg(arg, wchar_t *); */
- /*char *mbs = malloc(wcslen(ws) * MB_CUR_MAX + 1); */
- /*wcstombs(mbs, ws, wcslen(ws) * MB_CUR_MAX + 1); */
- /*nout = __append(s, mbs, nout, n); */
- /*free(mbs); */
- nout = __append(s, "WIDE STRING", nout, n);
- } else {
- nout = -nout;
- goto end;
- }
-
- break;
-
- case 'p': /* pointer */
- argptr = va_arg(arg, void *);
- nout = __append(s, "0x", nout, n);
- __itos(numbuf, (intptr_t)argptr, ZERO, sizeof(argptr) * 2, 16);
- nout = __append(s, numbuf, nout, n);
- break;
-
- case 'n': /* write-back */
- break;
-
- case '%': /* literal '%' */
- if (nout < (int)n) {
- s[nout] = '%';
- }
- nout++;
- break;
-
- default: /* undefined */
- return -nout;
- }
- }
-
- end:
- if (f) {
- fwrite(buf, 1, nout % BUFSIZ, f);
- funlockfile(f);
- } else if (fd != -1) {
- write(fd, buf, nout % BUFSIZ);
- }
-
- return nout;
-}
diff --git a/nonstd/static/scanf.h b/nonstd/static/scanf.h
deleted file mode 100644
index 89622951..00000000
--- a/nonstd/static/scanf.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#include "nonstd/types.h"
-
-static int __common_scanf(struct priscn_options *opt, const char *format, va_list arg)
-{
- (void)opt; (void)format; (void)arg;
- return 0;
-}
diff --git a/nonstd/static/thread.h b/nonstd/static/thread.h
deleted file mode 100644
index db66c0b7..00000000
--- a/nonstd/static/thread.h
+++ /dev/null
@@ -1,39 +0,0 @@
-#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 201101L
-
-static struct per_thread *per_thread(void)
-{
- _Thread_local static struct per_thread pt = {0};
- return &pt;
-}
-
-#elif defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 199506L
-#include <pthread.h>
-
-static pthread_key_t __per_thread_key;
-
-static void _make_key(void)
-{
- pthread_key_create(&key, NULL);
-}
-
-static struct per_thread *per_thread(void)
-{
- static pthread_once_t key_once = PTHREAD_ONCE_INIT;
- struct per_thread *pt;
- pthread_once(&key_once, make_key);
- if ((pt = pthread_getspecific(key)) == NULL) {
- pt = calloc(1, sizeof (*pt));
- pthread_setspecific(key, pt);
- }
- return pt;
-}
-
-#else
-
-static struct per_thread *per_thread(void)
-{
- static struct per_thread pt = {0};
- return &pt;
-}
-
-#endif
diff --git a/nonstd/static/wctrans.h b/nonstd/static/wctrans.h
deleted file mode 100644
index 5dcb7608..00000000
--- a/nonstd/static/wctrans.h
+++ /dev/null
@@ -1,5 +0,0 @@
-static const char *__wctrans[] = {
- NULL, /* 0 is an invalid wctrans_t */
- "tolower",
- "toupper",
-};
diff --git a/nonstd/static/wctype.h b/nonstd/static/wctype.h
deleted file mode 100644
index e0615096..00000000
--- a/nonstd/static/wctype.h
+++ /dev/null
@@ -1,15 +0,0 @@
-static const char *__wctype[] = {
- 0, /* 0 is an invalid wctype_t */
- "alnum",
- "alpha",
- "blank",
- "cntrl",
- "digit",
- "graph",
- "lower",
- "print",
- "punct",
- "space",
- "upper",
- "xdigit",
-};
diff --git a/nonstd/stubs/fcntl.h b/nonstd/stubs/fcntl.h
deleted file mode 100644
index 2c737603..00000000
--- a/nonstd/stubs/fcntl.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef __FCNTL_H__
-#define __FCNTL_H__
-#include "nonstd/types.h"
-
-#define F_DUPFD 1
-#define F_DUPFD_CLOEXEC 2
-#define F_GETFD 3
-#define F_SETFD 4
-#define F_GETFL 5
-#define F_SETFL 6
-#define F_GETLK 7
-#define F_SETLK 8
-#define F_SETLKW 9
-#define F_GETOWN 10
-#define F_SETOWN 11
-
-#define FD_CLOEXEC 1
-
-#define F_RDLCK 1
-#define F_UNLCK 2
-#define F_WRLCK 3
-
-#define O_CLOEXEC 02000000
-#define O_CREAT (1 << 1)
-#define O_DIRECTORY (1 << 2)
-#define O_EXCL (1 << 3)
-#define O_NCTTY (1 << 4)
-#define O_NOFOLLOW (1 << 5)
-#define O_TRUNC (1 << 6)
-#define O_TTY_INIT (1 << 7)
-
-#define O_APPEND (1 << 8)
-#define O_DSYNC (1 << 9)
-#define O_NONBLOCK (1 << 10)
-#define O_RSYNC (1 << 11)
-#define O_SYNC (1 << 12)
-
-#define O_EXEC (1 << 13)
-#define O_RDONLY (1 << 14)
-#define O_RDWR 02
-#define O_SEARCH (1 << 16)
-#define O_WRONLY (1 << 17)
-
-#define O_ACCMODE (O_EXEC|O_RDONLY|O_RDWR|O_SEARCH|O_WRONLY)
-
-#define open(path, mode, flags) __libc.syscall(__libc.syscall_lookup("open"), path, mode, flags)
-
-#endif
diff --git a/nonstd/stubs/inttypes.h b/nonstd/stubs/inttypes.h
deleted file mode 100644
index acaa97af..00000000
--- a/nonstd/stubs/inttypes.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#define SIZE_MAX 0xffffffff
-typedef long long int intmax_t;
-typedef unsigned long long int uintmax_t;
-typedef unsigned long int intptr_t;
-intmax_t strtoimax(const char *, char **, int);
-uintmax_t strtoumax(const char *, char **, int);
diff --git a/nonstd/stubs/sys/mman.h b/nonstd/stubs/sys/mman.h
deleted file mode 100644
index 01a201eb..00000000
--- a/nonstd/stubs/sys/mman.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#include "nonstd/types.h"
-
-#ifndef PROT_READ
-# define PROT_READ 0x1
-#endif
-#ifndef PROT_WRITE
-# define PROT_WRITE 0x2
-#endif
-#ifndef MAP_PRIVATE
-# define MAP_PRIVATE 0x02
-#endif
-
-#define mmap(_a, _l, _p, _f, _d, _o) __libc.syscall(__libc.syscall_lookup("mmap"), _a, _l, _p, _f, _d, _o)
diff --git a/nonstd/stubs/sys/stat.h b/nonstd/stubs/sys/stat.h
deleted file mode 100644
index e69de29b..00000000
--- a/nonstd/stubs/sys/stat.h
+++ /dev/null
diff --git a/nonstd/stubs/sys/types.h b/nonstd/stubs/sys/types.h
deleted file mode 100644
index 5fe25895..00000000
--- a/nonstd/stubs/sys/types.h
+++ /dev/null
@@ -1 +0,0 @@
-typedef int pid_t;
diff --git a/nonstd/stubs/unistd.h b/nonstd/stubs/unistd.h
deleted file mode 100644
index 8e16c2e8..00000000
--- a/nonstd/stubs/unistd.h
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef __UNISTD_H__
-#define __UNISTD_H__
-
-#include <stddef.h>
-#include "nonstd/syscall.h"
-
-#define open(path, mode, flags) __libc.syscall(__libc.syscall_lookup("open"), path, mode, flags)
-#define close(fd) __libc.syscall(__libc.syscall_lookup("close"), fd)
-#define write(fd, buf, nbyte) __libc.syscall(__libc.syscall_lookup("write"), fd, buf, nbyte)
-#define read(fd, buf, nbyte) __libc.syscall(__libc.syscall_lookup("read"), fd, buf, nbyte)
-#define kill(pid, sig) __libc.syscall(__libc.syscall_lookup("kill"), pid, sig)
-#define getpid() __libc.syscall(__libc.syscall_lookup("getpid"))
-#define _exit(status) __libc.syscall(__libc.syscall_lookup("exit"), status)
-
-#endif
diff --git a/nonstd/stubs/wchar.h b/nonstd/stubs/wchar.h
deleted file mode 100644
index 0bdc95cb..00000000
--- a/nonstd/stubs/wchar.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <stddef.h>
-#define WEOF (-1L)
-typedef int mbstate_t;
-typedef int wint_t;
-size_t mbrlen(const char * restrict, size_t, mbstate_t * restrict);
-size_t mbsrtowcs(wchar_t * restrict, const char * restrict, size_t, mbstate_t * restrict);
-size_t mbrtowc(wchar_t * restrict, const char * restrict, size_t, mbstate_t * restrict);
-size_t wcrtomb(char * restrict, wchar_t, mbstate_t * restrict);
-wint_t btowc(int);
diff --git a/nonstd/syscall.h b/nonstd/syscall.h
deleted file mode 100644
index e698f40d..00000000
--- a/nonstd/syscall.h
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef __NONSTD_SYSCALL_H__
-#define __NONSTD_SYSCALL_H__
-
-#include <errno.h>
-#include "nonstd/types.h"
-
-#ifndef ENOSYS
-#define ENOSYS 10
-#endif
-
-#define SCNO(_var, _name, _notfound) static int _var = -2; do { \
- if ((_var) == -2) { (_var) = __libc.syscall_lookup((_name)); } \
- if ((_var) == -1) { errno = ENOSYS; return (_notfound); } \
- } while (0)
-
-#define SCNOFAIL() static int _scno = -2; \
- if (_scno == -2) { _scno = __libc.syscall_lookup(__func__); } \
- return __libc.syscall(_scno)
-
-#define SC(_type, ...) static int _scno = -2; \
- if (_scno == -2) { _scno = __libc.syscall_lookup(__func__); } \
- _type _ret = __libc.syscall(_scno, __VA_ARGS__); \
- if (_ret < 0) { \
- errno = -_ret; \
- return -1; \
- } \
- return _ret
-
-#define SC0(_type) static int _scno = -2; \
- if (_scno == -2) { _scno = __libc.syscall_lookup(__func__); } \
- _type _ret = __libc.syscall(_scno); \
- if (_ret < 0) { \
- errno = -_ret; \
- return -1; \
- } \
- return _ret
-
-#endif
diff --git a/nonstd/types.h b/nonstd/types.h
deleted file mode 100644
index 54f3848c..00000000
--- a/nonstd/types.h
+++ /dev/null
@@ -1,149 +0,0 @@
-#ifndef __NONSTD_TYPES_H__
-#define __NONSTD_TYPES_H__
-
-#include <stdio.h> /* for FILE */
-#include <stdarg.h> /* for va_list */
-#include <locale.h> /* for struct lconv */
-
-#include "nonstd/FILE.h"
-
-typedef int errno_t;
-typedef void (*constraint_handler_t)(const char * restrict msg, void * restrict ptr, errno_t error);
-
-struct __constraint_info {
- const char *func;
-};
-
-struct __locale_t {
- int mask;
- char *all;
- char *collate;
- unsigned char *collation;
- char *ctype;
- unsigned char *ctattr;
- unsigned char *ctoupper;
- unsigned char *ctolower;
- char *message;
- struct {
- char *yesexpr;
- char *noexpr;
- } lc_messages;
- char *monetary;
- char *numeric;
- struct lconv mn;
- char *time;
- struct {
- char *abday[7];
- char *day[7];
- char *abmon[12];
- char *mon[12];
- char *d_t_fmt;
- char *d_fmt;
- char *t_fmt;
- char *am_pm[2];
- char *t_fmt_ampm;
- struct {
- char direction;
- int offset;
- int start_year;
- int start_month;
- int start_day;
- int end_year;
- int end_month;
- int end_day;
- char *era_name;
- char *era_format;
- } era;
- char *era_d_fmt;
- char *era_t_fmt;
- char *era_d_t_fmt;
- char *alt_digits;
- } lc_time;
-};
-
-struct priscn_options {
- const char *fnname;
- char *string;
- FILE *stream;
- size_t maxlen;
- int fd;
- int flags;
-};
-
-struct __fopen_options {
- const char *fnname;
- char *path;
- int fd;
- FILE *stream;
-};
-
-struct per_thread {
- int id;
- int err;
- struct __locale_t *locale;
-};
-
-struct libc {
- const struct {
- int ctattr;
- int ctoupper;
- int ctolower;
- int lower;
- int punct;
- int space;
- int upper;
- int xdigit;
- unsigned char *(*getmap)(int);
- } ctype;
- struct {
- struct __locale_t *global;
- } locale;
- struct {
- FILE files[FOPEN_MAX];
- FILE *lastfile;
- int nopen;
- int (*printf)(struct priscn_options *, const char *, va_list);
- int (*scanf)(struct priscn_options *, const char *, va_list);
- FILE *(*fopen)(struct __fopen_options *);
- } stdio;
- struct {
- unsigned int rand;
- struct atexit {
- void (*fn)(void);
- struct atexit *next;
- struct atexit *prev;
- } atexit[32], at_quick_exit[32];
- struct atexit *atexit_tail;
- struct atexit *at_quick_exit_tail;
- int atexit_max;
- int natexit;
- int nat_quick_exit;
- constraint_handler_t constraint_handler;
- } stdlib;
- struct {
- const char **wctype;
- const int nwctype;
- const char **wctrans;
- const int nwctrans;
- } wctype;
- struct {
- int nopen;
- struct fd {
- int fd;
- char *name;
- char *dir;
- } *fds;
- } unistd;
- char* (*atpath)(int fd, const char *path);
- long (*syscall_lookup)(const char *call);
- long (*syscall)(long call, ...);
- /*
- int (*syscall_bynum)(int call, ...);
- int (*syscall_byname)(const char *call, ...);
- int (*syscall_arglist)(int call, va_list arg);
- */
- struct per_thread *(*per_thread)(void);
-};
-extern struct libc __libc;
-
-#endif
diff --git a/nonstd/x86-32.s b/nonstd/x86-32.s
deleted file mode 100644
index dd7dbeff..00000000
--- a/nonstd/x86-32.s
+++ /dev/null
@@ -1,18 +0,0 @@
-.global __syscall_x86_32
-__syscall_x86_32:
- mov 4(%esp), %eax
- mov 8(%esp), %ebx
- mov 12(%esp), %ecx
- mov 16(%esp), %edx
- mov 20(%esp), %esi
- mov 24(%esp), %edi
- mov 28(%esp), %ebp
- sysenter
- ret
-
-/* FIXME: this seems to be unpossible to put in a shared library */
-/* FIXME: it may be worthwhile to separate this into crt1.s */
-.global _start
-_start:
- /* TODO */
- call __libc_start
diff --git a/nonstd/x86-64.s b/nonstd/x86-64.s
deleted file mode 100644
index 92d6a2d1..00000000
--- a/nonstd/x86-64.s
+++ /dev/null
@@ -1,19 +0,0 @@
-.global __syscall_x86_64
-__syscall_x86_64:
- mov %rdi, %rax
- mov %rsi, %rdi
- mov %rdx, %rsi
- mov %rcx, %rdx
- mov %r8, %r10
- mov %r9, %r8
- mov 8(%rsp), %r9
- syscall
- ret
-
-/* FIXME: this seems to be unpossible to put in a shared library */
-/* FIXME: it may be worthwhile to separate this into crt1.s */
-.global _start
-_start:
- popq %rdi
- movq %rsp, %rsi
- call __libc_start
diff --git a/src/9899-1990 b/src/9899-1990
deleted file mode 160000
-Subproject e98afb5e3575253054d775d7379ed5000c7ac98
diff --git a/src/9899-1999 b/src/9899-1999
new file mode 160000
+Subproject 4de20b5bb125f997db296e3c4be8b300ce578dd