summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/fileno.c
blob: 09db0ad5df13479e16f731a0b1e27c8f3ab235f6 (plain)
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;
}