summaryrefslogtreecommitdiff
path: root/lib/libc/stdio/fileno_unlocked.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/stdio/fileno_unlocked.c')
-rw-r--r--lib/libc/stdio/fileno_unlocked.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/libc/stdio/fileno_unlocked.c b/lib/libc/stdio/fileno_unlocked.c
new file mode 100644
index 00000000..a3490686
--- /dev/null
+++ b/lib/libc/stdio/fileno_unlocked.c
@@ -0,0 +1,13 @@
+#include <__stdio.h>
+#include <errno.h>
+#include <stdio.h>
+
+int fileno_unlocked(FILE *stream)
+{
+ if (stream->fd < 0) {
+ errno = EBADF;
+ return -1;
+ }
+
+ return stream->fd;
+}