File tree Expand file tree Collapse file tree 3 files changed +37
-8
lines changed Expand file tree Collapse file tree 3 files changed +37
-8
lines changed Original file line number Diff line number Diff line change @@ -18,4 +18,16 @@ add_entrypoint_object(
1818 libc.src.stdio.printf_core.printf_main
1919 libc.src.stdio.printf_core.writer
2020 libc.src.__support.arg_list
21+ libc.src.__support.OSUtil.osutil
22+ )
23+
24+ add_entrypoint_object(
25+ putchar
26+ SRCS
27+ putchar.cpp
28+ HDRS
29+ ../putchar.h
30+ DEPENDS
31+ libc.src.__support.OSUtil.osutil
32+ libc.src.__support.CPP.string_view
2133)
Original file line number Diff line number Diff line change 77// ===----------------------------------------------------------------------===//
88
99#include " src/stdio/printf.h"
10+ #include " src/__support/OSUtil/io.h"
1011#include " src/__support/arg_list.h"
1112#include " src/stdio/printf_core/core_structs.h"
1213#include " src/stdio/printf_core/printf_main.h"
1314#include " src/stdio/printf_core/writer.h"
1415
1516#include < stdarg.h>
1617
17- // TODO(https://github.com/llvm/llvm-project/issues/94685) unify baremetal hooks
18-
19- // This is intended to be provided by the vendor.
20- extern " C" size_t __llvm_libc_raw_write (const char *s, size_t size);
21-
2218namespace LIBC_NAMESPACE {
2319
2420namespace {
2521
2622LIBC_INLINE int raw_write_hook (cpp::string_view new_str, void *) {
27- size_t written = __llvm_libc_raw_write (new_str.data (), new_str.size ());
28- if (written != new_str.size ())
29- return printf_core::FILE_WRITE_ERROR;
23+ write_to_stderr (new_str);
3024 return printf_core::WRITE_OK;
3125}
3226
Original file line number Diff line number Diff line change 1+ // ===-- Baremetal Implementation of putchar -------------------------------===//
2+ //
3+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+ // See https://llvm.org/LICENSE.txt for license information.
5+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+ //
7+ // ===----------------------------------------------------------------------===//
8+
9+ #include " src/stdio/putchar.h"
10+ #include " src/__support/CPP/string_view.h"
11+ #include " src/__support/OSUtil/io.h"
12+
13+ namespace LIBC_NAMESPACE {
14+
15+ LLVM_LIBC_FUNCTION (int , putchar, (int c)) {
16+ char uc = static_cast <char >(c);
17+
18+ write_to_stderr (cpp::string_view (&uc, 1 ));
19+
20+ return 0 ;
21+ }
22+
23+ } // namespace LIBC_NAMESPACE
You can’t perform that action at this time.
0 commit comments