[libc-commits] [libc] [libc] Remove dependency on `cpp::function` in `rpc.h` (PR #112422)

via libc-commits libc-commits at lists.llvm.org
Tue Oct 15 12:24:23 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Joseph Huber (jhuber6)

<details>
<summary>Changes</summary>

Summary:
I'm going to attempt to move the `rpc.h` header to a separate folder
that we can install and include outside of `libc`. Before doing this I'm
going to try to trim up the file so there's not as many things I need to
copy to make it work. This dependency on `cpp::functional` is a low
hanging fruit. I only did it so that I could overload the argument of
the work function so that passing the id was optional in the lambda,
that's not a *huge* deal and it makes it more explicit I suppose.


---

Patch is 21.56 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/112422.diff


22 Files Affected:

- (modified) libc/src/__support/GPU/allocator.cpp (+6-5) 
- (modified) libc/src/__support/OSUtil/gpu/exit.cpp (+3-2) 
- (modified) libc/src/__support/OSUtil/gpu/io.cpp (+1-1) 
- (modified) libc/src/__support/RPC/rpc.h (+4-18) 
- (modified) libc/src/gpu/rpc_host_call.cpp (+2-2) 
- (modified) libc/src/stdio/gpu/clearerr.cpp (+4-2) 
- (modified) libc/src/stdio/gpu/fclose.cpp (+3-2) 
- (modified) libc/src/stdio/gpu/feof.cpp (+6-2) 
- (modified) libc/src/stdio/gpu/ferror.cpp (+6-2) 
- (modified) libc/src/stdio/gpu/fflush.cpp (+6-2) 
- (modified) libc/src/stdio/gpu/fgets.cpp (+1-1) 
- (modified) libc/src/stdio/gpu/file.h (+4-4) 
- (modified) libc/src/stdio/gpu/fopen.cpp (+2-2) 
- (modified) libc/src/stdio/gpu/fseek.cpp (+4-2) 
- (modified) libc/src/stdio/gpu/ftell.cpp (+6-2) 
- (modified) libc/src/stdio/gpu/remove.cpp (+3-2) 
- (modified) libc/src/stdio/gpu/rename.cpp (+3-2) 
- (modified) libc/src/stdio/gpu/ungetc.cpp (+4-2) 
- (modified) libc/src/stdio/gpu/vfprintf_utils.h (+3-3) 
- (modified) libc/src/stdlib/gpu/abort.cpp (+3-2) 
- (modified) libc/src/stdlib/gpu/system.cpp (+3-2) 
- (modified) libc/utils/gpu/server/rpc_server.cpp (+15-15) 


``````````diff
diff --git a/libc/src/__support/GPU/allocator.cpp b/libc/src/__support/GPU/allocator.cpp
index 01273e16a9387a..f98e610104797f 100644
--- a/libc/src/__support/GPU/allocator.cpp
+++ b/libc/src/__support/GPU/allocator.cpp
@@ -18,17 +18,18 @@ namespace {
 void *rpc_allocate(uint64_t size) {
   void *ptr = nullptr;
   rpc::Client::Port port = rpc::client.open<RPC_MALLOC>();
-  port.send_and_recv([=](rpc::Buffer *buffer) { buffer->data[0] = size; },
-                     [&](rpc::Buffer *buffer) {
-                       ptr = reinterpret_cast<void *>(buffer->data[0]);
-                     });
+  port.send_and_recv(
+      [=](rpc::Buffer *buffer, uint32_t) { buffer->data[0] = size; },
+      [&](rpc::Buffer *buffer, uint32_t) {
+        ptr = reinterpret_cast<void *>(buffer->data[0]);
+      });
   port.close();
   return ptr;
 }
 
 void rpc_free(void *ptr) {
   rpc::Client::Port port = rpc::client.open<RPC_FREE>();
-  port.send([=](rpc::Buffer *buffer) {
+  port.send([=](rpc::Buffer *buffer, uint32_t) {
     buffer->data[0] = reinterpret_cast<uintptr_t>(ptr);
   });
   port.close();
diff --git a/libc/src/__support/OSUtil/gpu/exit.cpp b/libc/src/__support/OSUtil/gpu/exit.cpp
index 360bcca1c6da33..8aaa41b4e3eefc 100644
--- a/libc/src/__support/OSUtil/gpu/exit.cpp
+++ b/libc/src/__support/OSUtil/gpu/exit.cpp
@@ -18,8 +18,9 @@ namespace internal {
 [[noreturn]] void exit(int status) {
   // We want to first make sure the server is listening before we exit.
   rpc::Client::Port port = rpc::client.open<RPC_EXIT>();
-  port.send_and_recv([](rpc::Buffer *) {}, [](rpc::Buffer *) {});
-  port.send([&](rpc::Buffer *buffer) {
+  port.send_and_recv([](rpc::Buffer *, uint32_t) {},
+                     [](rpc::Buffer *, uint32_t) {});
+  port.send([&](rpc::Buffer *buffer, uint32_t) {
     reinterpret_cast<uint32_t *>(buffer->data)[0] = status;
   });
   port.close();
diff --git a/libc/src/__support/OSUtil/gpu/io.cpp b/libc/src/__support/OSUtil/gpu/io.cpp
index f3000bd0f48b16..f70c2e798cfe15 100644
--- a/libc/src/__support/OSUtil/gpu/io.cpp
+++ b/libc/src/__support/OSUtil/gpu/io.cpp
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
 void write_to_stderr(cpp::string_view msg) {
   rpc::Client::Port port = rpc::client.open<RPC_WRITE_TO_STDERR>();
   port.send_n(msg.data(), msg.size());
-  port.recv([](rpc::Buffer *) { /* void */ });
+  port.recv([](rpc::Buffer *, uint32_t) { /* void */ });
   port.close();
 }
 
diff --git a/libc/src/__support/RPC/rpc.h b/libc/src/__support/RPC/rpc.h
index a94b11902c1190..c421dd82b29450 100644
--- a/libc/src/__support/RPC/rpc.h
+++ b/libc/src/__support/RPC/rpc.h
@@ -21,7 +21,6 @@
 #include "rpc_util.h"
 #include "src/__support/CPP/algorithm.h" // max
 #include "src/__support/CPP/atomic.h"
-#include "src/__support/CPP/functional.h"
 #include "src/__support/CPP/optional.h"
 #include "src/__support/GPU/utils.h"
 #include "src/__support/macros/config.h"
@@ -266,22 +265,9 @@ template <bool Invert> struct Process {
 };
 
 /// Invokes a function accross every active buffer across the total lane size.
-static LIBC_INLINE void invoke_rpc(cpp::function<void(Buffer *)> fn,
-                                   uint32_t lane_size, uint64_t lane_mask,
-                                   Buffer *slot) {
-  if constexpr (is_process_gpu()) {
-    fn(&slot[gpu::get_lane_id()]);
-  } else {
-    for (uint32_t i = 0; i < lane_size; i += gpu::get_lane_size())
-      if (lane_mask & (1ul << i))
-        fn(&slot[i]);
-  }
-}
-
-/// Alternate version that also provides the index of the current lane.
-static LIBC_INLINE void invoke_rpc(cpp::function<void(Buffer *, uint32_t)> fn,
-                                   uint32_t lane_size, uint64_t lane_mask,
-                                   Buffer *slot) {
+template <typename F>
+LIBC_INLINE static void invoke_rpc(F &&fn, uint32_t lane_size,
+                                   uint64_t lane_mask, Buffer *slot) {
   if constexpr (is_process_gpu()) {
     fn(&slot[gpu::get_lane_id()], gpu::get_lane_id());
   } else {
@@ -444,7 +430,7 @@ template <bool T>
 template <typename W>
 LIBC_INLINE void Port<T>::recv_and_send(W work) {
   recv(work);
-  send([](Buffer *) { /* no-op */ });
+  send([](Buffer *, uint32_t) { /* no-op */ });
 }
 
 /// Helper routine to simplify the interface when sending from the GPU using
diff --git a/libc/src/gpu/rpc_host_call.cpp b/libc/src/gpu/rpc_host_call.cpp
index f21fadc319c615..1181e9554d16e2 100644
--- a/libc/src/gpu/rpc_host_call.cpp
+++ b/libc/src/gpu/rpc_host_call.cpp
@@ -21,11 +21,11 @@ LLVM_LIBC_FUNCTION(unsigned long long, rpc_host_call,
                    (void *fn, void *data, size_t size)) {
   rpc::Client::Port port = rpc::client.open<RPC_HOST_CALL>();
   port.send_n(data, size);
-  port.send([=](rpc::Buffer *buffer) {
+  port.send([=](rpc::Buffer *buffer, uint32_t) {
     buffer->data[0] = reinterpret_cast<uintptr_t>(fn);
   });
   unsigned long long ret;
-  port.recv([&](rpc::Buffer *buffer) {
+  port.recv([&](rpc::Buffer *buffer, uint32_t) {
     ret = static_cast<unsigned long long>(buffer->data[0]);
   });
   port.close();
diff --git a/libc/src/stdio/gpu/clearerr.cpp b/libc/src/stdio/gpu/clearerr.cpp
index 5826a7bcb95fb7..4c631b9f946f3f 100644
--- a/libc/src/stdio/gpu/clearerr.cpp
+++ b/libc/src/stdio/gpu/clearerr.cpp
@@ -17,8 +17,10 @@ namespace LIBC_NAMESPACE_DECL {
 LLVM_LIBC_FUNCTION(void, clearerr, (::FILE * stream)) {
   rpc::Client::Port port = rpc::client.open<RPC_CLEARERR>();
   port.send_and_recv(
-      [=](rpc::Buffer *buffer) { buffer->data[0] = file::from_stream(stream); },
-      [&](rpc::Buffer *) {});
+      [=](rpc::Buffer *buffer, uint32_t) {
+        buffer->data[0] = file::from_stream(stream);
+      },
+      [&](rpc::Buffer *, uint32_t) {});
   port.close();
 }
 
diff --git a/libc/src/stdio/gpu/fclose.cpp b/libc/src/stdio/gpu/fclose.cpp
index 78caccd90c6931..683e0548495d16 100644
--- a/libc/src/stdio/gpu/fclose.cpp
+++ b/libc/src/stdio/gpu/fclose.cpp
@@ -19,8 +19,9 @@ LLVM_LIBC_FUNCTION(int, fclose, (::FILE * stream)) {
   uint64_t ret = 0;
   uintptr_t file = reinterpret_cast<uintptr_t>(stream);
   rpc::Client::Port port = rpc::client.open<RPC_CLOSE_FILE>();
-  port.send_and_recv([=](rpc::Buffer *buffer) { buffer->data[0] = file; },
-                     [&](rpc::Buffer *buffer) { ret = buffer->data[0]; });
+  port.send_and_recv(
+      [=](rpc::Buffer *buffer, uint32_t) { buffer->data[0] = file; },
+      [&](rpc::Buffer *buffer, uint32_t) { ret = buffer->data[0]; });
   port.close();
 
   if (ret != 0)
diff --git a/libc/src/stdio/gpu/feof.cpp b/libc/src/stdio/gpu/feof.cpp
index 4a8a17332a0a92..02adb4ce73d681 100644
--- a/libc/src/stdio/gpu/feof.cpp
+++ b/libc/src/stdio/gpu/feof.cpp
@@ -18,8 +18,12 @@ LLVM_LIBC_FUNCTION(int, feof, (::FILE * stream)) {
   int ret;
   rpc::Client::Port port = rpc::client.open<RPC_FEOF>();
   port.send_and_recv(
-      [=](rpc::Buffer *buffer) { buffer->data[0] = file::from_stream(stream); },
-      [&](rpc::Buffer *buffer) { ret = static_cast<int>(buffer->data[0]); });
+      [=](rpc::Buffer *buffer, uint32_t) {
+        buffer->data[0] = file::from_stream(stream);
+      },
+      [&](rpc::Buffer *buffer, uint32_t) {
+        ret = static_cast<int>(buffer->data[0]);
+      });
   port.close();
   return ret;
 }
diff --git a/libc/src/stdio/gpu/ferror.cpp b/libc/src/stdio/gpu/ferror.cpp
index 1cee96f5ef23b3..ca777131fd1b3e 100644
--- a/libc/src/stdio/gpu/ferror.cpp
+++ b/libc/src/stdio/gpu/ferror.cpp
@@ -18,8 +18,12 @@ LLVM_LIBC_FUNCTION(int, ferror, (::FILE * stream)) {
   int ret;
   rpc::Client::Port port = rpc::client.open<RPC_FERROR>();
   port.send_and_recv(
-      [=](rpc::Buffer *buffer) { buffer->data[0] = file::from_stream(stream); },
-      [&](rpc::Buffer *buffer) { ret = static_cast<int>(buffer->data[0]); });
+      [=](rpc::Buffer *buffer, uint32_t) {
+        buffer->data[0] = file::from_stream(stream);
+      },
+      [&](rpc::Buffer *buffer, uint32_t) {
+        ret = static_cast<int>(buffer->data[0]);
+      });
   port.close();
   return ret;
 }
diff --git a/libc/src/stdio/gpu/fflush.cpp b/libc/src/stdio/gpu/fflush.cpp
index be267a2e9ce129..577325b70c4e70 100644
--- a/libc/src/stdio/gpu/fflush.cpp
+++ b/libc/src/stdio/gpu/fflush.cpp
@@ -18,8 +18,12 @@ LLVM_LIBC_FUNCTION(int, fflush, (::FILE * stream)) {
   int ret;
   rpc::Client::Port port = rpc::client.open<RPC_FFLUSH>();
   port.send_and_recv(
-      [=](rpc::Buffer *buffer) { buffer->data[0] = file::from_stream(stream); },
-      [&](rpc::Buffer *buffer) { ret = static_cast<int>(buffer->data[0]); });
+      [=](rpc::Buffer *buffer, uint32_t) {
+        buffer->data[0] = file::from_stream(stream);
+      },
+      [&](rpc::Buffer *buffer, uint32_t) {
+        ret = static_cast<int>(buffer->data[0]);
+      });
   port.close();
   return ret;
 }
diff --git a/libc/src/stdio/gpu/fgets.cpp b/libc/src/stdio/gpu/fgets.cpp
index 942f6f0ff03bc1..fbc1b0cf7d1a87 100644
--- a/libc/src/stdio/gpu/fgets.cpp
+++ b/libc/src/stdio/gpu/fgets.cpp
@@ -27,7 +27,7 @@ LLVM_LIBC_FUNCTION(char *, fgets,
   uint64_t recv_size;
   void *buf = nullptr;
   rpc::Client::Port port = rpc::client.open<RPC_READ_FGETS>();
-  port.send([=](rpc::Buffer *buffer) {
+  port.send([=](rpc::Buffer *buffer, uint32_t) {
     buffer->data[0] = count;
     buffer->data[1] = file::from_stream(stream);
   });
diff --git a/libc/src/stdio/gpu/file.h b/libc/src/stdio/gpu/file.h
index 0856a3430803ae..16d64e8f377501 100644
--- a/libc/src/stdio/gpu/file.h
+++ b/libc/src/stdio/gpu/file.h
@@ -55,13 +55,13 @@ LIBC_INLINE uint64_t write_impl(::FILE *file, const void *data, size_t size) {
   rpc::Client::Port port = rpc::client.open<opcode>();
 
   if constexpr (opcode == RPC_WRITE_TO_STREAM) {
-    port.send([&](rpc::Buffer *buffer) {
+    port.send([&](rpc::Buffer *buffer, uint32_t) {
       buffer->data[0] = reinterpret_cast<uintptr_t>(file);
     });
   }
 
   port.send_n(data, size);
-  port.recv([&](rpc::Buffer *buffer) {
+  port.recv([&](rpc::Buffer *buffer, uint32_t) {
     ret = reinterpret_cast<uint64_t *>(buffer->data)[0];
   });
   port.close();
@@ -81,12 +81,12 @@ LIBC_INLINE uint64_t read_from_stream(::FILE *file, void *buf, size_t size) {
   uint64_t ret = 0;
   uint64_t recv_size;
   rpc::Client::Port port = rpc::client.open<RPC_READ_FROM_STREAM>();
-  port.send([=](rpc::Buffer *buffer) {
+  port.send([=](rpc::Buffer *buffer, uint32_t) {
     buffer->data[0] = size;
     buffer->data[1] = from_stream(file);
   });
   port.recv_n(&buf, &recv_size, [&](uint64_t) { return buf; });
-  port.recv([&](rpc::Buffer *buffer) { ret = buffer->data[0]; });
+  port.recv([&](rpc::Buffer *buffer, uint32_t) { ret = buffer->data[0]; });
   port.close();
   return ret;
 }
diff --git a/libc/src/stdio/gpu/fopen.cpp b/libc/src/stdio/gpu/fopen.cpp
index 76daece68ac9d8..e165d2acd2109a 100644
--- a/libc/src/stdio/gpu/fopen.cpp
+++ b/libc/src/stdio/gpu/fopen.cpp
@@ -21,10 +21,10 @@ LLVM_LIBC_FUNCTION(::FILE *, fopen,
   rpc::Client::Port port = rpc::client.open<RPC_OPEN_FILE>();
   port.send_n(path, internal::string_length(path) + 1);
   port.send_and_recv(
-      [=](rpc::Buffer *buffer) {
+      [=](rpc::Buffer *buffer, uint32_t) {
         inline_memcpy(buffer->data, mode, internal::string_length(mode) + 1);
       },
-      [&](rpc::Buffer *buffer) { file = buffer->data[0]; });
+      [&](rpc::Buffer *buffer, uint32_t) { file = buffer->data[0]; });
   port.close();
 
   return reinterpret_cast<FILE *>(file);
diff --git a/libc/src/stdio/gpu/fseek.cpp b/libc/src/stdio/gpu/fseek.cpp
index 4f3e9ce6ec024d..37c40bc602d87e 100644
--- a/libc/src/stdio/gpu/fseek.cpp
+++ b/libc/src/stdio/gpu/fseek.cpp
@@ -18,12 +18,14 @@ LLVM_LIBC_FUNCTION(int, fseek, (::FILE * stream, long offset, int whence)) {
   int ret;
   rpc::Client::Port port = rpc::client.open<RPC_FSEEK>();
   port.send_and_recv(
-      [=](rpc::Buffer *buffer) {
+      [=](rpc::Buffer *buffer, uint32_t) {
         buffer->data[0] = file::from_stream(stream);
         buffer->data[1] = static_cast<uint64_t>(offset);
         buffer->data[2] = static_cast<uint64_t>(whence);
       },
-      [&](rpc::Buffer *buffer) { ret = static_cast<int>(buffer->data[0]); });
+      [&](rpc::Buffer *buffer, uint32_t) {
+        ret = static_cast<int>(buffer->data[0]);
+      });
   port.close();
   return ret;
 }
diff --git a/libc/src/stdio/gpu/ftell.cpp b/libc/src/stdio/gpu/ftell.cpp
index 483b1ad4fee0fe..226aeda2f8dedc 100644
--- a/libc/src/stdio/gpu/ftell.cpp
+++ b/libc/src/stdio/gpu/ftell.cpp
@@ -18,8 +18,12 @@ LLVM_LIBC_FUNCTION(long, ftell, (::FILE * stream)) {
   long ret;
   rpc::Client::Port port = rpc::client.open<RPC_FSEEK>();
   port.send_and_recv(
-      [=](rpc::Buffer *buffer) { buffer->data[0] = file::from_stream(stream); },
-      [&](rpc::Buffer *buffer) { ret = static_cast<long>(buffer->data[0]); });
+      [=](rpc::Buffer *buffer, uint32_t) {
+        buffer->data[0] = file::from_stream(stream);
+      },
+      [&](rpc::Buffer *buffer, uint32_t) {
+        ret = static_cast<long>(buffer->data[0]);
+      });
   port.close();
   return ret;
 }
diff --git a/libc/src/stdio/gpu/remove.cpp b/libc/src/stdio/gpu/remove.cpp
index 3f21e8aeff5aed..6604be1c31f2b0 100644
--- a/libc/src/stdio/gpu/remove.cpp
+++ b/libc/src/stdio/gpu/remove.cpp
@@ -18,8 +18,9 @@ LLVM_LIBC_FUNCTION(int, remove, (const char *path)) {
   int ret;
   rpc::Client::Port port = rpc::client.open<RPC_REMOVE>();
   port.send_n(path, internal::string_length(path) + 1);
-  port.recv(
-      [&](rpc::Buffer *buffer) { ret = static_cast<int>(buffer->data[0]); });
+  port.recv([&](rpc::Buffer *buffer, uint32_t) {
+    ret = static_cast<int>(buffer->data[0]);
+  });
   port.close();
   return ret;
 }
diff --git a/libc/src/stdio/gpu/rename.cpp b/libc/src/stdio/gpu/rename.cpp
index 1087228835842e..e6396e212b8b5c 100644
--- a/libc/src/stdio/gpu/rename.cpp
+++ b/libc/src/stdio/gpu/rename.cpp
@@ -20,8 +20,9 @@ LLVM_LIBC_FUNCTION(int, rename, (const char *oldpath, const char *newpath)) {
   rpc::Client::Port port = rpc::client.open<RPC_RENAME>();
   port.send_n(oldpath, internal::string_length(oldpath) + 1);
   port.send_n(newpath, internal::string_length(newpath) + 1);
-  port.recv(
-      [&](rpc::Buffer *buffer) { ret = static_cast<int>(buffer->data[0]); });
+  port.recv([&](rpc::Buffer *buffer, uint32_t) {
+    ret = static_cast<int>(buffer->data[0]);
+  });
   port.close();
 
   return ret;
diff --git a/libc/src/stdio/gpu/ungetc.cpp b/libc/src/stdio/gpu/ungetc.cpp
index e9232a5e43a270..dce14391b7de4a 100644
--- a/libc/src/stdio/gpu/ungetc.cpp
+++ b/libc/src/stdio/gpu/ungetc.cpp
@@ -18,11 +18,13 @@ LLVM_LIBC_FUNCTION(int, ungetc, (int c, ::FILE *stream)) {
   int ret;
   rpc::Client::Port port = rpc::client.open<RPC_UNGETC>();
   port.send_and_recv(
-      [=](rpc::Buffer *buffer) {
+      [=](rpc::Buffer *buffer, uint32_t) {
         buffer->data[0] = c;
         buffer->data[1] = file::from_stream(stream);
       },
-      [&](rpc::Buffer *buffer) { ret = static_cast<int>(buffer->data[0]); });
+      [&](rpc::Buffer *buffer, uint32_t) {
+        ret = static_cast<int>(buffer->data[0]);
+      });
   port.close();
   return ret;
 }
diff --git a/libc/src/stdio/gpu/vfprintf_utils.h b/libc/src/stdio/gpu/vfprintf_utils.h
index 7c012d139ba5dc..93ce1649869fc1 100644
--- a/libc/src/stdio/gpu/vfprintf_utils.h
+++ b/libc/src/stdio/gpu/vfprintf_utils.h
@@ -23,14 +23,14 @@ LIBC_INLINE int vfprintf_impl(::FILE *__restrict file,
 
   if constexpr (opcode == RPC_PRINTF_TO_STREAM ||
                 opcode == RPC_PRINTF_TO_STREAM_PACKED) {
-    port.send([&](rpc::Buffer *buffer) {
+    port.send([&](rpc::Buffer *buffer, uint32_t) {
       buffer->data[0] = reinterpret_cast<uintptr_t>(file);
     });
   }
 
   size_t args_size = 0;
   port.send_n(format, format_size);
-  port.recv([&](rpc::Buffer *buffer) {
+  port.recv([&](rpc::Buffer *buffer, uint32_t) {
     args_size = static_cast<size_t>(buffer->data[0]);
   });
   port.send_n(vlist, args_size);
@@ -38,7 +38,7 @@ LIBC_INLINE int vfprintf_impl(::FILE *__restrict file,
   uint32_t ret = 0;
   for (;;) {
     const char *str = nullptr;
-    port.recv([&](rpc::Buffer *buffer) {
+    port.recv([&](rpc::Buffer *buffer, uint32_t) {
       ret = static_cast<uint32_t>(buffer->data[0]);
       str = reinterpret_cast<const char *>(buffer->data[1]);
     });
diff --git a/libc/src/stdlib/gpu/abort.cpp b/libc/src/stdlib/gpu/abort.cpp
index fee198607cc029..cfc7e9b8e228ba 100644
--- a/libc/src/stdlib/gpu/abort.cpp
+++ b/libc/src/stdlib/gpu/abort.cpp
@@ -17,8 +17,9 @@ namespace LIBC_NAMESPACE_DECL {
 LLVM_LIBC_FUNCTION(void, abort, ()) {
   // We want to first make sure the server is listening before we abort.
   rpc::Client::Port port = rpc::client.open<RPC_ABORT>();
-  port.send_and_recv([](rpc::Buffer *) {}, [](rpc::Buffer *) {});
-  port.send([&](rpc::Buffer *) {});
+  port.send_and_recv([](rpc::Buffer *, uint32_t) {},
+                     [](rpc::Buffer *, uint32_t) {});
+  port.send([&](rpc::Buffer *, uint32_t) {});
   port.close();
 
   gpu::end_program();
diff --git a/libc/src/stdlib/gpu/system.cpp b/libc/src/stdlib/gpu/system.cpp
index acf3a8c941ffa9..1890006512de4f 100644
--- a/libc/src/stdlib/gpu/system.cpp
+++ b/libc/src/stdlib/gpu/system.cpp
@@ -19,8 +19,9 @@ LLVM_LIBC_FUNCTION(int, system, (const char *command)) {
   int ret;
   rpc::Client::Port port = rpc::client.open<RPC_SYSTEM>();
   port.send_n(command, internal::string_length(command) + 1);
-  port.recv(
-      [&](rpc::Buffer *buffer) { ret = static_cast<int>(buffer->data[0]); });
+  port.recv([&](rpc::Buffer *buffer, uint32_t) {
+    ret = static_cast<int>(buffer->data[0]);
+  });
   port.close();
 
   return ret;
diff --git a/libc/utils/gpu/server/rpc_server.cpp b/libc/utils/gpu/server/rpc_server.cpp
index ca10e67509ae63..11b6d0e27ab948 100644
--- a/libc/utils/gpu/server/rpc_server.cpp
+++ b/libc/utils/gpu/server/rpc_server.cpp
@@ -302,8 +302,8 @@ rpc_status_t handle_server_impl(
   }
   case RPC_EXIT: {
     // Send a response to the client to signal that we are ready to exit.
-    port->recv_and_send([](rpc::Buffer *) {});
-    port->recv([](rpc::Buffer *buffer) {
+    port->recv_and_send([](rpc::Buffer *, uint32_t) {});
+    port->recv([](rpc::Buffer *buffer, uint32_t) {
       int status = 0;
       std::memcpy(&status, buffer->data, sizeof(int));
       exit(status);
@@ -312,8 +312,8 @@ rpc_status_t handle_server_impl(
   }
   case RPC_ABORT: {
     // Send a response to the client to signal that we are ready to abort.
-    port->recv_and_send([](rpc::Buffer *) {});
-    port->recv([](rpc::Buffer *) {});
+    port->recv_and_send([](rpc::Buffer *, uint32_t) {});
+    port->recv([](rpc::Buffer *, uint32_t) {});
     abort();
     break;
   }
@@ -334,25 +334,25 @@ rpc_status_t handle_server_impl(
     break;
   }
   case RPC_FEOF: {
-    port->recv_and_send([](rpc::Buffer *buffer) {
+    port->recv_and_send([](rpc::Buffer *buffer, uint32_t) {
       buffer->data[0] = feof(file::to_stream(buffer->data[0]));
     });
     break;
   }
   case RPC_FERROR: {
-    port->recv_and_send([](rpc::Buffer *buffer) {
+    port->recv_and_send([](rpc::Buffer *buffer, uint32_t) {
       buffer->data[0] = ferror(file::to_stream(buffer->data[0]));
     });
     break;
   }
   case RPC_CLEARERR: {
-    port->recv_and_send([](rpc::Buffer *buffer) {
+    port->recv_and_send([](rpc::Buffer *buffer, uint32_t) {
       clearerr(file::to_stream(buffer->data[0]));
     });
     break;
   }
   case RPC_FSEEK: {
-    port->recv_and_send([](rpc::Buffer *buffer) {
+    port->recv_and_send([](rpc::Buffer *buffer, uint32_t) {
       buffer->data[0] = fseek(file::to_stream(buffer->data[0]),
                               static_cast<long>(buffer->data[1]),
                               static_cast<int>(buffer->data[2]));
@@ -360,19 +360,19 @@ rpc_status_t handle_server_impl(
     break;
   }
   case RPC_FTELL: {
-    port->recv_and_send([](rpc::Buffer *buffer) {
+    port->recv_and_send([](rpc::Buffer *buffer, uint32_t) {
       buffer->data[0] = ftell(file::to_stream(buffer->data[0]));
     });
     break;
   }
   case RPC_FFLUSH: {
-    port->recv_and_send([](rpc::Buffer *buffer) {
+    port->recv_and_send([](rpc::Buffer *buffer, uint32_t) {
       buffer->data[0] = fflush(file::to_stream(buffer->data[0]));
     });
     break;
   }
   case RPC_UNGETC: {
-    port->recv_and_send([](rpc::Buffer *buffer) {
+    port->recv_and_send([](rpc::Buffer *buffer, uint32_t) {
   ...
[truncated]

``````````

</details>


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


More information about the libc-commits mailing list