summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-08-11 11:11:53 -0400
committerJakob Kaivo <jkk@ung.org>2020-08-11 11:11:53 -0400
commit17ad48fef73839e9d36c89d5054a7bd2a72b14ac (patch)
tree2a06499249fdd395371312f16552c17fa296f09a /src
parentaa30cdc2098ca309668517f8e3a240792d24d1a0 (diff)
move array of __FILE structs from __libc() to _stdio internal
Diffstat (limited to 'src')
-rw-r--r--src/nonstd/__libc.c5
-rw-r--r--src/nonstd/__libc_start.c14
-rw-r--r--src/stdio/__FILES.c2
-rw-r--r--src/stdio/_stdio.h2
4 files changed, 10 insertions, 13 deletions
diff --git a/src/nonstd/__libc.c b/src/nonstd/__libc.c
index 9471558d..7ef57432 100644
--- a/src/nonstd/__libc.c
+++ b/src/nonstd/__libc.c
@@ -10,7 +10,6 @@ void *__libc(LIBC_INTERNAL variable)
{
extern void *__libc_per_thread(LIBC_INTERNAL __variable);
static struct __locale_t locale;
- static struct __FILE file_streams[FOPEN_MAX];
void *r = (void*)0;
@@ -65,10 +64,6 @@ void *__libc(LIBC_INTERNAL variable)
r = (void*)__syscall_lookup;
break;
- case FILE_STREAMS:
- r = file_streams;
- break;
-
case LOAD_LOCALE:
r = (void*)(__load_locale);
break;
diff --git a/src/nonstd/__libc_start.c b/src/nonstd/__libc_start.c
index 4b0b773e..924029d7 100644
--- a/src/nonstd/__libc_start.c
+++ b/src/nonstd/__libc_start.c
@@ -20,21 +20,20 @@ static struct termios __tios;
void __libc_start(int argc, char **argv)
{
extern int main(int, char*[]);
- struct __FILE *files = __libc(FILE_STREAMS);
- stdin = files + 0;
+ stdin = __FILES + 0;
stdin->fd = 0;
- freopen(NULL, "r", stdin);
+ /* freopen(", "r", stdin); */
setvbuf(stdin, NULL, isatty(0) ? _IOLBF : _IOFBF, BUFSIZ);
- stdout = files + 1;
+ stdout = __FILES + 1;
stdout->fd = 1;
- freopen(NULL, "w", stdout);
+ /* freopen(NULL, "w", stdout); */
setvbuf(stdin, NULL, isatty(1) ? _IOLBF : _IOFBF, BUFSIZ);
- stderr = files + 2;
+ stderr = __FILES + 2;
stderr->fd = 2;
- freopen(NULL, "w", stderr);
+ /* freopen(NULL, "w", stderr); */
setvbuf(stderr, NULL, _IONBF, 0);
stdin->next = stdout;
@@ -45,6 +44,5 @@ void __libc_start(int argc, char **argv)
setlocale(LC_ALL, DEFAULT_LOCALE);
-
exit(main(argc, argv));
}
diff --git a/src/stdio/__FILES.c b/src/stdio/__FILES.c
new file mode 100644
index 00000000..f9bcdbba
--- /dev/null
+++ b/src/stdio/__FILES.c
@@ -0,0 +1,2 @@
+#include "_stdio.h"
+struct __FILE __FILES[FOPEN_MAX];
diff --git a/src/stdio/_stdio.h b/src/stdio/_stdio.h
index 84ad60ca..6cb0ab0c 100644
--- a/src/stdio/_stdio.h
+++ b/src/stdio/_stdio.h
@@ -54,6 +54,8 @@ struct io_options {
int __printf(struct io_options * restrict, const char * restrict, va_list);
int __scanf(struct io_options * restrict, const char * restrict, va_list);
+extern struct __FILE __FILES[FOPEN_MAX];
+
#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 199506L
#define flockfile(_file) (void)(_file)
#define funlockfile(_file) (void)(_file)