From 60c3831e53b7afa5dd372601250e7e8739329383 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Wed, 12 Aug 2020 12:52:58 -0400 Subject: move more stuff out of nonstd/ --- src/__FEATURE_TEST_MACROS__/_POSIX_C_SOURCE.c | 0 src/__FEATURE_TEST_MACROS__/_POSIX_SOURCE.c | 5 +++ src/__FEATURE_TEST_MACROS__/_XOPEN_SOURCE.c | 0 .../_XOPEN_SOURCE_EXTENDED.c | 0 src/__PREDEFINED_MACROS__/__DATE__.c | 12 ++++++ src/__PREDEFINED_MACROS__/__FILE__.c | 14 ++++++ src/__PREDEFINED_MACROS__/__LINE__.c | 14 ++++++ src/__PREDEFINED_MACROS__/__STDC_HOSTED__.c | 10 +++++ .../__STDC_IEC_559_COMPLEX__.c | 10 +++++ src/__PREDEFINED_MACROS__/__STDC_IEC_559__.c | 10 +++++ src/__PREDEFINED_MACROS__/__STDC_ISO_10646__.c | 13 ++++++ src/__PREDEFINED_MACROS__/__STDC_VERSION__.c | 13 ++++++ src/__PREDEFINED_MACROS__/__STDC__.c | 14 ++++++ src/__PREDEFINED_MACROS__/__TIME__.c | 12 ++++++ src/__main.c | 50 ++++++++++++++++++++++ src/_sys.x86-32.s | 18 ++++++++ src/_sys.x86-64.s | 21 +++++++++ src/nonstd/_FTM/_POSIX_C_SOURCE.c | 0 src/nonstd/_FTM/_POSIX_SOURCE.c | 5 --- src/nonstd/_FTM/_XOPEN_SOURCE.c | 0 src/nonstd/_FTM/_XOPEN_SOURCE_EXTENDED.c | 0 src/nonstd/_PREDEF/__DATE__.c | 12 ------ src/nonstd/_PREDEF/__FILE__.c | 14 ------ src/nonstd/_PREDEF/__LINE__.c | 14 ------ src/nonstd/_PREDEF/__STDC_HOSTED__.c | 10 ----- src/nonstd/_PREDEF/__STDC_IEC_559_COMPLEX__.c | 10 ----- src/nonstd/_PREDEF/__STDC_IEC_559__.c | 10 ----- src/nonstd/_PREDEF/__STDC_ISO_10646__.c | 13 ------ src/nonstd/_PREDEF/__STDC_VERSION__.c | 13 ------ src/nonstd/_PREDEF/__STDC__.c | 14 ------ src/nonstd/_PREDEF/__TIME__.c | 12 ------ src/nonstd/__libc_start.c | 48 --------------------- src/nonstd/x86-32.s | 18 -------- src/nonstd/x86-64.s | 21 --------- 34 files changed, 216 insertions(+), 214 deletions(-) create mode 100644 src/__FEATURE_TEST_MACROS__/_POSIX_C_SOURCE.c create mode 100644 src/__FEATURE_TEST_MACROS__/_POSIX_SOURCE.c create mode 100644 src/__FEATURE_TEST_MACROS__/_XOPEN_SOURCE.c create mode 100644 src/__FEATURE_TEST_MACROS__/_XOPEN_SOURCE_EXTENDED.c create mode 100644 src/__PREDEFINED_MACROS__/__DATE__.c create mode 100644 src/__PREDEFINED_MACROS__/__FILE__.c create mode 100644 src/__PREDEFINED_MACROS__/__LINE__.c create mode 100644 src/__PREDEFINED_MACROS__/__STDC_HOSTED__.c create mode 100644 src/__PREDEFINED_MACROS__/__STDC_IEC_559_COMPLEX__.c create mode 100644 src/__PREDEFINED_MACROS__/__STDC_IEC_559__.c create mode 100644 src/__PREDEFINED_MACROS__/__STDC_ISO_10646__.c create mode 100644 src/__PREDEFINED_MACROS__/__STDC_VERSION__.c create mode 100644 src/__PREDEFINED_MACROS__/__STDC__.c create mode 100644 src/__PREDEFINED_MACROS__/__TIME__.c create mode 100644 src/__main.c create mode 100644 src/_sys.x86-32.s create mode 100644 src/_sys.x86-64.s delete mode 100644 src/nonstd/_FTM/_POSIX_C_SOURCE.c delete mode 100644 src/nonstd/_FTM/_POSIX_SOURCE.c delete mode 100644 src/nonstd/_FTM/_XOPEN_SOURCE.c delete mode 100644 src/nonstd/_FTM/_XOPEN_SOURCE_EXTENDED.c delete mode 100644 src/nonstd/_PREDEF/__DATE__.c delete mode 100644 src/nonstd/_PREDEF/__FILE__.c delete mode 100644 src/nonstd/_PREDEF/__LINE__.c delete mode 100644 src/nonstd/_PREDEF/__STDC_HOSTED__.c delete mode 100644 src/nonstd/_PREDEF/__STDC_IEC_559_COMPLEX__.c delete mode 100644 src/nonstd/_PREDEF/__STDC_IEC_559__.c delete mode 100644 src/nonstd/_PREDEF/__STDC_ISO_10646__.c delete mode 100644 src/nonstd/_PREDEF/__STDC_VERSION__.c delete mode 100644 src/nonstd/_PREDEF/__STDC__.c delete mode 100644 src/nonstd/_PREDEF/__TIME__.c delete mode 100644 src/nonstd/__libc_start.c delete mode 100644 src/nonstd/x86-32.s delete mode 100644 src/nonstd/x86-64.s diff --git a/src/__FEATURE_TEST_MACROS__/_POSIX_C_SOURCE.c b/src/__FEATURE_TEST_MACROS__/_POSIX_C_SOURCE.c new file mode 100644 index 00000000..e69de29b diff --git a/src/__FEATURE_TEST_MACROS__/_POSIX_SOURCE.c b/src/__FEATURE_TEST_MACROS__/_POSIX_SOURCE.c new file mode 100644 index 00000000..b594f3d9 --- /dev/null +++ b/src/__FEATURE_TEST_MACROS__/_POSIX_SOURCE.c @@ -0,0 +1,5 @@ +#define _POSIX_SOURCE /** feature test macro **/ +/* +FTM(POSIX.1-1988) +POSIX(1) +*/ diff --git a/src/__FEATURE_TEST_MACROS__/_XOPEN_SOURCE.c b/src/__FEATURE_TEST_MACROS__/_XOPEN_SOURCE.c new file mode 100644 index 00000000..e69de29b diff --git a/src/__FEATURE_TEST_MACROS__/_XOPEN_SOURCE_EXTENDED.c b/src/__FEATURE_TEST_MACROS__/_XOPEN_SOURCE_EXTENDED.c new file mode 100644 index 00000000..e69de29b diff --git a/src/__PREDEFINED_MACROS__/__DATE__.c b/src/__PREDEFINED_MACROS__/__DATE__.c new file mode 100644 index 00000000..14e40fcb --- /dev/null +++ b/src/__PREDEFINED_MACROS__/__DATE__.c @@ -0,0 +1,12 @@ +#define __DATE__ /** date of compilation **/ + +/*** +is automatically defined by the compiler as the date of program +compilation, in the format DEFINITION("Mmm dd yyyy"). +***/ + +/* +VALUE_TYPE(string literal) +VALUE_FIXED(VAR("date-of-compilation")) +STDC(1) +*/ diff --git a/src/__PREDEFINED_MACROS__/__FILE__.c b/src/__PREDEFINED_MACROS__/__FILE__.c new file mode 100644 index 00000000..257ae89b --- /dev/null +++ b/src/__PREDEFINED_MACROS__/__FILE__.c @@ -0,0 +1,14 @@ +#define __FILE__ /** source file name **/ + +/*** +is automatically defined by the compiler as the file name of the +current source file being compiled as a character string literal. + +THIS() can be changed using PPDIR(line). +***/ + +/* +VALUE_TYPE(string literal) +VALUE_FIXED(VAR(the current file name)) +STDC(1) +*/ diff --git a/src/__PREDEFINED_MACROS__/__LINE__.c b/src/__PREDEFINED_MACROS__/__LINE__.c new file mode 100644 index 00000000..c6acb1b1 --- /dev/null +++ b/src/__PREDEFINED_MACROS__/__LINE__.c @@ -0,0 +1,14 @@ +#define __LINE__ /** source file line number **/ + +/*** +is automatically defined by the compiler as the current logical source +line in the source file being compiled. + +THIS() can be changed during compilation using PPDIR(line). +***/ + +/* +VALUE_TYPE(TYPE(int)) +VALUE_FIXED(VAR(the current line number)) +STDC(1) +*/ diff --git a/src/__PREDEFINED_MACROS__/__STDC_HOSTED__.c b/src/__PREDEFINED_MACROS__/__STDC_HOSTED__.c new file mode 100644 index 00000000..48fe28b7 --- /dev/null +++ b/src/__PREDEFINED_MACROS__/__STDC_HOSTED__.c @@ -0,0 +1,10 @@ +#define __STDC_HOSTED__ /** hosted or free-standing implementation **/ + +/*** +is defined to the integer constant CONST(1) if the implementation +is hosted, CONST(0) otherwise. +***/ + +/* +STDC(199901) +*/ diff --git a/src/__PREDEFINED_MACROS__/__STDC_IEC_559_COMPLEX__.c b/src/__PREDEFINED_MACROS__/__STDC_IEC_559_COMPLEX__.c new file mode 100644 index 00000000..a8d1f810 --- /dev/null +++ b/src/__PREDEFINED_MACROS__/__STDC_IEC_559_COMPLEX__.c @@ -0,0 +1,10 @@ +#define __STDC_IEC_559_COMPLEX__ /** IEC 60559 complex arithmetic **/ + +/*** +is defined to CONST(1) if the implementation conforms to Annex G +of ISO/IEC 9899 (IEC 60559 complex arithmetic). +***/ + +/* +STDC(199901) +*/ diff --git a/src/__PREDEFINED_MACROS__/__STDC_IEC_559__.c b/src/__PREDEFINED_MACROS__/__STDC_IEC_559__.c new file mode 100644 index 00000000..bdc441c4 --- /dev/null +++ b/src/__PREDEFINED_MACROS__/__STDC_IEC_559__.c @@ -0,0 +1,10 @@ +#define __STDC_IEC_559__ /** IEC 60559 floating-point arithmetic **/ + +/*** +is defined to CONST(1) if the implementation conforms to Annex G +of ISO/IEC 9899 (IEC 60559 floating-point arithmetic). +***/ + +/* +STDC(199901) +*/ diff --git a/src/__PREDEFINED_MACROS__/__STDC_ISO_10646__.c b/src/__PREDEFINED_MACROS__/__STDC_ISO_10646__.c new file mode 100644 index 00000000..3379c855 --- /dev/null +++ b/src/__PREDEFINED_MACROS__/__STDC_ISO_10646__.c @@ -0,0 +1,13 @@ +#define __STDC_ISO_10646__ /** supported UCS version **/ + +/*** +is defined if TYPE(wchar_t) represents characters encoded +in conformance with ISO/IEC 10646. In this case, THIS() is +defined as an integer CONST(yyyymmL), where CONST(yyyy) +represents the year and CONST(mm) the month of the supported +version of ISO/IEC 10646. +***/ + +/* +STDC(199901) +*/ diff --git a/src/__PREDEFINED_MACROS__/__STDC_VERSION__.c b/src/__PREDEFINED_MACROS__/__STDC_VERSION__.c new file mode 100644 index 00000000..56a23d90 --- /dev/null +++ b/src/__PREDEFINED_MACROS__/__STDC_VERSION__.c @@ -0,0 +1,13 @@ +#define __STDC_VERSION__ /** supported C standard **/ + +/*** +declares the supported version of ISO/IEC 9899. If THIS() is not defined, +the implementation only supports ISO/IEC 9899:1990, without AMD1. +***/ + +/* +VALUE_SELECT(`199409L', `ISO/IEC 9899:1990 AMD1') +VALUE_SELECT(`199901L', `ISO/IEC 9899:1999') +VALUE_SELECT(`201112L', `ISO/IEC 9899:2011') +STDC(199409) +*/ diff --git a/src/__PREDEFINED_MACROS__/__STDC__.c b/src/__PREDEFINED_MACROS__/__STDC__.c new file mode 100644 index 00000000..5bcfe7aa --- /dev/null +++ b/src/__PREDEFINED_MACROS__/__STDC__.c @@ -0,0 +1,14 @@ +#define __STDC__ (1) + +/** standard C support **/ + +/*** +is automatically defined by the compiler to indicate that it supports +some version of ISO/IEC 9899. +***/ + +/* +VALUE_TYPE(TYPE(int)) +VALUE_FIXED(1) +STDC(1) +*/ diff --git a/src/__PREDEFINED_MACROS__/__TIME__.c b/src/__PREDEFINED_MACROS__/__TIME__.c new file mode 100644 index 00000000..472e42c0 --- /dev/null +++ b/src/__PREDEFINED_MACROS__/__TIME__.c @@ -0,0 +1,12 @@ +#define __TIME__ /** time of compilation **/ + +/*** +is automatically defined by the compiler as the time of compilation +in the format DEFINITION("hh:mm:ss"). +***/ + +/* +VALUE_TYPE(string literal) +VALUE_FIXED(VAR("time of compilation")) +STDC(1) +*/ diff --git a/src/__main.c b/src/__main.c new file mode 100644 index 00000000..14e71594 --- /dev/null +++ b/src/__main.c @@ -0,0 +1,50 @@ +#include "stdlib.h" +#include "stdio.h" +#include "locale.h" +#include "stdio/_stdio.h" + +#ifdef _POSIX_SOURCE +#define DEFAULT_LOCALE "POSIX" +#include "unistd.h" +#else +#define DEFAULT_LOCALE "C" +#include "_syscall.h" +#include "termios/NCCS.c" +#include "termios/cc_t.c" +#include "termios/tcflag_t.c" +#include "termios/struct_termios.c" +static struct termios __tios; +#define isatty(fd) (__syscall(__syscall_lookup(tcgetattr), fd, &__tios) == 0) +#endif + +void __main(int argc, char **argv) +{ + extern int main(int, char*[]); + extern char **environ; + environ = argv + argc + 1; + + stdin = __stdio.FILES + 0; + stdin->fd = 0; + /* freopen(", "r", stdin); */ + setvbuf(stdin, NULL, isatty(0) ? _IOLBF : _IOFBF, BUFSIZ); + + stdout = __stdio.FILES + 1; + stdout->fd = 1; + /* freopen(NULL, "w", stdout); */ + setvbuf(stdin, NULL, isatty(1) ? _IOLBF : _IOFBF, BUFSIZ); + + stderr = __stdio.FILES + 2; + stderr->fd = 2; + /* freopen(NULL, "w", stderr); */ + setvbuf(stderr, NULL, _IONBF, 0); + + stdin->next = stdout; + stdout->next = stderr; + + stdout->prev = stdin; + stderr->prev = stdout; + + /* setlocale(LC_ALL, DEFAULT_LOCALE); */ + + exit(main(argc, argv)); +} diff --git a/src/_sys.x86-32.s b/src/_sys.x86-32.s new file mode 100644 index 00000000..ad60201d --- /dev/null +++ b/src/_sys.x86-32.s @@ -0,0 +1,18 @@ +.global __syscall +__syscall: + 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/src/_sys.x86-64.s b/src/_sys.x86-64.s new file mode 100644 index 00000000..415a8084 --- /dev/null +++ b/src/_sys.x86-64.s @@ -0,0 +1,21 @@ +.global __syscall +__syscall: + mov %rdi, %rax + mov %rsi, %rdi + mov %rdx, %rsi + mov %rcx, %rdx + mov %r8, %r10 + mov %r9, %r8 + mov 8(%rsp), %r9 + syscall + ret + +.global _start +_start: + popq %rdi + movq %rsp, %rsi + call __main + +.global __stack_chk_fail +__stack_chk_fail: + ret diff --git a/src/nonstd/_FTM/_POSIX_C_SOURCE.c b/src/nonstd/_FTM/_POSIX_C_SOURCE.c deleted file mode 100644 index e69de29b..00000000 diff --git a/src/nonstd/_FTM/_POSIX_SOURCE.c b/src/nonstd/_FTM/_POSIX_SOURCE.c deleted file mode 100644 index b594f3d9..00000000 --- a/src/nonstd/_FTM/_POSIX_SOURCE.c +++ /dev/null @@ -1,5 +0,0 @@ -#define _POSIX_SOURCE /** feature test macro **/ -/* -FTM(POSIX.1-1988) -POSIX(1) -*/ diff --git a/src/nonstd/_FTM/_XOPEN_SOURCE.c b/src/nonstd/_FTM/_XOPEN_SOURCE.c deleted file mode 100644 index e69de29b..00000000 diff --git a/src/nonstd/_FTM/_XOPEN_SOURCE_EXTENDED.c b/src/nonstd/_FTM/_XOPEN_SOURCE_EXTENDED.c deleted file mode 100644 index e69de29b..00000000 diff --git a/src/nonstd/_PREDEF/__DATE__.c b/src/nonstd/_PREDEF/__DATE__.c deleted file mode 100644 index 14e40fcb..00000000 --- a/src/nonstd/_PREDEF/__DATE__.c +++ /dev/null @@ -1,12 +0,0 @@ -#define __DATE__ /** date of compilation **/ - -/*** -is automatically defined by the compiler as the date of program -compilation, in the format DEFINITION("Mmm dd yyyy"). -***/ - -/* -VALUE_TYPE(string literal) -VALUE_FIXED(VAR("date-of-compilation")) -STDC(1) -*/ diff --git a/src/nonstd/_PREDEF/__FILE__.c b/src/nonstd/_PREDEF/__FILE__.c deleted file mode 100644 index 257ae89b..00000000 --- a/src/nonstd/_PREDEF/__FILE__.c +++ /dev/null @@ -1,14 +0,0 @@ -#define __FILE__ /** source file name **/ - -/*** -is automatically defined by the compiler as the file name of the -current source file being compiled as a character string literal. - -THIS() can be changed using PPDIR(line). -***/ - -/* -VALUE_TYPE(string literal) -VALUE_FIXED(VAR(the current file name)) -STDC(1) -*/ diff --git a/src/nonstd/_PREDEF/__LINE__.c b/src/nonstd/_PREDEF/__LINE__.c deleted file mode 100644 index c6acb1b1..00000000 --- a/src/nonstd/_PREDEF/__LINE__.c +++ /dev/null @@ -1,14 +0,0 @@ -#define __LINE__ /** source file line number **/ - -/*** -is automatically defined by the compiler as the current logical source -line in the source file being compiled. - -THIS() can be changed during compilation using PPDIR(line). -***/ - -/* -VALUE_TYPE(TYPE(int)) -VALUE_FIXED(VAR(the current line number)) -STDC(1) -*/ diff --git a/src/nonstd/_PREDEF/__STDC_HOSTED__.c b/src/nonstd/_PREDEF/__STDC_HOSTED__.c deleted file mode 100644 index 48fe28b7..00000000 --- a/src/nonstd/_PREDEF/__STDC_HOSTED__.c +++ /dev/null @@ -1,10 +0,0 @@ -#define __STDC_HOSTED__ /** hosted or free-standing implementation **/ - -/*** -is defined to the integer constant CONST(1) if the implementation -is hosted, CONST(0) otherwise. -***/ - -/* -STDC(199901) -*/ diff --git a/src/nonstd/_PREDEF/__STDC_IEC_559_COMPLEX__.c b/src/nonstd/_PREDEF/__STDC_IEC_559_COMPLEX__.c deleted file mode 100644 index a8d1f810..00000000 --- a/src/nonstd/_PREDEF/__STDC_IEC_559_COMPLEX__.c +++ /dev/null @@ -1,10 +0,0 @@ -#define __STDC_IEC_559_COMPLEX__ /** IEC 60559 complex arithmetic **/ - -/*** -is defined to CONST(1) if the implementation conforms to Annex G -of ISO/IEC 9899 (IEC 60559 complex arithmetic). -***/ - -/* -STDC(199901) -*/ diff --git a/src/nonstd/_PREDEF/__STDC_IEC_559__.c b/src/nonstd/_PREDEF/__STDC_IEC_559__.c deleted file mode 100644 index bdc441c4..00000000 --- a/src/nonstd/_PREDEF/__STDC_IEC_559__.c +++ /dev/null @@ -1,10 +0,0 @@ -#define __STDC_IEC_559__ /** IEC 60559 floating-point arithmetic **/ - -/*** -is defined to CONST(1) if the implementation conforms to Annex G -of ISO/IEC 9899 (IEC 60559 floating-point arithmetic). -***/ - -/* -STDC(199901) -*/ diff --git a/src/nonstd/_PREDEF/__STDC_ISO_10646__.c b/src/nonstd/_PREDEF/__STDC_ISO_10646__.c deleted file mode 100644 index 3379c855..00000000 --- a/src/nonstd/_PREDEF/__STDC_ISO_10646__.c +++ /dev/null @@ -1,13 +0,0 @@ -#define __STDC_ISO_10646__ /** supported UCS version **/ - -/*** -is defined if TYPE(wchar_t) represents characters encoded -in conformance with ISO/IEC 10646. In this case, THIS() is -defined as an integer CONST(yyyymmL), where CONST(yyyy) -represents the year and CONST(mm) the month of the supported -version of ISO/IEC 10646. -***/ - -/* -STDC(199901) -*/ diff --git a/src/nonstd/_PREDEF/__STDC_VERSION__.c b/src/nonstd/_PREDEF/__STDC_VERSION__.c deleted file mode 100644 index 56a23d90..00000000 --- a/src/nonstd/_PREDEF/__STDC_VERSION__.c +++ /dev/null @@ -1,13 +0,0 @@ -#define __STDC_VERSION__ /** supported C standard **/ - -/*** -declares the supported version of ISO/IEC 9899. If THIS() is not defined, -the implementation only supports ISO/IEC 9899:1990, without AMD1. -***/ - -/* -VALUE_SELECT(`199409L', `ISO/IEC 9899:1990 AMD1') -VALUE_SELECT(`199901L', `ISO/IEC 9899:1999') -VALUE_SELECT(`201112L', `ISO/IEC 9899:2011') -STDC(199409) -*/ diff --git a/src/nonstd/_PREDEF/__STDC__.c b/src/nonstd/_PREDEF/__STDC__.c deleted file mode 100644 index 5bcfe7aa..00000000 --- a/src/nonstd/_PREDEF/__STDC__.c +++ /dev/null @@ -1,14 +0,0 @@ -#define __STDC__ (1) - -/** standard C support **/ - -/*** -is automatically defined by the compiler to indicate that it supports -some version of ISO/IEC 9899. -***/ - -/* -VALUE_TYPE(TYPE(int)) -VALUE_FIXED(1) -STDC(1) -*/ diff --git a/src/nonstd/_PREDEF/__TIME__.c b/src/nonstd/_PREDEF/__TIME__.c deleted file mode 100644 index 472e42c0..00000000 --- a/src/nonstd/_PREDEF/__TIME__.c +++ /dev/null @@ -1,12 +0,0 @@ -#define __TIME__ /** time of compilation **/ - -/*** -is automatically defined by the compiler as the time of compilation -in the format DEFINITION("hh:mm:ss"). -***/ - -/* -VALUE_TYPE(string literal) -VALUE_FIXED(VAR("time of compilation")) -STDC(1) -*/ diff --git a/src/nonstd/__libc_start.c b/src/nonstd/__libc_start.c deleted file mode 100644 index d8fd5875..00000000 --- a/src/nonstd/__libc_start.c +++ /dev/null @@ -1,48 +0,0 @@ -#include "stdlib.h" -#include "stdio.h" -#include "locale.h" -#include "../stdio/_stdio.h" - -#ifdef _POSIX_SOURCE -#define DEFAULT_LOCALE "POSIX" -#include "unistd.h" -#else -#define DEFAULT_LOCALE "C" -#include "../_syscall.h" -#include "../termios/NCCS.c" -#include "../termios/cc_t.c" -#include "../termios/tcflag_t.c" -#include "../termios/struct_termios.c" -static struct termios __tios; -#define isatty(fd) (__syscall(__syscall_lookup(tcgetattr), fd, &__tios) == 0) -#endif - -void __libc_start(int argc, char **argv) -{ - extern int main(int, char*[]); - - stdin = __stdio.FILES + 0; - stdin->fd = 0; - /* freopen(", "r", stdin); */ - setvbuf(stdin, NULL, isatty(0) ? _IOLBF : _IOFBF, BUFSIZ); - - stdout = __stdio.FILES + 1; - stdout->fd = 1; - /* freopen(NULL, "w", stdout); */ - setvbuf(stdin, NULL, isatty(1) ? _IOLBF : _IOFBF, BUFSIZ); - - stderr = __stdio.FILES + 2; - stderr->fd = 2; - /* freopen(NULL, "w", stderr); */ - setvbuf(stderr, NULL, _IONBF, 0); - - stdin->next = stdout; - stdout->next = stderr; - - stdout->prev = stdin; - stderr->prev = stdout; - - /* setlocale(LC_ALL, DEFAULT_LOCALE); */ - - exit(main(argc, argv)); -} diff --git a/src/nonstd/x86-32.s b/src/nonstd/x86-32.s deleted file mode 100644 index ad60201d..00000000 --- a/src/nonstd/x86-32.s +++ /dev/null @@ -1,18 +0,0 @@ -.global __syscall -__syscall: - 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/src/nonstd/x86-64.s b/src/nonstd/x86-64.s deleted file mode 100644 index 87ff1637..00000000 --- a/src/nonstd/x86-64.s +++ /dev/null @@ -1,21 +0,0 @@ -.global __syscall -__syscall: - mov %rdi, %rax - mov %rsi, %rdi - mov %rdx, %rsi - mov %rcx, %rdx - mov %r8, %r10 - mov %r9, %r8 - mov 8(%rsp), %r9 - syscall - ret - -.global _start -_start: - popq %rdi - movq %rsp, %rsi - call __libc_start - -.global __stack_chk_fail -__stack_chk_fail: - ret -- cgit v1.2.1