Skip to content

Commit 9b4168f

Browse files
committed
fixup! fixup! fixup! fixup! fixup! fixup! [libc] Add putc, fputc, and fprintf to stdio/baremetal
1 parent 94ea13f commit 9b4168f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

libc/src/stdio/baremetal/fprintf.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ LLVM_LIBC_FUNCTION(int, fprintf,
3030
static constexpr size_t BUFF_SIZE = 1024;
3131
char buffer[BUFF_SIZE];
3232

33+
write_utils::StreamWriter write_hook = write_utils::get_write_hook(stream);
34+
if (write_hook == nullptr) {
35+
return 0;
36+
}
37+
3338
printf_core::WriteBuffer<printf_core::WriteMode::FLUSH_TO_STREAM> wb(
3439
buffer, BUFF_SIZE, write_utils::get_write_hook(stream), nullptr);
3540
printf_core::Writer<printf_core::WriteMode::FLUSH_TO_STREAM> writer(wb);

libc/src/stdio/baremetal/write_utils.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "hdr/types/FILE.h"
1111
#include "src/__support/CPP/string_view.h"
1212
#include "src/__support/OSUtil/io.h"
13-
#include "src/__support/libc_errno.h"
1413
#include "src/__support/macros/config.h"
1514
#include "src/stdio/baremetal/write_hooks.h"
1615

@@ -23,7 +22,7 @@ LIBC_INLINE void write(::FILE *f, cpp::string_view new_str) {
2322
} else if (f == stderr) {
2423
write_to_stderr(new_str);
2524
} else {
26-
libc_errno = 1;
25+
// Do nothing
2726
}
2827
}
2928

@@ -35,8 +34,7 @@ LIBC_INLINE StreamWriter get_write_hook(::FILE *f) {
3534
return &stderr_write_hook;
3635
}
3736

38-
libc_errno = 1;
39-
return NULL;
37+
return nullptr;
4038
}
4139

4240
} // namespace write_utils

0 commit comments

Comments
 (0)