summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-28 14:54:24 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-28 14:54:24 -0500
commita7b88fa1dacaf822fb0b12c62705eff45d551bc7 (patch)
treeb83537437ba94b72a30ac7494a8f6577e6c6a8ce /src
parent5e7c2c33880fc104b28043c25087624ebd4dc122 (diff)
use the internal array of FILE streams for stdin/stdout/stderr
Diffstat (limited to 'src')
-rw-r--r--src/nonstd/__libc_start.c20
1 files changed, 13 insertions, 7 deletions
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");