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/hle/service/sockets/bsd.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core/hle/service/sockets/bsd.cpp') diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index a9875b9a6..70860e7f8 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp @@ -489,18 +489,18 @@ std::pair BSD::PollImpl(std::vector& write_buffer, std::vector static_cast(MAX_FD) || pollfd.fd < 0) { LOG_ERROR(Service, "File descriptor handle={} is invalid", pollfd.fd); - pollfd.revents = 0; + pollfd.revents = PollEvents{}; return {0, Errno::SUCCESS}; } const std::optional& descriptor = file_descriptors[pollfd.fd]; if (!descriptor) { LOG_ERROR(Service, "File descriptor handle={} is not allocated", pollfd.fd); - pollfd.revents = POLL_NVAL; + pollfd.revents = PollEvents::Nval; return {0, Errno::SUCCESS}; } } @@ -510,7 +510,7 @@ std::pair BSD::PollImpl(std::vector& write_buffer, std::vectorsocket.get(); result.events = TranslatePollEventsToHost(pollfd.events); - result.revents = 0; + result.revents = Network::PollEvents{}; return result; }); -- cgit v1.2.3