aboutsummaryrefslogtreecommitdiff
path: root/src/stdio/fileno.c
blob: 3b8fc97f5f3cb7a0eba61b215e5b1b3746d4114c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#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);


#ifdef TEST
int
main(void) {
	return 0;
}
#endif