[libc-commits] [libc] 0ce6b27 - [libc] Add LIBC_INLINE macro to RPC implementation

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Wed Mar 29 16:16:49 PDT 2023


Author: Joseph Huber
Date: 2023-03-29T18:16:40-05:00
New Revision: 0ce6b2788788891354f1afe779c8c0d1c3fb265d

URL: https://github.com/llvm/llvm-project/commit/0ce6b2788788891354f1afe779c8c0d1c3fb265d
DIFF: https://github.com/llvm/llvm-project/commit/0ce6b2788788891354f1afe779c8c0d1c3fb265d.diff

LOG: [libc] Add LIBC_INLINE macro to RPC implementation

These were required by the llvmlibc linter.

Reviewed By: sivachandra

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

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 8ebf40af3e265..561e90c156034 100644
--- a/libc/src/__support/RPC/rpc.h
+++ b/libc/src/__support/RPC/rpc.h
@@ -43,12 +43,17 @@ struct Buffer {
 /// server. The process contains an inbox and an outbox used for signaling
 /// ownership of the shared buffer.
 struct Process {
+  LIBC_INLINE Process() = default;
+  LIBC_INLINE Process(const Process &) = default;
+  LIBC_INLINE Process &operator=(const Process &) = default;
+  LIBC_INLINE ~Process() = default;
+
   cpp::Atomic<uint32_t> *inbox;
   cpp::Atomic<uint32_t> *outbox;
   Buffer *buffer;
 
   /// Initialize the communication channels.
-  void reset(void *inbox, void *outbox, void *buffer) {
+  LIBC_INLINE void reset(void *inbox, void *outbox, void *buffer) {
     *this = {
         reinterpret_cast<cpp::Atomic<uint32_t> *>(inbox),
         reinterpret_cast<cpp::Atomic<uint32_t> *>(outbox),
@@ -59,12 +64,22 @@ struct Process {
 
 /// The RPC client used to make requests to the server.
 struct Client : public Process {
-  template <typename F, typename U> void run(F fill, U use);
+  LIBC_INLINE Client() = default;
+  LIBC_INLINE Client(const Client &) = default;
+  LIBC_INLINE Client &operator=(const Client &) = default;
+  LIBC_INLINE ~Client() = default;
+
+  template <typename F, typename U> LIBC_INLINE void run(F fill, U use);
 };
 
 /// The RPC server used to respond to the client.
 struct Server : public Process {
-  template <typename W, typename C> bool handle(W work, C clean);
+  LIBC_INLINE Server() = default;
+  LIBC_INLINE Server(const Server &) = default;
+  LIBC_INLINE Server &operator=(const Server &) = default;
+  LIBC_INLINE ~Server() = default;
+
+  template <typename W, typename C> LIBC_INLINE bool handle(W work, C clean);
 };
 
 /// Run the RPC client protocol to communicate with the server. We perform the
@@ -73,7 +88,7 @@ struct Server : public Process {
 ///   - Wait until the inbox is 1.
 ///   - Apply \p use to the shared buffer and write 0 to the outbox.
 ///   - Wait until the inbox is 0.
-template <typename F, typename U> void Client::run(F fill, U use) {
+template <typename F, typename U> LIBC_INLINE void Client::run(F fill, U use) {
   bool in = inbox->load(cpp::MemoryOrder::RELAXED);
   bool out = outbox->load(cpp::MemoryOrder::RELAXED);
   atomic_thread_fence(cpp::MemoryOrder::ACQUIRE);
@@ -112,7 +127,8 @@ template <typename F, typename U> void Client::run(F fill, U use) {
 ///   - Apply \p work to the shared buffer and write 1 to the outbox.
 ///   - Wait until the inbox is 0.
 ///   - Apply \p clean to the shared buffer and write 0 to the outbox.
-template <typename W, typename C> bool Server::handle(W work, C clean) {
+template <typename W, typename C>
+LIBC_INLINE bool Server::handle(W work, C clean) {
   bool in = inbox->load(cpp::MemoryOrder::RELAXED);
   bool out = outbox->load(cpp::MemoryOrder::RELAXED);
   atomic_thread_fence(cpp::MemoryOrder::ACQUIRE);


        


More information about the libc-commits mailing list