[libc-commits] [PATCH] D149493: [libc] Fix printing on the GPU when given a `cpp::string_ref`
Joseph Huber via Phabricator via libc-commits
libc-commits at lists.llvm.org
Fri Apr 28 19:32:24 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG91528d205840: [libc] Fix printing on the GPU when given a `cpp::string_ref` (authored by jhuber6).
Changed prior to commit:
https://reviews.llvm.org/D149493?vs=518074&id=518120#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149493/new/
https://reviews.llvm.org/D149493
Files:
libc/src/__support/OSUtil/gpu/io.cpp
libc/utils/gpu/loader/Server.h
Index: libc/utils/gpu/loader/Server.h
===================================================================
--- libc/utils/gpu/loader/Server.h
+++ libc/utils/gpu/loader/Server.h
@@ -30,10 +30,15 @@
switch (port->get_opcode()) {
case __llvm_libc::rpc::Opcode::PRINT_TO_STDERR: {
- void *str = nullptr;
- port->recv_n([&](uint64_t size) { return str = malloc(size); });
- fputs(reinterpret_cast<char *>(str), stderr);
- free(str);
+ uint64_t str_size;
+ char *str = nullptr;
+ port->recv_n([&](uint64_t size) {
+ str_size = size;
+ str = new char[size];
+ return str;
+ });
+ fwrite(str, str_size, 1, stderr);
+ delete[] str;
break;
}
case __llvm_libc::rpc::Opcode::EXIT: {
Index: libc/src/__support/OSUtil/gpu/io.cpp
===================================================================
--- libc/src/__support/OSUtil/gpu/io.cpp
+++ libc/src/__support/OSUtil/gpu/io.cpp
@@ -16,7 +16,7 @@
void write_to_stderr(cpp::string_view msg) {
rpc::Port port = rpc::client.open(rpc::PRINT_TO_STDERR);
- port.send_n(msg.data(), msg.size() + 1);
+ port.send_n(msg.data(), msg.size());
port.close();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149493.518120.patch
Type: text/x-patch
Size: 1160 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230429/9f7f7db2/attachment.bin>
More information about the libc-commits
mailing list