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

Volodymyr Turanskyy via libc-commits libc-commits at lists.llvm.org
Wed Jan 28 08:11:28 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); }
----------------
voltur01 wrote:

Thank you for the review and pointing out the incorrect dependency - I moved `ungetc` implementation into an internal helper and updated to use it here.

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


More information about the libc-commits mailing list