From caeaf6146928dba6048a323e9eada9a7c4012045 Mon Sep 17 00:00:00 2001 From: GaryOderNichts <12049776+GaryOderNichts@users.noreply.github.com> Date: Sun, 18 Feb 2024 15:55:54 +0100 Subject: [PATCH] Implement support for userbuffers on Wii U The Wii U socket implementation has limited memory available. To support larger receive buffers, application memory needs to be provided. To make sockets use this user memory the `SO_RUSRBUF` option needs to be set on the socket. --- include/enet/enet.h | 6 +++++- unix.c | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/enet/enet.h b/include/enet/enet.h index fd48edd5..791e3033 100644 --- a/include/enet/enet.h +++ b/include/enet/enet.h @@ -200,7 +200,11 @@ typedef enum _ENetPeerState enum { -#ifdef __3DS__ +#if defined(__WIIU__) + ENET_HOST_RECEIVE_BUFFER_SIZE = 256 * 1024, + // Send buffer size is limited since it cannot use userbuffers + ENET_HOST_SEND_BUFFER_SIZE = 0x10000 - 1, +#elif defined(__3DS__) ENET_HOST_RECEIVE_BUFFER_SIZE = 0x20000, ENET_HOST_SEND_BUFFER_SIZE = 0x20000, #else diff --git a/unix.c b/unix.c index eb1538b1..e27a51f5 100644 --- a/unix.c +++ b/unix.c @@ -393,6 +393,14 @@ enet_socket_create (int af, ENetSocketType type) } #endif +#ifdef __WIIU__ + { + // Enable usage of userbuffers on Wii U + int on = 1; + setsockopt(sock, SOL_SOCKET, SO_RUSRBUF, (char *)&on, sizeof(on)); + } +#endif + return sock; }