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/stdio/fgets.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'lib/libc/stdio/fgets.c') diff --git a/lib/libc/stdio/fgets.c b/lib/libc/stdio/fgets.c index adeae1b4..d0f7d2d9 100644 --- a/lib/libc/stdio/fgets.c +++ b/lib/libc/stdio/fgets.c @@ -1,11 +1,12 @@ -#include "stddef.h" // for NULL - -#include // for weak_reference -#include // for fread, FILE, fgets +#include char *fgets(char *restrict s, int n, FILE *restrict stream) { - return fread(s, 1, n, stream) ? s : NULL; -} + char *r; -weak_reference(fgets, fgets_unlocked); + flockfile(stream); + r = fgets_unlocked(s, n, stream); + funlockfile(stream); + + return r; +} -- cgit v1.2.3