summaryrefslogtreecommitdiff
path: root/libc/src
diff options
context:
space:
mode:
authorJon Chesterfield <jonathanchesterfield@gmail.com>2023-05-11 00:39:54 +0100
committerJon Chesterfield <jonathanchesterfield@gmail.com>2023-05-11 00:41:51 +0100
commitf497611f436cbf5ae0157edcf498f62a136799cb (patch)
tree9e27d72e406e4979b710ffa943ae5c554d2d233f /libc/src
parent958a3d8e2dec95a878dfc9d823861b3a6c674534 (diff)
downloadllvm-f497611f436cbf5ae0157edcf498f62a136799cb.tar.gz
[libc][rpc] Allocate locks array within process
Replaces the globals currently used. Worth changing to a bitmap before allowing runtime number of ports >> 64. One bit per port is likely to be cheap enough that sizing for the worst case is always fine, otherwise in the future we can change to dynamically allocating it. Reviewed By: jhuber6 Differential Revision: https://reviews.llvm.org/D150309
Diffstat (limited to 'libc/src')
-rw-r--r--libc/src/__support/RPC/rpc.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/libc/src/__support/RPC/rpc.h b/libc/src/__support/RPC/rpc.h
index ae905bccbc65..d448e190214f 100644
--- a/libc/src/__support/RPC/rpc.h
+++ b/libc/src/__support/RPC/rpc.h
@@ -106,20 +106,20 @@ template <bool InvertInbox> struct Process {
uint64_t port_count;
uint32_t lane_size;
- cpp::Atomic<uint32_t> *lock;
cpp::Atomic<uint32_t> *inbox;
cpp::Atomic<uint32_t> *outbox;
Packet *packet;
+ cpp::Atomic<uint32_t> lock[default_port_count] = {0};
+
/// Initialize the communication channels.
- LIBC_INLINE void reset(uint64_t port_count, uint32_t lane_size, void *lock,
- void *inbox, void *outbox, void *packet) {
- *this = {port_count,
- lane_size,
- reinterpret_cast<cpp::Atomic<uint32_t> *>(lock),
- reinterpret_cast<cpp::Atomic<uint32_t> *>(inbox),
- reinterpret_cast<cpp::Atomic<uint32_t> *>(outbox),
- reinterpret_cast<Packet *>(packet)};
+ LIBC_INLINE void reset(uint64_t port_count, uint32_t lane_size, void *inbox,
+ void *outbox, void *packet) {
+ this->port_count = port_count;
+ this->lane_size = lane_size;
+ this->inbox = reinterpret_cast<cpp::Atomic<uint32_t> *>(inbox);
+ this->outbox = reinterpret_cast<cpp::Atomic<uint32_t> *>(outbox);
+ this->packet = reinterpret_cast<Packet *>(packet);
}
/// The length of the packet is flexible because the server needs to look up