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

Michael Jones via libc-commits libc-commits at lists.llvm.org
Fri May 31 16:26:38 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:

I'd say `raw_write` and `write_to_stderr` are (in my mind) different in the same way `stdout` and `stderr` are. The intent for `stdout` is for normal output, whereas the intent for `stderr` is error messages. That being said, I should probably move this to `OSUtil` so that it's in the same place as `write_to_stderr`.

As for using `FILE` as an opaque handle, that probably would work, but the request from @petrhosek was for a printf that only writes to the provided function.

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


More information about the libc-commits mailing list