From a7b88fa1dacaf822fb0b12c62705eff45d551bc7 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Thu, 28 Feb 2019 14:54:24 -0500 Subject: use the internal array of FILE streams for stdin/stdout/stderr --- src/nonstd/__libc_start.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/nonstd/__libc_start.c b/src/nonstd/__libc_start.c index e10e081e..f9fadfd5 100644 --- a/src/nonstd/__libc_start.c +++ b/src/nonstd/__libc_start.c @@ -5,16 +5,22 @@ void __libc_start(int argc, char **argv) { - struct __FILE sin, sout, serr; + struct __FILE *files = __libc(FILE_STREAMS); - sin.fd = 0; - stdin = &sin; + stdin = files + 0; + stdin->fd = 0; - sout.fd = 1; - stdout = &sout; + stdout = files + 1; + stdout->fd = 1; - serr.fd = 2; - stderr = &serr; + stderr = files + 2; + stderr->fd = 2; + + stdin->next = stdout; + stdout->next = stderr; + + stdout->prev = stdin; + stderr->prev = stdout; #if defined _POSIX_SOURCE setlocale(LC_ALL, "POSIX"); -- cgit v1.2.1