Skip to content

Commit c1ba4d6

Browse files
committed
[libc] Add support for std::cout on embedded
Fixes an bug with external linkage in stdout/stderr. Adds the required entrypoints for std::cout.
1 parent 78e3a58 commit c1ba4d6

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

libc/config/baremetal/aarch64/entrypoints.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ set(TARGET_LIBC_ENTRYPOINTS
124124

125125
# stdio.h entrypoints
126126
libc.src.stdio.asprintf
127+
libc.src.stdio.fflush
127128
libc.src.stdio.fopencookie
128129
libc.src.stdio.fprintf
130+
libc.src.stdio.fwrite
131+
libc.src.stdio.getc
129132
libc.src.stdio.getchar
130133
libc.src.stdio.printf
131134
libc.src.stdio.putchar
@@ -135,7 +138,12 @@ set(TARGET_LIBC_ENTRYPOINTS
135138
libc.src.stdio.snprintf
136139
libc.src.stdio.sprintf
137140
libc.src.stdio.sscanf
141+
libc.src.stdio.stderr
142+
libc.src.stdio.stdin
143+
libc.src.stdio.stdout
144+
libc.src.stdio.ungetc
138145
libc.src.stdio.vasprintf
146+
libc.src.stdio.vfprintf
139147
libc.src.stdio.vprintf
140148
libc.src.stdio.vscanf
141149
libc.src.stdio.vsnprintf

libc/config/baremetal/arm/entrypoints.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ set(TARGET_LIBC_ENTRYPOINTS
124124

125125
# stdio.h entrypoints
126126
libc.src.stdio.asprintf
127+
libc.src.stdio.fflush
127128
libc.src.stdio.fopencookie
128129
libc.src.stdio.fprintf
130+
libc.src.stdio.fwrite
131+
libc.src.stdio.getc
129132
libc.src.stdio.getchar
130133
libc.src.stdio.printf
131134
libc.src.stdio.putchar
@@ -135,7 +138,12 @@ set(TARGET_LIBC_ENTRYPOINTS
135138
libc.src.stdio.snprintf
136139
libc.src.stdio.sprintf
137140
libc.src.stdio.sscanf
141+
libc.src.stdio.stderr
142+
libc.src.stdio.stdin
143+
libc.src.stdio.stdout
144+
libc.src.stdio.ungetc
138145
libc.src.stdio.vasprintf
146+
libc.src.stdio.vfprintf
139147
libc.src.stdio.vprintf
140148
libc.src.stdio.vscanf
141149
libc.src.stdio.vsnprintf

libc/config/baremetal/riscv/entrypoints.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,11 @@ set(TARGET_LIBC_ENTRYPOINTS
124124

125125
# stdio.h entrypoints
126126
libc.src.stdio.asprintf
127+
libc.src.stdio.fflush
127128
libc.src.stdio.fopencookie
128129
libc.src.stdio.fprintf
130+
libc.src.stdio.fwrite
131+
libc.src.stdio.getc
129132
libc.src.stdio.getchar
130133
libc.src.stdio.printf
131134
libc.src.stdio.putchar
@@ -135,7 +138,12 @@ set(TARGET_LIBC_ENTRYPOINTS
135138
libc.src.stdio.snprintf
136139
libc.src.stdio.sprintf
137140
libc.src.stdio.sscanf
141+
libc.src.stdio.stderr
142+
libc.src.stdio.stdin
143+
libc.src.stdio.stdout
144+
libc.src.stdio.ungetc
138145
libc.src.stdio.vasprintf
146+
libc.src.stdio.vfprintf
139147
libc.src.stdio.vprintf
140148
libc.src.stdio.vscanf
141149
libc.src.stdio.vsnprintf

libc/src/__support/File/baremetal/stderr.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
namespace LIBC_NAMESPACE_DECL {
1616

17-
cookie_io_functions_t io_func = {.read = nullptr,
18-
.write = __llvm_libc_stdio_write,
19-
.seek = nullptr,
20-
.close = nullptr};
17+
static cookie_io_functions_t io_func = {.read = nullptr,
18+
.write = __llvm_libc_stdio_write,
19+
.seek = nullptr,
20+
.close = nullptr};
2121
#pragma clang diagnostic push
2222
#pragma clang diagnostic ignored "-Wglobal-constructors"
2323
// Buffering is implementation defined. Therefore to save RAM, we use no

libc/src/__support/File/baremetal/stdin.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414

1515
namespace LIBC_NAMESPACE_DECL {
1616

17-
cookie_io_functions_t io_func = {.read = __llvm_libc_stdio_read,
18-
.write = nullptr,
19-
.seek = nullptr,
20-
.close = nullptr};
17+
static cookie_io_functions_t io_func = {.read = __llvm_libc_stdio_read,
18+
.write = nullptr,
19+
.seek = nullptr,
20+
.close = nullptr};
2121
#pragma clang diagnostic push
2222
#pragma clang diagnostic ignored "-Wglobal-constructors"
2323
// Buffering is implementation defined. Therefore to save RAM, we use no

0 commit comments

Comments
 (0)