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/fileno.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'lib/libc/stdio/fileno.c') diff --git a/lib/libc/stdio/fileno.c b/lib/libc/stdio/fileno.c index e27b56de..4fa47eb4 100644 --- a/lib/libc/stdio/fileno.c +++ b/lib/libc/stdio/fileno.c @@ -1,20 +1,12 @@ -#include <__stdio.h> // for __FILE -#include // for LIBC_LOCK, LIBC_UNLOCK -#include // for EBADF, errno -#include // for FILE, fileno +#include int fileno(FILE *stream) { - int fd; + int r; - LIBC_LOCK(__FILE(stream)->lock); - fd = __FILE(stream)->fd; - LIBC_UNLOCK(__FILE(stream)->lock); + flockfile(stream); + r = fileno_unlocked(stream); + funlockfile(stream); - if (fd < 0) { - errno = EBADF; - return -1; - } - - return fd; + return r; } -- cgit v1.2.3