From 8acc7de89c36d3a02a70f9aa3b83189ab6569929 Mon Sep 17 00:00:00 2001 From: g1n Date: Thu, 30 Dec 2021 22:09:36 +0200 Subject: [PATCH] Fixed stdin/stdout/stderr declarations --- examples/hello.c | 2 +- src/liblinux.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/examples/hello.c b/examples/hello.c index 3787695..0489eb3 100644 --- a/examples/hello.c +++ b/examples/hello.c @@ -2,6 +2,6 @@ int main() { char hellostr[] = "Hello, World!\n"; - sys_write(0, hellostr, sizeof(hellostr)); + sys_write(stdout->fd, hellostr, sizeof(hellostr)); return 0; } diff --git a/src/liblinux.c b/src/liblinux.c index 477234e..bd2c723 100644 --- a/src/liblinux.c +++ b/src/liblinux.c @@ -1,9 +1,23 @@ #include #include -FILE *stdin = {0}; // FIXME -FILE *stdout = {1}; -FILE *stderr = {2}; +FILE __stdin_FILE = { + .fd = 0 +}; + +FILE *stdin = &__stdin_FILE; + +FILE __stdout_FILE = { + .fd = 1 +}; + +FILE *stdout = &__stdout_FILE; + +FILE __stderr_FILE = { + .fd = 2 +}; + +FILE *stderr = &__stderr_FILE; _Noreturn void sys_exit(int status) { syscall(__NR_exit, status);