Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions libc/src/stdio/baremetal/printf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace LIBC_NAMESPACE_DECL {

namespace {

LIBC_INLINE int raw_write_hook(cpp::string_view new_str, void *) {
write_to_stderr(new_str);
LIBC_INLINE int stdout_write_hook(cpp::string_view new_str, void *) {
write_to_stdout(new_str);
return printf_core::WRITE_OK;
}

Expand All @@ -35,11 +35,11 @@ LLVM_LIBC_FUNCTION(int, printf, (const char *__restrict format, ...)) {
// and pointer semantics, as well as handling
// destruction automatically.
va_end(vlist);
constexpr size_t BUFF_SIZE = 1024;
static constexpr size_t BUFF_SIZE = 1024;
char buffer[BUFF_SIZE];

printf_core::WriteBuffer<printf_core::WriteMode::FLUSH_TO_STREAM> wb(
buffer, BUFF_SIZE, &raw_write_hook, nullptr);
buffer, BUFF_SIZE, &stdout_write_hook, nullptr);
printf_core::Writer<printf_core::WriteMode::FLUSH_TO_STREAM> writer(wb);

int retval = printf_core::printf_main(&writer, format, args);
Expand Down
2 changes: 1 addition & 1 deletion libc/src/stdio/baremetal/putchar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(int, putchar, (int c)) {
char uc = static_cast<char>(c);

write_to_stderr(cpp::string_view(&uc, 1));
write_to_stdout(cpp::string_view(&uc, 1));

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions libc/src/stdio/baremetal/puts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ LLVM_LIBC_FUNCTION(int, puts, (const char *__restrict str)) {
cpp::string_view str_view(str);

// TODO: Can we combine these to avoid needing two writes?
write_to_stderr(str_view);
write_to_stderr("\n");
write_to_stdout(str_view);
write_to_stdout("\n");

return 0;
}
Expand Down
8 changes: 4 additions & 4 deletions libc/src/stdio/baremetal/vprintf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace LIBC_NAMESPACE_DECL {

namespace {

LIBC_INLINE int raw_write_hook(cpp::string_view new_str, void *) {
write_to_stderr(new_str);
LIBC_INLINE int stdout_write_hook(cpp::string_view new_str, void *) {
write_to_stdout(new_str);
return printf_core::WRITE_OK;
}

Expand All @@ -33,11 +33,11 @@ LLVM_LIBC_FUNCTION(int, vprintf,
internal::ArgList args(vlist); // This holder class allows for easier copying
// and pointer semantics, as well as handling
// destruction automatically.
constexpr size_t BUFF_SIZE = 1024;
static constexpr size_t BUFF_SIZE = 1024;
char buffer[BUFF_SIZE];

printf_core::WriteBuffer<printf_core::WriteMode::FLUSH_TO_STREAM> wb(
buffer, BUFF_SIZE, &raw_write_hook, nullptr);
buffer, BUFF_SIZE, &stdout_write_hook, nullptr);
printf_core::Writer<printf_core::WriteMode::FLUSH_TO_STREAM> writer(wb);

int retval = printf_core::printf_main(&writer, format, args);
Expand Down
Loading