[libc-commits] [libc] 140d65f - [libc][NFC] Fix comments and macros in the RPC interface

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Mon Feb 16 16:10:32 PST 2026


Author: Joseph Huber
Date: 2026-02-16T18:09:58-06:00
New Revision: 140d65f138f2153b61a11a7eceabf8b1b99b7c9b

URL: https://github.com/llvm/llvm-project/commit/140d65f138f2153b61a11a7eceabf8b1b99b7c9b
DIFF: https://github.com/llvm/llvm-project/commit/140d65f138f2153b61a11a7eceabf8b1b99b7c9b.diff

LOG: [libc][NFC] Fix comments and macros in the RPC interface

Summary:
Typos and missing include header guards should be fixed now.

Added: 
    

Modified: 
    libc/shared/rpc.h
    libc/shared/rpc_dispatch.h
    libc/shared/rpc_opcodes.h
    libc/shared/rpc_util.h

Removed: 
    


################################################################################
diff  --git a/libc/shared/rpc.h b/libc/shared/rpc.h
index e13ba1de89c20..668b6f1993d88 100644
--- a/libc/shared/rpc.h
+++ b/libc/shared/rpc.h
@@ -8,10 +8,10 @@
 //
 // This file implements a remote procedure call mechanism to communicate between
 // heterogeneous devices that can share an address space atomically. We provide
-// a client and a server to facilitate the remote call. The client makes request
-// to the server using a shared communication channel. We use separate atomic
-// signals to indicate which side, the client or the server is in ownership of
-// the buffer.
+// a client and a server to facilitate the remote call. The client makes
+// requests to the server using a shared communication channel. We use separate
+// atomic signals to indicate which side, the client or the server is in
+// ownership of the buffer.
 //
 //===----------------------------------------------------------------------===//
 
@@ -36,7 +36,7 @@ namespace rpc {
 #define __scoped_atomic_thread_fence(ord, scp) __atomic_thread_fence(ord)
 #endif
 
-/// Generic codes that can be used whem implementing the server.
+/// Generic codes that can be used when implementing the server.
 enum Status {
   RPC_SUCCESS = 0x0,
   RPC_ERROR = 0x1000,
@@ -242,7 +242,7 @@ template <bool Invert> struct Process {
     return Invert ? 0 : mailbox_bytes(port_count);
   }
 
-  /// Offset of the buffer containing the packets after the inbox and outbox.
+  /// Offset of the header containing the opcode and mask after the mailboxes.
   RPC_ATTRS static constexpr uint64_t header_offset(uint32_t port_count) {
     return align_up(2 * mailbox_bytes(port_count), alignof(Header));
   }
@@ -337,7 +337,7 @@ template <bool T> struct Port {
     // Wait for all lanes to finish using the port.
     rpc::sync_lane(lane_mask);
 
-    // The server is passive, if it own the buffer when it closes we need to
+    // The server is passive, if it owns the buffer when it closes we need to
     // give ownership back to the client.
     if (owns_buffer && T)
       out = process.invert_outbox(index, out);

diff  --git a/libc/shared/rpc_dispatch.h b/libc/shared/rpc_dispatch.h
index ff4f357378f2a..d9ea5fe661b49 100644
--- a/libc/shared/rpc_dispatch.h
+++ b/libc/shared/rpc_dispatch.h
@@ -6,6 +6,9 @@
 //
 //===----------------------------------------------------------------------===//
 
+#ifndef LLVM_LIBC_SHARED_RPC_DISPATCH_H
+#define LLVM_LIBC_SHARED_RPC_DISPATCH_H
+
 #include "rpc.h"
 #include "rpc_util.h"
 
@@ -52,7 +55,7 @@ template <typename... Ts>
 struct tuple_bytes<rpc::tuple<Ts...>> : tuple_bytes<Ts...> {};
 
 // Client-side dispatch of pointer values. We copy the memory associated with
-// the pointer to the server and recieve back a server-side pointer to replace
+// the pointer to the server and receive back a server-side pointer to replace
 // the client-side pointer in the argument list.
 template <uint64_t Idx, typename Tuple>
 RPC_ATTRS constexpr void prepare_arg(rpc::Client::Port &port, Tuple &t) {
@@ -73,7 +76,7 @@ RPC_ATTRS constexpr void prepare_arg(rpc::Client::Port &port, Tuple &t) {
   }
 }
 
-// Server-side handling of pointer arguments. We recieve the memory into a
+// Server-side handling of pointer arguments. We receive the memory into a
 // temporary buffer and pass a pointer to this new memory back to the client.
 template <uint32_t NUM_LANES, typename Tuple, uint64_t Idx>
 RPC_ATTRS constexpr void prepare_arg(rpc::Server::Port &port) {
@@ -213,7 +216,7 @@ dispatch(rpc::Client &client, FnTy, CallArgs... args) {
     return ret;
 }
 
-// Invoke a function on the server on behalf of the client. Recieves the
+// Invoke a function on the server on behalf of the client. Receives the
 // arguments through the interface and forwards them to the function.
 template <uint32_t NUM_LANES, typename FnTy>
 RPC_ATTRS constexpr void invoke(rpc::Server::Port &port, FnTy fn) {
@@ -222,7 +225,7 @@ RPC_ATTRS constexpr void invoke(rpc::Server::Port &port, FnTy fn) {
   using TupleTy = typename Traits::arg_types;
   using Bytes = tuple_bytes<TupleTy>;
 
-  // Recieve pointer data from the host and pack it in server-side memory.
+  // Receive pointer data from the host and pack it in server-side memory.
   rpc::prepare_args<NUM_LANES, TupleTy>(
       port, rpc::make_index_sequence<Traits::ARITY>{});
 
@@ -230,7 +233,7 @@ RPC_ATTRS constexpr void invoke(rpc::Server::Port &port, FnTy fn) {
   typename Bytes::array_type arg_buf[NUM_LANES]{};
   port.recv_n(arg_buf);
 
-  // Convert the recieved arguments into an invocable argument list.
+  // Convert the received arguments into an invocable argument list.
   TupleTy args[NUM_LANES];
   for (uint32_t id = 0; id < NUM_LANES; ++id) {
     if (port.get_lane_mask() & (uint64_t(1) << id))
@@ -259,3 +262,5 @@ RPC_ATTRS constexpr void invoke(rpc::Server::Port &port, FnTy fn) {
   port.send_n(rets);
 }
 } // namespace rpc
+
+#endif // LLVM_LIBC_SHARED_RPC_DISPATCH_H

diff  --git a/libc/shared/rpc_opcodes.h b/libc/shared/rpc_opcodes.h
index a9c4f5521021e..3b94094226e0b 100644
--- a/libc/shared/rpc_opcodes.h
+++ b/libc/shared/rpc_opcodes.h
@@ -53,6 +53,7 @@ typedef enum {
   LIBC_LAST = 0xFFFFFFFF,
 } rpc_opcode_t;
 
+#undef LLVM_LIBC_RPC_BASE
 #undef LLVM_LIBC_OPCODE
 
 #endif // LLVM_LIBC_SHARED_RPC_OPCODES_H

diff  --git a/libc/shared/rpc_util.h b/libc/shared/rpc_util.h
index 9b6368e1b4fca..c984c5eab4f50 100644
--- a/libc/shared/rpc_util.h
+++ b/libc/shared/rpc_util.h
@@ -368,7 +368,7 @@ RPC_ATTRS uint32_t get_num_lanes() {
 #endif
 }
 
-/// Returns the id of the thread inside of an AMD wavefront executing together.
+/// Returns a bitmask of the currently active lanes.
 RPC_ATTRS uint64_t get_lane_mask() {
 #ifdef RPC_TARGET_IS_GPU
   return __gpu_lane_mask();


        


More information about the libc-commits mailing list