diff options
| author | Kacper <kacper@mail.openlinux.dev> | 2025-12-22 23:27:56 +0100 |
|---|---|---|
| committer | Kacper <kacper@mail.openlinux.dev> | 2025-12-22 23:30:32 +0100 |
| commit | 0f30d227497418c6d3bef7d52244407e30454504 (patch) | |
| tree | 0e1ac19623d3268380cf74328cdf643648a2f43c /lib/libc/stdio/fileno.c | |
| parent | 90dad97fc07f049383903a166631e2c257f9b8c1 (diff) | |
Added c11 threads, fixed some locks and add *_unlocked functions
Diffstat (limited to 'lib/libc/stdio/fileno.c')
| -rw-r--r-- | lib/libc/stdio/fileno.c | 20 |
1 files changed, 6 insertions, 14 deletions
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 <atomic.h> // for LIBC_LOCK, LIBC_UNLOCK -#include <errno.h> // for EBADF, errno -#include <stdio.h> // for FILE, fileno +#include <stdio.h> 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; } |
