diff --git a/.gitignore b/.gitignore index cec9e0c4fd..485e7b46fe 100644 --- a/.gitignore +++ b/.gitignore @@ -94,7 +94,6 @@ database overlays playlists states -system shaders/shaders_cg shaders/shaders_glsl shaders/shaders_slang @@ -220,7 +219,6 @@ libretro-common/samples/streams/rzip/rzip #VITA param.sfo -*.S *.wo *.elf *.self diff --git a/libretro-common/include/net/net_compat.h b/libretro-common/include/net/net_compat.h index 7f9f452e64..7387596eb8 100644 --- a/libretro-common/include/net/net_compat.h +++ b/libretro-common/include/net/net_compat.h @@ -158,6 +158,11 @@ static INLINE bool isagain(int bytes) #endif } +#ifdef WIIU +#define WIIU_RCVBUF (128 * 2 * 1024) +#define WIIU_SNDBUF (128 * 2 * 1024) +#endif + #ifdef _XBOX #define socklen_t int diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index aacbb4dd3e..8b9e183e46 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -264,6 +264,25 @@ void freeaddrinfo_retro(struct addrinfo *res) #endif } +#if defined(WIIU) +#include + +static OSThread wiiu_net_cmpt_thread; +static void wiiu_net_cmpt_thread_cleanup(OSThread *thread, void *stack) { + free(stack); +} +static int wiiu_net_cmpt_thread_entry(int argc, const char** argv) { + const int buf_size = WIIU_RCVBUF + WIIU_SNDBUF; + void* buf = memalign(128, buf_size); + if (!buf) return -1; + + somemopt(1, buf, buf_size, 0); + + free(buf); + return 0; +} +#endif + /** * network_init: * @@ -332,6 +351,18 @@ bool network_init(void) return false; #elif defined(WIIU) socket_lib_init(); + + const int stack_size = 4096; + void* stack = malloc(stack_size); + if (stack && OSCreateThread(&wiiu_net_cmpt_thread, + wiiu_net_cmpt_thread_entry, 0, NULL, stack+stack_size, stack_size, + 3, OS_THREAD_ATTRIB_AFFINITY_ANY)) { + + OSSetThreadName(&wiiu_net_cmpt_thread, "Network compat thread"); + OSSetThreadDeallocator(&wiiu_net_cmpt_thread, + wiiu_net_cmpt_thread_cleanup); + OSResumeThread(&wiiu_net_cmpt_thread); + } #elif defined(_3DS) _net_compat_net_memory = (u32*)memalign(SOC_ALIGN, SOC_BUFFERSIZE); if (!_net_compat_net_memory) diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index f33d284075..04b01ade4c 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -256,6 +256,20 @@ int socket_connect(int fd, void *data, bool timeout_enable) setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof timeout); } +#endif +#if defined(WIIU) + int op = 1; + setsockopt(fd, SOL_SOCKET, SO_WINSCALE, &op, sizeof(op)); + if (addr->ai_socktype == SOCK_STREAM) { + setsockopt(fd, SOL_SOCKET, SO_TCPSACK, &op, sizeof(op)); + + setsockopt(fd, SOL_SOCKET, 0x10000, &op, sizeof(op)); + int recvsz = WIIU_RCVBUF; + setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &recvsz, sizeof(recvsz)); + int sendsz = WIIU_SNDBUF; + setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &sendsz, sizeof(sendsz)); + } + #endif return connect(fd, addr->ai_addr, addr->ai_addrlen); diff --git a/wiiu/include/sys/socket.h b/wiiu/include/sys/socket.h index 24eabff7f1..45b2ea9bdc 100644 --- a/wiiu/include/sys/socket.h +++ b/wiiu/include/sys/socket.h @@ -21,6 +21,10 @@ extern "C" { /* #define MSG_DONTWAIT 0x0004 */ #define SO_REUSEADDR 0x0004 +#define SO_WINSCALE 0x0400 +#define SO_TCPSACK 0x0200 +#define SO_SNDBUF 0x1001 +#define SO_RCVBUF 0x1002 #define SO_NBIO 0x1014 #define SO_NONBLOCK 0x1016 @@ -70,6 +74,7 @@ int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t int shutdown(int sockfd, int how); int socket(int domain, int type, int protocol); int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); +int somemopt (int req_type, char* mem, unsigned int memlen, int flags); int socketlasterr(void); diff --git a/wiiu/include/wiiu/os/thread.h b/wiiu/include/wiiu/os/thread.h index b962b1acc5..a545185c60 100644 --- a/wiiu/include/wiiu/os/thread.h +++ b/wiiu/include/wiiu/os/thread.h @@ -133,7 +133,7 @@ typedef struct #define OS_THREAD_TAG 0x74487244u #pragma pack(push, 1) -typedef struct OSThread +typedef struct __attribute__ ((aligned (8))) OSThread { OSContext context; diff --git a/wiiu/system/imports.h b/wiiu/system/imports.h index e3685aaa1a..bfff0e860c 100644 --- a/wiiu/system/imports.h +++ b/wiiu/system/imports.h @@ -32,6 +32,7 @@ IMPORT(OSIsThreadTerminated); IMPORT(OSSetThreadPriority); IMPORT(OSCreateThread); IMPORT(OSSetThreadCleanupCallback); +IMPORT(OSSetThreadDeallocator); IMPORT(OSResumeThread); IMPORT(OSIsThreadSuspended); IMPORT(OSSuspendThread); @@ -39,6 +40,7 @@ IMPORT(OSGetCurrentThread); IMPORT(OSExitThread); IMPORT(OSJoinThread); IMPORT(OSYieldThread); +IMPORT(OSSetThreadName); IMPORT(OSGetCoreId); IMPORT(OSIsMainCore); IMPORT(OSGetSystemTime); @@ -153,6 +155,12 @@ IMPORT(socketlasterr); IMPORT_END(); +IMPORT_BEGIN(nn_nets2); + +IMPORT(somemopt); + +IMPORT_END(); + /* gx2 */ IMPORT_BEGIN(gx2);