Skip to content

Commit e85a9f5

Browse files
authored
libc: Prefix RPC Status code to avoid conflict in windows build (#119991)
Somehow conflict with define in wingdi.h. Fix build failures: [ 52%] Building CXX object projects/offload/plugins-nextgen/common/CMakeFiles/PluginCommon.dir/src/RPC.cpp.obj In file included from ...llvm\offload\plugins-nextgen\common\src\RPC.cpp:16: ...\llvm\libc\shared\rpc.h(48,3): error: expected identifier 48 | ERROR = 0x1000, | ^ c:\Program files (x86)\Windows Kits\10\include\10.0.22000.0\um\wingdi.h(118,29): note: expanded from macro 'ERROR' 118 | #define ERROR 0 | ^ ...\llvm\offload\plugins-nextgen\common\src\RPC.cpp(75,17): error: expected unqualified-id 75 | return rpc::ERROR; | ^ c:\Program files (x86)\Windows Kits\10\include\10.0.22000.0\um\wingdi.h(118,29): note: expanded from macro 'ERROR' 118 | #define ERROR 0 | ^ 2 errors generated.
1 parent e1271dd commit e85a9f5

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

libc/shared/rpc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ namespace rpc {
4444

4545
/// Generic codes that can be used whem implementing the server.
4646
enum Status {
47-
SUCCESS = 0x0,
48-
ERROR = 0x1000,
49-
UNHANDLED_OPCODE = 0x1001,
47+
RPC_SUCCESS = 0x0,
48+
RPC_ERROR = 0x1000,
49+
RPC_UNHANDLED_OPCODE = 0x1001,
5050
};
5151

5252
/// A fixed size channel used to communicate between the RPC client and server.

libc/utils/gpu/loader/Loader.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ inline uint32_t handle_server(rpc::Server &server, uint32_t index,
113113
return 0;
114114
index = port->get_index() + 1;
115115

116-
int status = rpc::SUCCESS;
116+
int status = rpc::RPC_SUCCESS;
117117
switch (port->get_opcode()) {
118118
case RPC_TEST_INCREMENT: {
119119
port->recv_and_send([](rpc::Buffer *buffer, uint32_t) {
@@ -186,7 +186,7 @@ inline uint32_t handle_server(rpc::Server &server, uint32_t index,
186186
}
187187

188188
// Handle all of the `libc` specific opcodes.
189-
if (status != rpc::SUCCESS)
189+
if (status != rpc::RPC_SUCCESS)
190190
handle_error("Error handling RPC server");
191191

192192
port->close();

libc/utils/gpu/server/rpc_server.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,10 @@ rpc::Status handle_port_impl(rpc::Server::Port &port) {
437437
break;
438438
}
439439
default:
440-
return rpc::UNHANDLED_OPCODE;
440+
return rpc::RPC_UNHANDLED_OPCODE;
441441
}
442442

443-
return rpc::SUCCESS;
443+
return rpc::RPC_SUCCESS;
444444
}
445445

446446
namespace rpc {
@@ -455,7 +455,7 @@ rpc::Status handle_libc_opcodes(rpc::Server::Port &port, uint32_t num_lanes) {
455455
case 64:
456456
return handle_port_impl<64>(port);
457457
default:
458-
return rpc::ERROR;
458+
return rpc::RPC_ERROR;
459459
}
460460
}
461461
} // namespace rpc

offload/plugins-nextgen/common/src/RPC.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ rpc::Status handle_offload_opcodes(plugin::GenericDeviceTy &Device,
5656
break;
5757
}
5858
default:
59-
return rpc::UNHANDLED_OPCODE;
59+
return rpc::RPC_UNHANDLED_OPCODE;
6060
break;
6161
}
62-
return rpc::SUCCESS;
62+
return rpc::RPC_SUCCESS;
6363
}
6464

6565
static rpc::Status handle_offload_opcodes(plugin::GenericDeviceTy &Device,
@@ -72,7 +72,7 @@ static rpc::Status handle_offload_opcodes(plugin::GenericDeviceTy &Device,
7272
else if (NumLanes == 64)
7373
return handle_offload_opcodes<64>(Device, Port);
7474
else
75-
return rpc::ERROR;
75+
return rpc::RPC_ERROR;
7676
}
7777

7878
RPCServerTy::RPCServerTy(plugin::GenericPluginTy &Plugin)
@@ -125,12 +125,12 @@ Error RPCServerTy::runServer(plugin::GenericDeviceTy &Device) {
125125

126126
// Let the `libc` library handle any other unhandled opcodes.
127127
#ifdef LIBOMPTARGET_RPC_SUPPORT
128-
if (Status == rpc::UNHANDLED_OPCODE)
128+
if (Status == rpc::RPC_UNHANDLED_OPCODE)
129129
Status = handle_libc_opcodes(*Port, Device.getWarpSize());
130130
#endif
131131

132132
Port->close();
133-
if (Status != rpc::SUCCESS)
133+
if (Status != rpc::RPC_SUCCESS)
134134
return createStringError("RPC server given invalid opcode!");
135135

136136
return Error::success();

0 commit comments

Comments
 (0)