summaryrefslogtreecommitdiff
path: root/lib/libc/internal/init/io.c
diff options
context:
space:
mode:
authorKacper <kacper@mail.openlinux.dev>2025-12-22 23:27:56 +0100
committerKacper <kacper@mail.openlinux.dev>2025-12-22 23:30:32 +0100
commit0f30d227497418c6d3bef7d52244407e30454504 (patch)
tree0e1ac19623d3268380cf74328cdf643648a2f43c /lib/libc/internal/init/io.c
parent90dad97fc07f049383903a166631e2c257f9b8c1 (diff)
Added c11 threads, fixed some locks and add *_unlocked functions
Diffstat (limited to 'lib/libc/internal/init/io.c')
-rw-r--r--lib/libc/internal/init/io.c42
1 files changed, 42 insertions, 0 deletions
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 <atomic.h>
+#include <fcntl.h>
+#include <libc.h>
+#include <stdio.h>
+#include <unistd.h>
+
+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;
+}