[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 Jan 28 01:18:36 PST 2026
================
@@ -33,12 +35,12 @@ class StreamReader : public scanf_core::Reader<StreamReader> {
LIBC_INLINE char getc() {
char c;
- auto result = __llvm_libc_stdio_read(stream, &c, 1);
+ auto result = read_internal(&c, 1, stream);
if (result != 1)
return '\0';
return c;
}
- LIBC_INLINE void ungetc(int) {}
+ LIBC_INLINE void ungetc(int c) { (void)LIBC_NAMESPACE::ungetc(c, stream); }
----------------
petrhosek wrote:
We should have an internal `ungetc` implementation and use it here rather than calling an entrypoint (in case the `ungetc` entrypoint is not included).
https://github.com/llvm/llvm-project/pull/175530
More information about the libc-commits
mailing list