[libc-commits] [libc] cb7e3da - [libc][rpc] Treat pointers as arrays consistently
Jon Chesterfield via libc-commits
libc-commits at lists.llvm.org
Thu May 4 02:53:17 PDT 2023
Author: Jon Chesterfield
Date: 2023-05-04T10:52:45+01:00
New Revision: cb7e3da0545219d39e3881c0046c73831f829741
URL: https://github.com/llvm/llvm-project/commit/cb7e3da0545219d39e3881c0046c73831f829741
DIFF: https://github.com/llvm/llvm-project/commit/cb7e3da0545219d39e3881c0046c73831f829741.diff
LOG: [libc][rpc] Treat pointers as arrays consistently
Noticed in passing. Either way compiles.
Reviewed By: jhuber6
Differential Revision: https://reviews.llvm.org/D149808
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 e478061ed33c1..18b21394d4e79 100644
--- a/libc/src/__support/RPC/rpc.h
+++ b/libc/src/__support/RPC/rpc.h
@@ -263,19 +263,19 @@ LIBC_INLINE void Port<T>::recv_n(A alloc) {
LIBC_INLINE cpp::optional<Client::Port> Client::try_open(uint16_t opcode) {
constexpr uint64_t index = 0;
// Attempt to acquire the lock on this index.
- if (lock->fetch_or(1, cpp::MemoryOrder::RELAXED))
+ if (lock[index].fetch_or(1, cpp::MemoryOrder::RELAXED))
return cpp::nullopt;
// The mailbox state must be read with the lock held.
atomic_thread_fence(cpp::MemoryOrder::ACQUIRE);
uint32_t in = load_inbox(index);
- uint32_t out = outbox->load(cpp::MemoryOrder::RELAXED);
+ uint32_t out = outbox[index].load(cpp::MemoryOrder::RELAXED);
// Once we acquire the index we need to check if we are in a valid sending
// state.
if (!can_send_data(in, out)) {
- lock->store(0, cpp::MemoryOrder::RELAXED);
+ lock[index].store(0, cpp::MemoryOrder::RELAXED);
return cpp::nullopt;
}
@@ -296,7 +296,7 @@ LIBC_INLINE Client::Port Client::open(uint16_t opcode) {
LIBC_INLINE cpp::optional<Server::Port> Server::try_open() {
constexpr uint64_t index = 0;
uint32_t in = load_inbox(index);
- uint32_t out = outbox->load(cpp::MemoryOrder::RELAXED);
+ uint32_t out = outbox[index].load(cpp::MemoryOrder::RELAXED);
// The server is passive, if there is no work pending don't bother
// opening a port.
@@ -304,17 +304,17 @@ LIBC_INLINE cpp::optional<Server::Port> Server::try_open() {
return cpp::nullopt;
// Attempt to acquire the lock on this index.
- if (lock->fetch_or(1, cpp::MemoryOrder::RELAXED))
+ if (lock[index].fetch_or(1, cpp::MemoryOrder::RELAXED))
return cpp::nullopt;
// The mailbox state must be read with the lock held.
atomic_thread_fence(cpp::MemoryOrder::ACQUIRE);
in = load_inbox(index);
- out = outbox->load(cpp::MemoryOrder::RELAXED);
+ out = outbox[index].load(cpp::MemoryOrder::RELAXED);
if (!can_recv_data(in, out)) {
- lock->store(0, cpp::MemoryOrder::RELAXED);
+ lock[index].store(0, cpp::MemoryOrder::RELAXED);
return cpp::nullopt;
}
More information about the libc-commits
mailing list