[libc-commits] [libc] 155191e - [libc] Restrict access to the RPC Process internals

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Wed May 17 15:48:19 PDT 2023


Author: Joseph Huber
Date: 2023-05-17T17:48:12-05:00
New Revision: 155191e9fdaee0d12f536a485909c460387d0db8

URL: https://github.com/llvm/llvm-project/commit/155191e9fdaee0d12f536a485909c460387d0db8
DIFF: https://github.com/llvm/llvm-project/commit/155191e9fdaee0d12f536a485909c460387d0db8.diff

LOG: [libc] Restrict access to the RPC Process internals

This patch changes the `Process` struct to only provide the functions
expected to be visible by the interface. So, now we only export the
open, reset, and size query functions. This prevents users of the
interface from messing with the internals of the process, so now the
only existing failure mode is mismatched send and recieve calls.

Reviewed By: michaelrj

Differential Revision: https://reviews.llvm.org/D150703

Added: 
    

Modified: 
    libc/src/__support/RPC/rpc.h

Removed: 
    


################################################################################
diff  --git a/libc/src/__support/RPC/rpc.h b/libc/src/__support/RPC/rpc.h
index a73c540fa0b1b..8be41162b3469 100644
--- a/libc/src/__support/RPC/rpc.h
+++ b/libc/src/__support/RPC/rpc.h
@@ -97,6 +97,9 @@ template <bool Invert> struct Process {
   LIBC_INLINE Process &operator=(Process &&) = default;
   LIBC_INLINE ~Process() = default;
 
+  template <bool T> friend struct Port;
+
+protected:
   uint64_t port_count;
   uint32_t lane_size;
   cpp::Atomic<uint32_t> *inbox;
@@ -105,6 +108,7 @@ template <bool Invert> struct Process {
 
   cpp::Atomic<uint32_t> lock[DEFAULT_PORT_COUNT] = {0};
 
+public:
   /// Initialize the communication channels.
   LIBC_INLINE void reset(uint64_t port_count, uint32_t lane_size,
                          void *buffer) {
@@ -131,6 +135,7 @@ template <bool Invert> struct Process {
     return buffer_offset(port_count) + buffer_bytes(port_count, lane_size);
   }
 
+protected:
   /// The length of the packet is flexible because the server needs to look up
   /// the lane size at runtime. This helper indexes at the proper offset.
   LIBC_INLINE Packet &get_packet(uint64_t index) {


        


More information about the libc-commits mailing list