From be1954e04cb5a0c3a526f78ed5490a5e65310280 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 15 Oct 2020 14:49:45 -0400 Subject: core: Fix clang build Recent changes to the build system that made more warnings be flagged as errors caused building via clang to break. Fixes #4795 --- src/core/network/network.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/core/network/network.h') diff --git a/src/core/network/network.h b/src/core/network/network.h index 0622e4593..b95bf68f8 100644 --- a/src/core/network/network.h +++ b/src/core/network/network.h @@ -67,12 +67,12 @@ struct PollFD { u16 revents; }; -constexpr u16 POLL_IN = 1 << 0; -constexpr u16 POLL_PRI = 1 << 1; -constexpr u16 POLL_OUT = 1 << 2; -constexpr u16 POLL_ERR = 1 << 3; -constexpr u16 POLL_HUP = 1 << 4; -constexpr u16 POLL_NVAL = 1 << 5; +constexpr u32 POLL_IN = 1 << 0; +constexpr u32 POLL_PRI = 1 << 1; +constexpr u32 POLL_OUT = 1 << 2; +constexpr u32 POLL_ERR = 1 << 3; +constexpr u32 POLL_HUP = 1 << 4; +constexpr u32 POLL_NVAL = 1 << 5; class NetworkInstance { public: -- cgit v1.2.3 From 3d592972dc3fd61cc88771b889eff237e4e03e0f Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 20 Oct 2020 19:07:39 -0700 Subject: Revert "core: Fix clang build" --- src/core/network/network.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/core/network/network.h') diff --git a/src/core/network/network.h b/src/core/network/network.h index b95bf68f8..0622e4593 100644 --- a/src/core/network/network.h +++ b/src/core/network/network.h @@ -67,12 +67,12 @@ struct PollFD { u16 revents; }; -constexpr u32 POLL_IN = 1 << 0; -constexpr u32 POLL_PRI = 1 << 1; -constexpr u32 POLL_OUT = 1 << 2; -constexpr u32 POLL_ERR = 1 << 3; -constexpr u32 POLL_HUP = 1 << 4; -constexpr u32 POLL_NVAL = 1 << 5; +constexpr u16 POLL_IN = 1 << 0; +constexpr u16 POLL_PRI = 1 << 1; +constexpr u16 POLL_OUT = 1 << 2; +constexpr u16 POLL_ERR = 1 << 3; +constexpr u16 POLL_HUP = 1 << 4; +constexpr u16 POLL_NVAL = 1 << 5; class NetworkInstance { public: -- cgit v1.2.3 From 0791082b435371837bbecd50575911ce0ba16dc9 Mon Sep 17 00:00:00 2001 From: comex Date: Mon, 31 Aug 2020 10:20:44 -0400 Subject: network, sockets: Replace `POLL_IN`, `POLL_OUT`, etc. constants with an `enum class PollEvents` Actually, two enum classes, since for some reason there are two separate yet identical `PollFD` types used in the codebase. I get that one is ABI-compatible with the Switch while the other is an abstract type used for the host, but why not use `WSAPOLLFD` directly for the latter? Anyway, why make this change? Because on Apple platforms, `POLL_IN`, `POLL_OUT`, etc. (with an underscore) are defined as macros in . (This is inherited from FreeBSD.) So defining a variable with the same name causes a compile error. I could just rename the variables, but while I was at it I thought I might as well switch to an enum for stronger typing. Also, change the type used for values copied directly to/from the `events` and `revents` fields of the host *native* `pollfd`/`WSASPOLLFD`, from `u32` to `short`, as `short` is the correct canonical type on both Unix and Windows. --- src/core/network/network.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/core/network/network.h') diff --git a/src/core/network/network.h b/src/core/network/network.h index 0622e4593..76b2821f2 100644 --- a/src/core/network/network.h +++ b/src/core/network/network.h @@ -61,19 +61,25 @@ struct SockAddrIn { }; /// Cross-platform poll fd structure + +enum class PollEvents : u16 { + // Using Pascal case because IN is a macro on Windows. + In = 1 << 0, + Pri = 1 << 1, + Out = 1 << 2, + Err = 1 << 3, + Hup = 1 << 4, + Nval = 1 << 5, +}; + +DECLARE_ENUM_FLAG_OPERATORS(PollEvents); + struct PollFD { Socket* socket; - u16 events; - u16 revents; + PollEvents events; + PollEvents revents; }; -constexpr u16 POLL_IN = 1 << 0; -constexpr u16 POLL_PRI = 1 << 1; -constexpr u16 POLL_OUT = 1 << 2; -constexpr u16 POLL_ERR = 1 << 3; -constexpr u16 POLL_HUP = 1 << 4; -constexpr u16 POLL_NVAL = 1 << 5; - class NetworkInstance { public: explicit NetworkInstance(); -- cgit v1.2.3