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);