Skip to content

Commit 29e7d26

Browse files
committed
util, gen, proxy: Fix Windows cross-build issues
1 parent 8f4bbfe commit 29e7d26

4 files changed

Lines changed: 16 additions & 13 deletions

File tree

include/mp/util.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323
#include <variant>
2424
#include <vector>
2525

26-
#ifdef WIN32
27-
#include <winsock2.h>
28-
#endif
29-
3026
namespace mp {
3127

3228
//! Generic utility functions used by capnp code.
@@ -261,7 +257,7 @@ using Stream = kj::Own<kj::AsyncIoStream>;
261257
#ifdef WIN32
262258
using ProcessId = uintptr_t;
263259
using SocketId = uintptr_t;
264-
constexpr SocketId SocketError{INVALID_SOCKET};
260+
constexpr SocketId SocketError{static_cast<SocketId>(-1)};
265261
#else
266262
using ProcessId = int;
267263
using SocketId = int;

src/mp/gen.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ static bool GetAnnotationInt32(const Reader& reader, uint64_t id, int32_t* resul
7878
return false;
7979
}
8080

81-
static void ForEachMethod(const capnp::InterfaceSchema& interface, const std::function<void(const capnp::InterfaceSchema& interface, const capnp::InterfaceSchema::Method)>& callback) // NOLINT(misc-no-recursion)
81+
static void ForEachMethod(const capnp::InterfaceSchema& schema, const std::function<void(const capnp::InterfaceSchema& schema, const capnp::InterfaceSchema::Method)>& callback) // NOLINT(misc-no-recursion)
8282
{
83-
for (const auto super : interface.getSuperclasses()) {
83+
for (const auto super : schema.getSuperclasses()) {
8484
ForEachMethod(super, callback);
8585
}
86-
for (const auto method : interface.getMethods()) {
87-
callback(interface, method);
86+
for (const auto method : schema.getMethods()) {
87+
callback(schema, method);
8888
}
8989
}
9090

@@ -391,7 +391,7 @@ static void Generate(kj::StringPtr src_prefix,
391391
}
392392

393393
if (proxied_class_type.size() && node.getProto().isInterface()) {
394-
const auto& interface = node.asInterface();
394+
const auto& node_interface = node.asInterface();
395395

396396
std::ostringstream client;
397397
client << "template<>\nstruct ProxyClient<" << message_namespace << "::" << node_name << "> final : ";
@@ -413,7 +413,7 @@ static void Generate(kj::StringPtr src_prefix,
413413
const std::ostringstream client_destroy;
414414

415415
int method_ordinal = 0;
416-
ForEachMethod(interface, [&] (const capnp::InterfaceSchema& method_interface, const capnp::InterfaceSchema::Method& method) {
416+
ForEachMethod(node_interface, [&] (const capnp::InterfaceSchema& method_interface, const capnp::InterfaceSchema::Method& method) {
417417
const kj::StringPtr method_name = method.getProto().getName();
418418
kj::StringPtr proxied_method_name = method_name;
419419
GetAnnotationText(method.getProto(), NAME_ANNOTATION_ID, &proxied_method_name);
@@ -503,7 +503,7 @@ static void Generate(kj::StringPtr src_prefix,
503503
}
504504
}
505505

506-
if (!is_construct && !is_destroy && (&method_interface == &interface)) {
506+
if (!is_construct && !is_destroy && (&method_interface == &node_interface)) {
507507
methods << "template<>\n";
508508
methods << "struct ProxyMethod<" << method_prefix << "Params>\n";
509509
methods << "{\n";

src/mp/proxy.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@
3636
#include <tuple>
3737
#include <utility>
3838

39+
#ifdef WIN32
40+
#include <winsock2.h>
41+
#ifdef ERROR
42+
#undef ERROR
43+
#endif
44+
#endif
45+
3946
namespace mp {
4047

4148
thread_local ThreadContext g_thread_context; // NOLINT(bitcoin-nontrivial-threadlocal)

src/mp/util.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
#ifdef WIN32
2525
#include <atomic>
26-
#include <windows.h>
2726
#include <winsock2.h>
27+
#include <windows.h>
2828
#else
2929
#include <fcntl.h>
3030
#include <sys/resource.h>

0 commit comments

Comments
 (0)