[libc-commits] [libc] [libc] Provide baremetal implementation of getchar (PR #98059)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Mon Jul 8 13:49:20 PDT 2024


================
@@ -11,10 +11,19 @@
 #include "src/__support/CPP/string_view.h"
 
 // This is intended to be provided by the vendor.
+
+extern struct __llvm_libc_stdin __llvm_libc_stdin;
+extern "C" ssize_t __llvm_libc_stdin_read(void *cookie, char *buf, size_t size);
+
 extern "C" void __llvm_libc_log_write(const char *msg, size_t len);
 
 namespace LIBC_NAMESPACE {
 
+ssize_t read_from_stdin(char *buf, size_t size) {
+  return __llvm_libc_stdin_read(static_cast<void *>(&__llvm_libc_stdin), buf,
----------------
michaelrj-google wrote:

nit: this should probably be a `reinterpret_cast` instead of `static_cast`

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


More information about the libc-commits mailing list