diff options
author | Lioncash <mathew1800@gmail.com> | 2020-10-15 20:49:45 +0200 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2020-10-18 01:50:39 +0200 |
commit | be1954e04cb5a0c3a526f78ed5490a5e65310280 (patch) | |
tree | 267db7ae4be88dbbc288fa605e35d4a2a13839f6 /src/core/network | |
parent | Merge pull request #4787 from lioncash/conversion (diff) | |
download | yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar.gz yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar.bz2 yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar.lz yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar.xz yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.tar.zst yuzu-be1954e04cb5a0c3a526f78ed5490a5e65310280.zip |
Diffstat (limited to 'src/core/network')
-rw-r--r-- | src/core/network/network.cpp | 31 | ||||
-rw-r--r-- | src/core/network/network.h | 12 | ||||
-rw-r--r-- | src/core/network/sockets.h | 6 |
3 files changed, 26 insertions, 23 deletions
diff --git a/src/core/network/network.cpp b/src/core/network/network.cpp index 4b3bb4366..d280f7a28 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, FIONBIO, &value) != SOCKET_ERROR; + return ioctlsocket(fd, static_cast<long>(FIONBIO), &value) != SOCKET_ERROR; } #elif __unix__ // ^ _WIN32 v __unix__ @@ -140,7 +140,9 @@ sockaddr TranslateFromSockAddrIn(SockAddrIn input) { result.sin_port = htons(input.portno); - result.sin_addr.s_addr = input.ip[0] | input.ip[1] << 8 | input.ip[2] << 16 | input.ip[3] << 24; + result.sin_addr.s_addr = static_cast<in_addr_t>( + input.ip[0] | static_cast<u32>(input.ip[1] << 8) | static_cast<u32>(input.ip[2] << 16) | + static_cast<u32>(input.ip[3] << 24)); sockaddr addr; std::memcpy(&addr, &result, sizeof(addr)); @@ -148,7 +150,7 @@ sockaddr TranslateFromSockAddrIn(SockAddrIn input) { } int WSAPoll(WSAPOLLFD* fds, ULONG nfds, int timeout) { - return poll(fds, nfds, timeout); + return poll(fds, static_cast<nfds_t>(nfds), timeout); } int closesocket(SOCKET fd) { @@ -158,7 +160,7 @@ int closesocket(SOCKET fd) { linger MakeLinger(bool enable, u32 linger_value) { linger value; value.l_onoff = enable ? 1 : 0; - value.l_linger = linger_value; + value.l_linger = static_cast<s32>(linger_value); return value; } @@ -337,7 +339,7 @@ std::pair<s32, Errno> Poll(std::vector<PollFD>& pollfds, s32 timeout) { std::transform(pollfds.begin(), pollfds.end(), host_pollfds.begin(), [](PollFD fd) { WSAPOLLFD result; result.fd = fd.socket->fd; - result.events = TranslatePollEvents(fd.events); + result.events = static_cast<s16>(TranslatePollEvents(fd.events)); result.revents = 0; return result; }); @@ -499,12 +501,12 @@ Errno Socket::Shutdown(ShutdownHow how) { } } -std::pair<s32, Errno> Socket::Recv(int flags, std::vector<u8>& message) { +std::pair<s32, Errno> Socket::Recv(u32 flags, std::vector<u8>& message) { ASSERT(flags == 0); ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max())); - const auto result = - recv(fd, reinterpret_cast<char*>(message.data()), static_cast<int>(message.size()), 0); + const auto result = recv(fd, reinterpret_cast<char*>(message.data()), + static_cast<socklen_t>(message.size()), 0); if (result != SOCKET_ERROR) { return {static_cast<s32>(result), Errno::SUCCESS}; } @@ -522,7 +524,7 @@ std::pair<s32, Errno> Socket::Recv(int flags, std::vector<u8>& message) { } } -std::pair<s32, Errno> Socket::RecvFrom(int flags, std::vector<u8>& message, SockAddrIn* addr) { +std::pair<s32, Errno> Socket::RecvFrom(u32 flags, std::vector<u8>& message, SockAddrIn* addr) { ASSERT(flags == 0); ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max())); @@ -532,7 +534,7 @@ std::pair<s32, Errno> Socket::RecvFrom(int flags, std::vector<u8>& message, Sock sockaddr* const p_addr_in = addr ? &addr_in : nullptr; const auto result = recvfrom(fd, reinterpret_cast<char*>(message.data()), - static_cast<int>(message.size()), 0, p_addr_in, p_addrlen); + static_cast<socklen_t>(message.size()), 0, p_addr_in, p_addrlen); if (result != SOCKET_ERROR) { if (addr) { ASSERT(addrlen == sizeof(addr_in)); @@ -554,12 +556,12 @@ std::pair<s32, Errno> Socket::RecvFrom(int flags, std::vector<u8>& message, Sock } } -std::pair<s32, Errno> Socket::Send(const std::vector<u8>& message, int flags) { +std::pair<s32, Errno> Socket::Send(const std::vector<u8>& message, u32 flags) { ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max())); ASSERT(flags == 0); const auto result = send(fd, reinterpret_cast<const char*>(message.data()), - static_cast<int>(message.size()), 0); + static_cast<socklen_t>(message.size()), 0); if (result != SOCKET_ERROR) { return {static_cast<s32>(result), Errno::SUCCESS}; } @@ -591,8 +593,9 @@ std::pair<s32, Errno> Socket::SendTo(u32 flags, const std::vector<u8>& message, to = &host_addr_in; } - const auto result = sendto(fd, reinterpret_cast<const char*>(message.data()), - static_cast<int>(message.size()), 0, to, tolen); + const auto result = + sendto(fd, reinterpret_cast<const char*>(message.data()), + static_cast<socklen_t>(message.size()), 0, to, static_cast<socklen_t>(tolen)); if (result != SOCKET_ERROR) { return {static_cast<s32>(result), Errno::SUCCESS}; } 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: diff --git a/src/core/network/sockets.h b/src/core/network/sockets.h index 7bdff0fe4..1682cbd4e 100644 --- a/src/core/network/sockets.h +++ b/src/core/network/sockets.h @@ -56,11 +56,11 @@ public: Errno Shutdown(ShutdownHow how); - std::pair<s32, Errno> Recv(int flags, std::vector<u8>& message); + std::pair<s32, Errno> Recv(u32 flags, std::vector<u8>& message); - std::pair<s32, Errno> RecvFrom(int flags, std::vector<u8>& message, SockAddrIn* addr); + std::pair<s32, Errno> RecvFrom(u32 flags, std::vector<u8>& message, SockAddrIn* addr); - std::pair<s32, Errno> Send(const std::vector<u8>& message, int flags); + std::pair<s32, Errno> Send(const std::vector<u8>& message, u32 flags); std::pair<s32, Errno> SendTo(u32 flags, const std::vector<u8>& message, const SockAddrIn* addr); |