From b2d3a6574c9f9c784d71f1a36f8ab6ec44b0e18c Mon Sep 17 00:00:00 2001 From: Joseph Huber Date: Thu, 2 Apr 2026 14:55:57 -0500 Subject: [PATCH] [libc] Rename rpc::Status to rpc::RPCStatus to reduce conflicts (#190239) Summary: `Status` is unfortunately heavily overloaded in practice. Things like X11 define it as a macro. Best to just remove that possibility entirely. --- flang-rt/lib/runtime/io-api-server.cpp | 2 +- libc/shared/rpc.h | 2 +- libc/src/__support/RPC/rpc_server.h | 6 +++--- offload/plugins-nextgen/common/src/RPC.cpp | 18 +++++++++--------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/flang-rt/lib/runtime/io-api-server.cpp b/flang-rt/lib/runtime/io-api-server.cpp index d4ef3876a3f8..9803c831fa9b 100644 --- a/flang-rt/lib/runtime/io-api-server.cpp +++ b/flang-rt/lib/runtime/io-api-server.cpp @@ -156,7 +156,7 @@ bool EnqueueDeferred(FnTy &&fn, Cookie cookie, Args &&...args) { } template -rpc::Status HandleOpcodesImpl(rpc::Server::Port &port) { +rpc::RPCStatus HandleOpcodesImpl(rpc::Server::Port &port) { switch (port.get_opcode()) { case BeginExternalListOutput_Opcode: rpc::invoke(port, diff --git a/libc/shared/rpc.h b/libc/shared/rpc.h index 644d1bbf1020..9886c3851b25 100644 --- a/libc/shared/rpc.h +++ b/libc/shared/rpc.h @@ -41,7 +41,7 @@ namespace rpc { #endif /// Generic codes that can be used when implementing the server. -enum Status { +enum RPCStatus { RPC_SUCCESS = 0x0, RPC_ERROR = 0x1000, RPC_UNHANDLED_OPCODE = 0x1001, diff --git a/libc/src/__support/RPC/rpc_server.h b/libc/src/__support/RPC/rpc_server.h index 8ea43c91826e..3dfd79c6ecd0 100644 --- a/libc/src/__support/RPC/rpc_server.h +++ b/libc/src/__support/RPC/rpc_server.h @@ -311,7 +311,7 @@ LIBC_INLINE static void handle_printf(rpc::Server::Port &port, } template -LIBC_INLINE static rpc::Status handle_port_impl(rpc::Server::Port &port) { +LIBC_INLINE static rpc::RPCStatus handle_port_impl(rpc::Server::Port &port) { TempStorage temp_storage; switch (port.get_opcode()) { @@ -586,8 +586,8 @@ namespace LIBC_NAMESPACE_DECL { namespace rpc { // Handles any opcode generated from the 'libc' client code. -LIBC_INLINE ::rpc::Status handle_libc_opcodes(::rpc::Server::Port &port, - uint32_t num_lanes) { +LIBC_INLINE ::rpc::RPCStatus handle_libc_opcodes(::rpc::Server::Port &port, + uint32_t num_lanes) { switch (num_lanes) { case 1: return internal::handle_port_impl<1>(port); diff --git a/offload/plugins-nextgen/common/src/RPC.cpp b/offload/plugins-nextgen/common/src/RPC.cpp index b37be170484b..4c03fa1517f7 100644 --- a/offload/plugins-nextgen/common/src/RPC.cpp +++ b/offload/plugins-nextgen/common/src/RPC.cpp @@ -26,8 +26,8 @@ using namespace omp; using namespace target; template -rpc::Status handleOffloadOpcodes(plugin::GenericDeviceTy &Device, - rpc::Server::Port &Port) { +rpc::RPCStatus handleOffloadOpcodes(plugin::GenericDeviceTy &Device, + rpc::Server::Port &Port) { switch (Port.get_opcode()) { case LIBC_MALLOC: { @@ -74,9 +74,9 @@ rpc::Status handleOffloadOpcodes(plugin::GenericDeviceTy &Device, return rpc::RPC_SUCCESS; } -static rpc::Status handleOffloadOpcodes(plugin::GenericDeviceTy &Device, - rpc::Server::Port &Port, - uint32_t NumLanes) { +static rpc::RPCStatus handleOffloadOpcodes(plugin::GenericDeviceTy &Device, + rpc::Server::Port &Port, + uint32_t NumLanes) { if (NumLanes == 1) return handleOffloadOpcodes<1>(Device, Port); else if (NumLanes == 32) @@ -87,7 +87,7 @@ static rpc::Status handleOffloadOpcodes(plugin::GenericDeviceTy &Device, return rpc::RPC_ERROR; } -static rpc::Status +static rpc::RPCStatus runServer(plugin::GenericDeviceTy &Device, void *Buffer, llvm::SmallSetVector &Callbacks, bool &ClientInUse) { @@ -100,11 +100,11 @@ runServer(plugin::GenericDeviceTy &Device, void *Buffer, return rpc::RPC_SUCCESS; ClientInUse = true; - rpc::Status Status = rpc::RPC_UNHANDLED_OPCODE; + rpc::RPCStatus Status = rpc::RPC_UNHANDLED_OPCODE; const uint32_t NumLanes = Device.getRPCNumLanes(); for (RPCServerTy::RPCServerCallbackTy Callback : Callbacks) { - Status = static_cast(Callback(&*Port, NumLanes)); + Status = static_cast(Callback(&*Port, NumLanes)); if (Status != rpc::RPC_UNHANDLED_OPCODE) break; } @@ -117,7 +117,7 @@ runServer(plugin::GenericDeviceTy &Device, void *Buffer, #ifdef OFFLOAD_HAS_FLANG_RT if (Status == rpc::RPC_UNHANDLED_OPCODE) - Status = static_cast( + Status = static_cast( Fortran::runtime::io::IONAME(HandleRPCOpcodes)(&*Port, NumLanes)); #endif