libc: io: implement file io buffering and internal locking for concurrency

This commit is contained in:
2026-04-01 18:51:13 +01:00
parent f2e650d368
commit 548387c43a
23 changed files with 948 additions and 73 deletions
+27
View File
@@ -0,0 +1,27 @@
#include "file.h"
#include <stddef.h>
#include <stdio.h>
extern int __libc_fctprintf(
void (*out)(char character, void *arg),
void *arg,
const char *format,
va_list va);
extern int __fputc(int c, struct __opaque_file *stream);
static inline void _out_file(char character, void *arg)
{
struct __opaque_file *fp = arg;
__fputc(character, fp);
}
int vprintf(const char *format, va_list arg)
{
__libc_file_lock(stdout);
int ret = __libc_fctprintf(_out_file, stdout, format, arg);
__libc_file_unlock(stdout);
return ret;
}