[libc] Replace the PRINT_TO_STDERR opcode for RPC printing.

A previous patch added general support for printing via the RPC
interface. we should consolidate this functionality and get rid of the
old opcode that was used for simple testing.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D152211
This commit is contained in:
Joseph Huber 2023-06-05 18:56:26 -05:00
parent eb5308adc4
commit e6a350df10
3 changed files with 4 additions and 18 deletions

View File

@ -15,7 +15,7 @@
namespace __llvm_libc {
void write_to_stderr(cpp::string_view msg) {
rpc::Client::Port port = rpc::client.open<rpc::PRINT_TO_STDERR>();
rpc::Client::Port port = rpc::client.open<rpc::WRITE_TO_STDERR>();
port.send_n(msg.data(), msg.size());
port.recv([](rpc::Buffer *) { /* void */ });
port.close();

View File

@ -39,10 +39,9 @@ enum Opcode : uint16_t {
WRITE_TO_STREAM = 4,
MALLOC = 5,
FREE = 6,
PRINT_TO_STDERR = 7,
TEST_INCREMENT = 8,
TEST_INTERFACE = 9,
TEST_STREAM = 10,
TEST_INCREMENT = 7,
TEST_INTERFACE = 8,
TEST_STREAM = 9,
};
/// A fixed size channel used to communicate between the RPC client and server.

View File

@ -58,19 +58,6 @@ void handle_server(Alloc allocator, Dealloc deallocator) {
}
break;
}
case rpc::Opcode::PRINT_TO_STDERR: {
uint64_t sizes[rpc::MAX_LANE_SIZE] = {0};
void *strs[rpc::MAX_LANE_SIZE] = {nullptr};
port->recv_n(strs, sizes, [&](uint64_t size) { return new char[size]; });
port->send([](rpc::Buffer *) { /* void */ });
for (uint64_t i = 0; i < rpc::MAX_LANE_SIZE; ++i) {
if (strs[i]) {
fwrite(strs[i], sizes[i], 1, stderr);
delete[] reinterpret_cast<uint8_t *>(strs[i]);
}
}
break;
}
case rpc::Opcode::EXIT: {
port->recv([](rpc::Buffer *buffer) {
exit(reinterpret_cast<uint32_t *>(buffer->data)[0]);