From 4abab5ad6c8465a7528ccdd5f49367da05f78bbd Mon Sep 17 00:00:00 2001 From: Vladimir Azarov Date: Tue, 1 Oct 2024 15:47:05 +0200 Subject: Initial version --- src/stdio/fileno.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/stdio/fileno.c (limited to 'src/stdio/fileno.c') diff --git a/src/stdio/fileno.c b/src/stdio/fileno.c new file mode 100644 index 0000000..0bd0e98 --- /dev/null +++ b/src/stdio/fileno.c @@ -0,0 +1,16 @@ +#include "stdio_impl.h" +#include + +int fileno(FILE *f) +{ + FLOCK(f); + int fd = f->fd; + FUNLOCK(f); + if (fd < 0) { + errno = EBADF; + return -1; + } + return fd; +} + +weak_alias(fileno, fileno_unlocked); -- cgit v1.2.3