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