From b5fce270377d08729b156c2069c8123627d1fee5 Mon Sep 17 00:00:00 2001 From: EnderIce2 Date: Wed, 19 Feb 2025 21:57:51 +0200 Subject: [PATCH] feat(userspace/libc): implement getchar() and getc() Signed-off-by: EnderIce2 --- Userspace/libc/include/stdio.h | 2 +- Userspace/libc/src/std/stdio.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Userspace/libc/include/stdio.h b/Userspace/libc/include/stdio.h index 5377c645..fc25c379 100644 --- a/Userspace/libc/include/stdio.h +++ b/Userspace/libc/include/stdio.h @@ -115,7 +115,7 @@ extern "C" int ftrylockfile(FILE *); void funlockfile(FILE *); size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream); - int getc(FILE *); + int getc(FILE *stream); int getchar(void); int getc_unlocked(FILE *); int getchar_unlocked(void); diff --git a/Userspace/libc/src/std/stdio.c b/Userspace/libc/src/std/stdio.c index 4b4e0a21..697502bb 100644 --- a/Userspace/libc/src/std/stdio.c +++ b/Userspace/libc/src/std/stdio.c @@ -347,8 +347,16 @@ export size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE return bytes_written / size; } -export int getc(FILE *); -export int getchar(void); +export int getc(FILE *stream) +{ + return fgetc(stream); +} + +export int getchar(void) +{ + return getc(stdin); +} + export int getc_unlocked(FILE *); export int getchar_unlocked(void); export ssize_t getdelim(char **restrict, size_t *restrict, int, FILE *restrict);