From 9d992e3d0693d32d6058a73b0dec23e8039fd2a2 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Sat, 11 Sep 2021 23:31:52 +0300 Subject: [PATCH] [Kernel] Rename sin_zero due to #define on Android --- src/xenia/kernel/xam/xam_net.cc | 2 +- src/xenia/kernel/xsocket.cc | 4 +++- src/xenia/kernel/xsocket.h | 9 ++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/xenia/kernel/xam/xam_net.cc b/src/xenia/kernel/xam/xam_net.cc index e9e8e8759..4c5c0ead4 100644 --- a/src/xenia/kernel/xam/xam_net.cc +++ b/src/xenia/kernel/xam/xam_net.cc @@ -950,7 +950,7 @@ dword_result_t NetDll_recvfrom(dword_t caller, dword_t socket_handle, from_ptr->sin_family = native_from.sin_family; from_ptr->sin_port = native_from.sin_port; from_ptr->sin_addr = native_from.sin_addr; - memset(from_ptr->sin_zero, 0, 8); + std::memset(from_ptr->x_sin_zero, 0, sizeof(from_ptr->x_sin_zero)); } if (fromlen_ptr) { *fromlen_ptr = native_fromlen; diff --git a/src/xenia/kernel/xsocket.cc b/src/xenia/kernel/xsocket.cc index ea15734e7..8bbc0375e 100644 --- a/src/xenia/kernel/xsocket.cc +++ b/src/xenia/kernel/xsocket.cc @@ -9,6 +9,8 @@ #include "src/xenia/kernel/xsocket.h" +#include + #include "xenia/base/platform.h" #include "xenia/kernel/kernel_state.h" #include "xenia/kernel/xam/xam_module.h" @@ -200,7 +202,7 @@ int XSocket::RecvFrom(uint8_t* buf, uint32_t buf_len, uint32_t flags, from->sin_family = nfrom.sin_family; from->sin_addr = ntohl(nfrom.sin_addr.s_addr); // BE <- BE from->sin_port = nfrom.sin_port; - memset(&from->sin_zero, 0, 8); + std::memset(from->x_sin_zero, 0, sizeof(from->x_sin_zero)); } if (from_len) { diff --git a/src/xenia/kernel/xsocket.h b/src/xenia/kernel/xsocket.h index 8c5103ec9..f77e2d8eb 100644 --- a/src/xenia/kernel/xsocket.h +++ b/src/xenia/kernel/xsocket.h @@ -10,6 +10,7 @@ #ifndef XENIA_KERNEL_XSOCKET_H_ #define XENIA_KERNEL_XSOCKET_H_ +#include #include #include "xenia/base/byte_order.h" @@ -42,7 +43,8 @@ struct XSOCKADDR_IN { // Always big-endian! xe::be sin_port; xe::be sin_addr; - char sin_zero[8]; + // sin_zero is defined as __pad on Android, so prefixed here. + char x_sin_zero[8]; }; // Xenia native sockaddr_in @@ -53,7 +55,7 @@ struct N_XSOCKADDR_IN { sin_family = other.sin_family; sin_port = other.sin_port; sin_addr = other.sin_addr; - std::memset(sin_zero, 0, 8); + std::memset(x_sin_zero, 0, sizeof(x_sin_zero)); return *this; } @@ -61,7 +63,8 @@ struct N_XSOCKADDR_IN { uint16_t sin_family; xe::be sin_port; xe::be sin_addr; - char sin_zero[8]; + // sin_zero is defined as __pad on Android, so prefixed here. + char x_sin_zero[8]; }; class XSocket : public XObject {