[libc-commits] [PATCH] D157821: [libc] add fileno function for Linux
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Mon Aug 14 16:52:21 PDT 2023
sivachandra added inline comments.
================
Comment at: libc/config/linux/x86_64/entrypoints.txt:430
libc.src.stdio.fflush
+ libc.src.stdio.fileno
libc.src.stdio.fopen
----------------
Can we add this to the other configs also?
================
Comment at: libc/src/stdio/fileno.cpp:18
+LLVM_LIBC_FUNCTION(int, fileno, (::FILE *__restrict stream)) {
+ auto fd = get_fileno(reinterpret_cast<__llvm_libc::File *>(stream));
+
----------------
This is not a fully evolved API yet. For example, the Linux implementation does not try to check if `stream` is actually a file stream. But, we have not yet decided if the `get_fileno` should be responsible to perform that check, or if it is the job of this function to perform that check. It feels like we should have some kind of flag maintained in the `File` data structure to indicate whether `stream` has a number or not. Let me think about this and get back. If you have any better suggestions to make, feel free to share.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D157821/new/
https://reviews.llvm.org/D157821
More information about the libc-commits
mailing list