summaryrefslogtreecommitdiffstats
path: root/src/core/network
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-10-21 04:07:39 +0200
committerGitHub <noreply@github.com>2020-10-21 04:07:39 +0200
commit3d592972dc3fd61cc88771b889eff237e4e03e0f (patch)
tree0dbc65ac86e609ae22087c7be9d4759ac6b73004 /src/core/network
parentkernel: Fix build with recent compiler flag changes (diff)
downloadyuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar
yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.gz
yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.bz2
yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.lz
yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.xz
yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.tar.zst
yuzu-3d592972dc3fd61cc88771b889eff237e4e03e0f.zip
Diffstat (limited to 'src/core/network')
-rw-r--r--src/core/network/network.cpp31
-rw-r--r--src/core/network/network.h12
-rw-r--r--src/core/network/sockets.h6
3 files changed, 23 insertions, 26 deletions
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<long>(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<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));
+ 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_t>(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<s32>(linger_value);
+ value.l_linger = linger_value;
return value;
}
@@ -339,7 +337,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 = static_cast<s16>(TranslatePollEvents(fd.events));
+ result.events = TranslatePollEvents(fd.events);
result.revents = 0;
return result;
});
@@ -501,12 +499,12 @@ Errno Socket::Shutdown(ShutdownHow how) {
}
}
-std::pair<s32, Errno> Socket::Recv(u32 flags, std::vector<u8>& message) {
+std::pair<s32, Errno> Socket::Recv(int 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<socklen_t>(message.size()), 0);
+ const auto result =
+ recv(fd, reinterpret_cast<char*>(message.data()), static_cast<int>(message.size()), 0);
if (result != SOCKET_ERROR) {
return {static_cast<s32>(result), Errno::SUCCESS};
}
@@ -524,7 +522,7 @@ std::pair<s32, Errno> Socket::Recv(u32 flags, std::vector<u8>& message) {
}
}
-std::pair<s32, Errno> Socket::RecvFrom(u32 flags, std::vector<u8>& message, SockAddrIn* addr) {
+std::pair<s32, Errno> Socket::RecvFrom(int flags, std::vector<u8>& message, SockAddrIn* addr) {
ASSERT(flags == 0);
ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max()));
@@ -534,7 +532,7 @@ std::pair<s32, Errno> Socket::RecvFrom(u32 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<socklen_t>(message.size()), 0, p_addr_in, p_addrlen);
+ static_cast<int>(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<s32, Errno> Socket::RecvFrom(u32 flags, std::vector<u8>& message, Sock
}
}
-std::pair<s32, Errno> Socket::Send(const std::vector<u8>& message, u32 flags) {
+std::pair<s32, Errno> Socket::Send(const std::vector<u8>& message, int 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<socklen_t>(message.size()), 0);
+ static_cast<int>(message.size()), 0);
if (result != SOCKET_ERROR) {
return {static_cast<s32>(result), Errno::SUCCESS};
}
@@ -593,9 +591,8 @@ 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<socklen_t>(message.size()), 0, to, static_cast<socklen_t>(tolen));
+ const auto result = sendto(fd, reinterpret_cast<const char*>(message.data()),
+ static_cast<int>(message.size()), 0, to, 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 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<s32, Errno> Recv(u32 flags, std::vector<u8>& message);
+ std::pair<s32, Errno> Recv(int flags, std::vector<u8>& message);
- std::pair<s32, Errno> RecvFrom(u32 flags, std::vector<u8>& message, SockAddrIn* addr);
+ std::pair<s32, Errno> RecvFrom(int flags, std::vector<u8>& message, SockAddrIn* addr);
- std::pair<s32, Errno> Send(const std::vector<u8>& message, u32 flags);
+ std::pair<s32, Errno> Send(const std::vector<u8>& message, int flags);
std::pair<s32, Errno> SendTo(u32 flags, const std::vector<u8>& message, const SockAddrIn* addr);