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.cpp | 31 ++++++++++++++----------------- src/core/network/network.h | 12 ++++++------ src/core/network/sockets.h | 6 +++--- 3 files changed, 23 insertions(+), 26 deletions(-) (limited to 'src/core/network') diff --git a/src/core/network/network.cpp b/src/core/network/network.cpp index d280f7a28..4b3bb4366 100644 --- a/src/core/network/network.cpp +++ b/src/core/network/network.cpp @@ -96,7 +96,7 @@ int LastError() { bool EnableNonBlock(SOCKET fd, bool enable) { u_long value = enable ? 1 : 0; - return ioctlsocket(fd, static_cast(FIONBIO), &value) != SOCKET_ERROR; + return ioctlsocket(fd, FIONBIO, &value) != SOCKET_ERROR; } #elif __unix__ // ^ _WIN32 v __unix__ @@ -140,9 +140,7 @@ sockaddr TranslateFromSockAddrIn(SockAddrIn input) { result.sin_port = htons(input.portno); - result.sin_addr.s_addr = static_cast( - input.ip[0] | static_cast(input.ip[1] << 8) | static_cast(input.ip[2] << 16) | - static_cast(input.ip[3] << 24)); + result.sin_addr.s_addr = input.ip[0] | input.ip[1] << 8 | input.ip[2] << 16 | input.ip[3] << 24; sockaddr addr; std::memcpy(&addr, &result, sizeof(addr)); @@ -150,7 +148,7 @@ sockaddr TranslateFromSockAddrIn(SockAddrIn input) { } int WSAPoll(WSAPOLLFD* fds, ULONG nfds, int timeout) { - return poll(fds, static_cast(nfds), timeout); + return poll(fds, nfds, timeout); } int closesocket(SOCKET fd) { @@ -160,7 +158,7 @@ int closesocket(SOCKET fd) { linger MakeLinger(bool enable, u32 linger_value) { linger value; value.l_onoff = enable ? 1 : 0; - value.l_linger = static_cast(linger_value); + value.l_linger = linger_value; return value; } @@ -339,7 +337,7 @@ std::pair Poll(std::vector& pollfds, s32 timeout) { std::transform(pollfds.begin(), pollfds.end(), host_pollfds.begin(), [](PollFD fd) { WSAPOLLFD result; result.fd = fd.socket->fd; - result.events = static_cast(TranslatePollEvents(fd.events)); + result.events = TranslatePollEvents(fd.events); result.revents = 0; return result; }); @@ -501,12 +499,12 @@ Errno Socket::Shutdown(ShutdownHow how) { } } -std::pair Socket::Recv(u32 flags, std::vector& message) { +std::pair Socket::Recv(int flags, std::vector& message) { ASSERT(flags == 0); ASSERT(message.size() < static_cast(std::numeric_limits::max())); - const auto result = recv(fd, reinterpret_cast(message.data()), - static_cast(message.size()), 0); + const auto result = + recv(fd, reinterpret_cast(message.data()), static_cast(message.size()), 0); if (result != SOCKET_ERROR) { return {static_cast(result), Errno::SUCCESS}; } @@ -524,7 +522,7 @@ std::pair Socket::Recv(u32 flags, std::vector& message) { } } -std::pair Socket::RecvFrom(u32 flags, std::vector& message, SockAddrIn* addr) { +std::pair Socket::RecvFrom(int flags, std::vector& message, SockAddrIn* addr) { ASSERT(flags == 0); ASSERT(message.size() < static_cast(std::numeric_limits::max())); @@ -534,7 +532,7 @@ std::pair Socket::RecvFrom(u32 flags, std::vector& message, Sock sockaddr* const p_addr_in = addr ? &addr_in : nullptr; const auto result = recvfrom(fd, reinterpret_cast(message.data()), - static_cast(message.size()), 0, p_addr_in, p_addrlen); + static_cast(message.size()), 0, p_addr_in, p_addrlen); if (result != SOCKET_ERROR) { if (addr) { ASSERT(addrlen == sizeof(addr_in)); @@ -556,12 +554,12 @@ std::pair Socket::RecvFrom(u32 flags, std::vector& message, Sock } } -std::pair Socket::Send(const std::vector& message, u32 flags) { +std::pair Socket::Send(const std::vector& message, int flags) { ASSERT(message.size() < static_cast(std::numeric_limits::max())); ASSERT(flags == 0); const auto result = send(fd, reinterpret_cast(message.data()), - static_cast(message.size()), 0); + static_cast(message.size()), 0); if (result != SOCKET_ERROR) { return {static_cast(result), Errno::SUCCESS}; } @@ -593,9 +591,8 @@ std::pair Socket::SendTo(u32 flags, const std::vector& message, to = &host_addr_in; } - const auto result = - sendto(fd, reinterpret_cast(message.data()), - static_cast(message.size()), 0, to, static_cast(tolen)); + const auto result = sendto(fd, reinterpret_cast(message.data()), + static_cast(message.size()), 0, to, tolen); if (result != SOCKET_ERROR) { return {static_cast(result), Errno::SUCCESS}; } 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: diff --git a/src/core/network/sockets.h b/src/core/network/sockets.h index 1682cbd4e..7bdff0fe4 100644 --- a/src/core/network/sockets.h +++ b/src/core/network/sockets.h @@ -56,11 +56,11 @@ public: Errno Shutdown(ShutdownHow how); - std::pair Recv(u32 flags, std::vector& message); + std::pair Recv(int flags, std::vector& message); - std::pair RecvFrom(u32 flags, std::vector& message, SockAddrIn* addr); + std::pair RecvFrom(int flags, std::vector& message, SockAddrIn* addr); - std::pair Send(const std::vector& message, u32 flags); + std::pair Send(const std::vector& message, int flags); std::pair SendTo(u32 flags, const std::vector& message, const SockAddrIn* addr); -- cgit v1.2.3