Compare commits

..

1 Commits

Author SHA1 Message Date
1374149fa5 Android #42 2023-08-17 00:57:12 +00:00
5 changed files with 8 additions and 37 deletions

View File

@ -134,7 +134,7 @@ else()
endif()
# GCC bugs
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "12" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# These diagnostics would be great if they worked, but are just completely broken
# and produce bogus errors on external libraries like fmt.
add_compile_options(

View File

@ -18,9 +18,7 @@ enum class Errno : u32 {
AGAIN = 11,
INVAL = 22,
MFILE = 24,
PIPE = 32,
MSGSIZE = 90,
CONNABORTED = 103,
CONNRESET = 104,
NOTCONN = 107,
TIMEDOUT = 110,

View File

@ -23,14 +23,10 @@ Errno Translate(Network::Errno value) {
return Errno::INVAL;
case Network::Errno::MFILE:
return Errno::MFILE;
case Network::Errno::PIPE:
return Errno::PIPE;
case Network::Errno::NOTCONN:
return Errno::NOTCONN;
case Network::Errno::TIMEDOUT:
return Errno::TIMEDOUT;
case Network::Errno::CONNABORTED:
return Errno::CONNABORTED;
case Network::Errno::CONNRESET:
return Errno::CONNRESET;
case Network::Errno::INPROGRESS:

View File

@ -39,11 +39,6 @@ namespace Network {
namespace {
enum class CallType {
Send,
Other,
};
#ifdef _WIN32
using socklen_t = int;
@ -101,7 +96,7 @@ bool EnableNonBlock(SOCKET fd, bool enable) {
return ioctlsocket(fd, FIONBIO, &value) != SOCKET_ERROR;
}
Errno TranslateNativeError(int e, CallType call_type = CallType::Other) {
Errno TranslateNativeError(int e) {
switch (e) {
case 0:
return Errno::SUCCESS;
@ -117,14 +112,6 @@ Errno TranslateNativeError(int e, CallType call_type = CallType::Other) {
return Errno::AGAIN;
case WSAECONNREFUSED:
return Errno::CONNREFUSED;
case WSAECONNABORTED:
if (call_type == CallType::Send) {
// Winsock yields WSAECONNABORTED from `send` in situations where Unix
// systems, and actual Switches, yield EPIPE.
return Errno::PIPE;
} else {
return Errno::CONNABORTED;
}
case WSAECONNRESET:
return Errno::CONNRESET;
case WSAEHOSTUNREACH:
@ -211,7 +198,7 @@ bool EnableNonBlock(int fd, bool enable) {
return fcntl(fd, F_SETFL, flags) == 0;
}
Errno TranslateNativeError(int e, CallType call_type = CallType::Other) {
Errno TranslateNativeError(int e) {
switch (e) {
case 0:
return Errno::SUCCESS;
@ -221,10 +208,6 @@ Errno TranslateNativeError(int e, CallType call_type = CallType::Other) {
return Errno::INVAL;
case EMFILE:
return Errno::MFILE;
case EPIPE:
return Errno::PIPE;
case ECONNABORTED:
return Errno::CONNABORTED;
case ENOTCONN:
return Errno::NOTCONN;
case EAGAIN:
@ -253,13 +236,13 @@ Errno TranslateNativeError(int e, CallType call_type = CallType::Other) {
#endif
Errno GetAndLogLastError(CallType call_type = CallType::Other) {
Errno GetAndLogLastError() {
#ifdef _WIN32
int e = WSAGetLastError();
#else
int e = errno;
#endif
const Errno err = TranslateNativeError(e, call_type);
const Errno err = TranslateNativeError(e);
if (err == Errno::AGAIN || err == Errno::TIMEDOUT || err == Errno::INPROGRESS) {
// These happen during normal operation, so only log them at debug level.
LOG_DEBUG(Network, "Socket operation error: {}", Common::NativeErrorToString(e));
@ -748,17 +731,13 @@ std::pair<s32, Errno> Socket::Send(std::span<const u8> message, int flags) {
ASSERT(message.size() < static_cast<size_t>(std::numeric_limits<int>::max()));
ASSERT(flags == 0);
int native_flags = 0;
#if YUZU_UNIX
native_flags |= MSG_NOSIGNAL; // do not send us SIGPIPE
#endif
const auto result = send(fd, reinterpret_cast<const char*>(message.data()),
static_cast<int>(message.size()), native_flags);
static_cast<int>(message.size()), 0);
if (result != SOCKET_ERROR) {
return {static_cast<s32>(result), Errno::SUCCESS};
}
return {-1, GetAndLogLastError(CallType::Send)};
return {-1, GetAndLogLastError()};
}
std::pair<s32, Errno> Socket::SendTo(u32 flags, std::span<const u8> message,
@ -780,7 +759,7 @@ std::pair<s32, Errno> Socket::SendTo(u32 flags, std::span<const u8> message,
return {static_cast<s32>(result), Errno::SUCCESS};
}
return {-1, GetAndLogLastError(CallType::Send)};
return {-1, GetAndLogLastError()};
}
Errno Socket::Close() {

View File

@ -33,12 +33,10 @@ enum class Errno {
BADF,
INVAL,
MFILE,
PIPE,
NOTCONN,
AGAIN,
CONNREFUSED,
CONNRESET,
CONNABORTED,
HOSTUNREACH,
NETDOWN,
NETUNREACH,