diff options
Diffstat (limited to 'libc-top-half/musl/src/stdio/fileno.c')
-rw-r--r-- | libc-top-half/musl/src/stdio/fileno.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/stdio/fileno.c b/libc-top-half/musl/src/stdio/fileno.c new file mode 100644 index 0000000..0bd0e98 --- /dev/null +++ b/libc-top-half/musl/src/stdio/fileno.c @@ -0,0 +1,16 @@ +#include "stdio_impl.h" +#include <errno.h> + +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); |