[libc-commits] [libc] [libc] Export the RPC interface from `libc` (PR #71432)

Jon Chesterfield via libc-commits libc-commits at lists.llvm.org
Thu Nov 9 10:01:57 PST 2023


================
@@ -28,61 +27,93 @@ static void test_interface(bool end_with_send) {
   // rpc::Client::Port port = rpc::client.open<RPC_TEST_INTERFACE>();
   rpc_port_t port = LIBC_NAMESPACE::rpc_open_port(RPC_TEST_INTERFACE);
 
-  // port.send([&](rpc::Buffer *buffer) { buffer->data[0] = end_with_send; });
-  rpc_buffer_t *buffer = LIBC_NAMESPACE::rpc_get_buffer(&port);
-  buffer->data[0] = end_with_send;
-  LIBC_NAMESPACE::rpc_send(&port);
+  LIBC_NAMESPACE::rpc_send(
+      &port,
+      [](rpc_buffer_t *buffer, void *data, uint32_t) {
+        buffer->data[0] = *reinterpret_cast<bool *>(data);
+      },
+      &end_with_send);
 
   // port.send([&](rpc::Buffer *buffer) { buffer->data[0] = cnt = cnt + 1; });
-  buffer = LIBC_NAMESPACE::rpc_get_buffer(&port);
-  buffer->data[0] = cnt = cnt + 1;
-  LIBC_NAMESPACE::rpc_send(&port);
+  LIBC_NAMESPACE::rpc_send(
+      &port,
+      [](rpc_buffer_t *buffer, void *data, uint32_t) {
+        buffer->data[0] = *reinterpret_cast<uint64_t *>(data) += 1;
+      },
+      &cnt);
 
   // port.recv([&](rpc::Buffer *buffer) { cnt = buffer->data[0]; });
-  LIBC_NAMESPACE::rpc_recv(&port);
-  buffer = LIBC_NAMESPACE::rpc_get_buffer(&port);
-  cnt = buffer->data[0];
+  LIBC_NAMESPACE::rpc_recv(
+      &port,
+      [](rpc_buffer_t *buffer, void *data, uint32_t) {
+        *reinterpret_cast<uint64_t *>(data) = buffer->data[0];
----------------
JonChesterfield wrote:

likewise, why is there type punning happening here

https://github.com/llvm/llvm-project/pull/71432


More information about the libc-commits mailing list