diff --git a/libc/include/stdio.h b/libc/include/stdio.h index de22722f..831d0069 100644 --- a/libc/include/stdio.h +++ b/libc/include/stdio.h @@ -32,6 +32,9 @@ extern "C" /* Close a file and frees up its stream. */ int fclose(FILE* stream); + /* Return the file descriptor associated with a stream. */ + int fileno(FILE* stream); + /* Read arbitrarily sized items from a stream. */ size_t fread(void* buf, size_t size, size_t nmemb, FILE* stream); diff --git a/libc/src/stdio.cpp b/libc/src/stdio.cpp index e34f59d0..e6f3ff8e 100644 --- a/libc/src/stdio.cpp +++ b/libc/src/stdio.cpp @@ -66,6 +66,11 @@ extern "C" return 0; } + int fileno(FILE* stream) + { + return stream->_fd; + } + size_t fread(void* buf, size_t size, size_t nmemb, FILE* stream) { if (size * nmemb == 0) return 0;