From 0f30d227497418c6d3bef7d52244407e30454504 Mon Sep 17 00:00:00 2001 From: Kacper Date: Mon, 22 Dec 2025 23:27:56 +0100 Subject: Added c11 threads, fixed some locks and add *_unlocked functions --- lib/libc/internal/init/io.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 lib/libc/internal/init/io.c (limited to 'lib/libc/internal/init/io.c') diff --git a/lib/libc/internal/init/io.c b/lib/libc/internal/init/io.c new file mode 100644 index 00000000..4790af89 --- /dev/null +++ b/lib/libc/internal/init/io.c @@ -0,0 +1,42 @@ +#include +#include +#include +#include +#include + +struct __FILE *const stdout = (struct __FILE *)&__libc.stdout; +struct __FILE *const stdin = (struct __FILE *)&__libc.stdin; +struct __FILE *const stderr = (struct __FILE *)&__libc.stderr; + +void __libc_init_io(void) +{ + /* stdout */ + memset(&__libc.stdout, 0, sizeof(struct __FILE)); + __libc.stdout.fd = STDOUT_FILENO; + __libc.stdout.flags = O_WRONLY; + __libc.stdout.type = _IOLBF; + __libc.stdout.buf = NULL; + __libc.stdout.buf_size = 0; + __libc.stdout.buf_len = 0; + __libc.stdout.buf_pos = 0; + + /* stdin */ + memset(&__libc.stdin, 0, sizeof(struct __FILE)); + __libc.stdin.fd = STDIN_FILENO; + __libc.stdin.flags = O_RDONLY; + __libc.stdin.type = _IONBF; + __libc.stdin.buf = NULL; + __libc.stdin.buf_size = 0; + __libc.stdin.buf_len = 0; + __libc.stdin.buf_pos = 0; + + /* stderr */ + memset(&__libc.stderr, 0, sizeof(struct __FILE)); + __libc.stderr.fd = STDERR_FILENO; + __libc.stderr.flags = O_WRONLY; + __libc.stderr.type = _IONBF; + __libc.stderr.buf = NULL; + __libc.stderr.buf_size = 0; + __libc.stderr.buf_len = 0; + __libc.stderr.buf_pos = 0; +} -- cgit v1.2.3