[libc-commits] [libc] [libc] Add baremetal printf (PR #94078)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Tue Jun 4 15:50:56 PDT 2024


================
@@ -0,0 +1,51 @@
+//===-- Implementation of printf for baremetal ------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/stdio/printf.h"
+#include "src/__support/arg_list.h"
+#include "src/stdio/printf_core/core_structs.h"
+#include "src/stdio/printf_core/printf_main.h"
+#include "src/stdio/printf_core/writer.h"
+
+#include <stdarg.h>
+
+// This is intended to be provided by the vendor. Name TBD
+extern "C" size_t __llvm_libc_raw_write(const char *s, size_t size);
----------------
michaelrj-google wrote:

having thought about it some more, I think the best solution might be to add a `write_to_stdout` that can be used by not just `printf` but also `puts` and `putchar` in future. I'll update this PR with what I currently have and then try making a version with this new design so that we can compare.

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


More information about the libc-commits mailing list