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(
18
18
libc.src.stdio.printf_core.printf_main
19
19
libc.src.stdio.printf_core.writer
20
20
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
21
33
)
Original file line number Diff line number Diff line change 7
7
// ===----------------------------------------------------------------------===//
8
8
9
9
#include " src/stdio/printf.h"
10
+ #include " src/__support/OSUtil/io.h"
10
11
#include " src/__support/arg_list.h"
11
12
#include " src/stdio/printf_core/core_structs.h"
12
13
#include " src/stdio/printf_core/printf_main.h"
13
14
#include " src/stdio/printf_core/writer.h"
14
15
15
16
#include < stdarg.h>
16
17
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
-
22
18
namespace LIBC_NAMESPACE {
23
19
24
20
namespace {
25
21
26
22
LIBC_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);
30
24
return printf_core::WRITE_OK;
31
25
}
32
26
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