1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include <io.h> #include <errno.h> #include <atomic.h> #include <stdio.h> int fileno(FILE *stream) { int fd; LIBC_LOCK(stream->lock); fd = stream->fd; LIBC_UNLOCK(stream->lock); if (fd < 0) { errno = EBADF; return -1; } return fd; }