[libc-commits] [PATCH] D150118: [libc] Prevent changing ownership of the port once opened

Joseph Huber via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed May 10 16:34:44 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rGbcc2021efdab: [libc] Prevent changing ownership of the port once opened (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150118/new/

https://reviews.llvm.org/D150118

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


Index: libc/src/__support/RPC/rpc.h
===================================================================
--- libc/src/__support/RPC/rpc.h
+++ libc/src/__support/RPC/rpc.h
@@ -250,16 +250,22 @@
 /// processes. A port is conceptually an index into the memory provided by the
 /// underlying process that is guarded by a lock bit.
 template <bool T> struct Port {
-  // TODO: This should be move-only.
   LIBC_INLINE Port(Process<T> &process, uint64_t lane_mask, uint64_t index,
                    uint32_t out)
       : process(process), lane_mask(lane_mask), index(index), out(out) {}
+  LIBC_INLINE ~Port() = default;
+
+private:
   LIBC_INLINE Port(const Port &) = delete;
   LIBC_INLINE Port &operator=(const Port &) = delete;
   LIBC_INLINE Port(Port &&) = default;
   LIBC_INLINE Port &operator=(Port &&) = default;
-  LIBC_INLINE ~Port() = default;
 
+  friend struct Client;
+  friend struct Server;
+  friend class cpp::optional<Port<T>>;
+
+public:
   template <typename U> LIBC_INLINE void recv(U use);
   template <typename F> LIBC_INLINE void send(F fill);
   template <typename F, typename U>


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150118.521154.patch
Type: text/x-patch
Size: 1105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230510/4bc228ca/attachment.bin>


More information about the libc-commits mailing list