mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
Merge pull request #12672 from QuarkTheAwesome/network-fixes
(Wii U) Network speed optimisations
This commit is contained in:
commit
c007a81103
2
.gitignore
vendored
2
.gitignore
vendored
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -264,6 +264,25 @@ void freeaddrinfo_retro(struct addrinfo *res)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(WIIU)
|
||||
#include <malloc.h>
|
||||
|
||||
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)
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user