diff --git a/libretro-common/include/net/net_compat.h b/libretro-common/include/net/net_compat.h index 35586627ab..1d2def2aeb 100644 --- a/libretro-common/include/net/net_compat.h +++ b/libretro-common/include/net/net_compat.h @@ -52,9 +52,20 @@ #elif defined(_XBOX) #define NOD3D + #include #include +#define socklen_t int + +#ifndef h_addr +#define h_addr h_addr_list[0] /* for backward compatibility */ +#endif + +#ifndef SO_KEEPALIVE +#define SO_KEEPALIVE 0 /* verify if correct */ +#endif + #elif defined(GEKKO) #include @@ -178,6 +189,10 @@ struct SceNetInAddr inet_aton(const char *ip_addr); #include #endif +#ifdef WIIU +#define WIIU_RCVBUF (128 * 2 * 1024) +#define WIIU_SNDBUF (128 * 2 * 1024) +#endif #if defined(__PSL1GHT__) #include @@ -192,8 +207,59 @@ struct SceNetInAddr inet_aton(const char *ip_addr); #endif #endif +#ifndef _WIN32 +#include +#include +#endif + #include +#ifndef MSG_NOSIGNAL +#define MSG_NOSIGNAL 0 +#endif + +#if defined(AF_INET6) && !defined(HAVE_SOCKET_LEGACY) && !defined(_3DS) +#define HAVE_INET6 1 +#endif + +#ifdef NETWORK_HAVE_POLL +#ifdef GEKKO +#define NET_POLL_FD(sockfd, sockfds) (sockfds)->socket = (sockfd) +#else +#define NET_POLL_FD(sockfd, sockfds) (sockfds)->fd = (sockfd) +#endif +#define NET_POLL_EVENT(sockev, sockfds) (sockfds)->events |= (sockev) +#define NET_POLL_HAS_EVENT(sockev, sockfds) ((sockfds)->revents & (sockev)) +#endif + +/* Compatibility layer for legacy or incomplete BSD socket implementations. + * Only for IPv4. Mostly useful for the consoles which do not support + * anything reasonably modern on the socket API side of things. */ +#ifdef HAVE_SOCKET_LEGACY + +#define sockaddr_storage sockaddr_in +#define addrinfo addrinfo_retro__ + +#ifndef AI_PASSIVE +#define AI_PASSIVE 1 +#endif + +struct addrinfo +{ + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + size_t ai_addrlen; + struct sockaddr *ai_addr; + char *ai_canonname; + struct addrinfo *ai_next; +}; + +/* gai_strerror() not used, so we skip that. */ + +#endif + static INLINE bool isagain(int bytes) { #if defined(_WIN32) @@ -224,71 +290,6 @@ static INLINE bool isinprogress(int bytes) #endif } -#ifdef WIIU -#define WIIU_RCVBUF (128 * 2 * 1024) -#define WIIU_SNDBUF (128 * 2 * 1024) -#endif - -#ifdef _XBOX -#define socklen_t int - -#ifndef h_addr -#define h_addr h_addr_list[0] /* for backward compatibility */ -#endif - -#ifndef SO_KEEPALIVE -#define SO_KEEPALIVE 0 /* verify if correct */ -#endif -#endif - -#ifndef MSG_NOSIGNAL -#define MSG_NOSIGNAL 0 -#endif - -#ifndef _WIN32 -#include -#include -#endif - -#ifdef NETWORK_HAVE_POLL -#ifdef GEKKO -#define NET_POLL_FD(sockfd, sockfds) (sockfds)->socket = (sockfd) -#else -#define NET_POLL_FD(sockfd, sockfds) (sockfds)->fd = (sockfd) -#endif -#define NET_POLL_EVENT(sockev, sockfds) (sockfds)->events |= (sockev) -#define NET_POLL_HAS_EVENT(sockev, sockfds) ((sockfds)->revents & (sockev)) -#endif - -/* Compatibility layer for legacy or incomplete BSD socket implementations. - * Only for IPv4. Mostly useful for the consoles which do not support - * anything reasonably modern on the socket API side of things. */ - -#ifdef HAVE_SOCKET_LEGACY - -#define sockaddr_storage sockaddr_in -#define addrinfo addrinfo_retro__ - -struct addrinfo -{ - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - size_t ai_addrlen; - struct sockaddr *ai_addr; - char *ai_canonname; - struct addrinfo *ai_next; -}; - -#ifndef AI_PASSIVE -#define AI_PASSIVE 1 -#endif - -/* gai_strerror() not used, so we skip that. */ - -#endif - uint16_t inet_htons(uint16_t hostshort); int inet_ptrton(int af, const char *src, void *dst); diff --git a/network/natt.c b/network/natt.c index da3302f1e1..870c2a30a8 100644 --- a/network/natt.c +++ b/network/natt.c @@ -30,12 +30,6 @@ #include "natt.h" -#if defined(AF_INET6) && !defined(HAVE_SOCKET_LEGACY) && !defined(_3DS) -#ifndef HAVE_INET6 -#define HAVE_INET6 1 -#endif -#endif - static bool translate_addr(struct sockaddr_in *addr, char *host, size_t hostlen, char *port, size_t portlen) { diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index a6ce81d7aa..b0b397cccb 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -78,12 +78,6 @@ #include "netplay_private.h" -#if defined(AF_INET6) && !defined(HAVE_SOCKET_LEGACY) && !defined(_3DS) -#ifndef HAVE_INET6 -#define HAVE_INET6 1 -#endif -#endif - #ifdef TCP_NODELAY #define SET_TCP_NODELAY(fd) \ { \