Can we add this to the other configs also?
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.
@sivachandra: Yes, I also wondered about that (re: "Linux implementation does not try to check if stream is actually a file stream"). I don't know what the best solution is. I tried both glibc and llvm-libc with invalid stream as argument and both crashed. Seems like musl libc also just assumes that the file ptr is valid https://elixir.bootlin.com/musl/latest/source/src/stdio/fileno.c#L7