[libc-commits] [libc] [libc] Add getc, ungetc, fflush to enable libc++ iostream on baremetal (PR #175530)

Petr Hosek via libc-commits libc-commits at lists.llvm.org
Wed Feb 11 00:59:49 PST 2026


================
@@ -32,11 +32,34 @@ struct FileIOResult {
   constexpr operator size_t() { return value; }
 };
 
+// ungetc handling.
+int push_ungetc_value(::FILE *stream, int c);
+bool pop_ungetc_value(::FILE *stream, unsigned char &out);
+namespace internal {
+int ungetc_internal(int c, ::FILE *stream);
+} // namespace internal
----------------
petrhosek wrote:

We don't put the other functions like `read_internal` or `write_internal` into `internal` namespace so I'd avoid it here as well for consistency plus I don't think it's really needed since the function already has `_internal` in the name.

```suggestion
int ungetc_internal(int c, ::FILE *stream);
```

https://github.com/llvm/llvm-project/pull/175530


More information about the libc-commits mailing list