156 lines
4.8 KiB
Diff
156 lines
4.8 KiB
Diff
From 49d1ca61e6249c3bc3284a6b55578b4ddd7b13ac Mon Sep 17 00:00:00 2001
|
|
From: Oskari Alaranta <oskari.alaranta@bananymous.com>
|
|
Date: Tue, 13 Jan 2026 20:49:19 +0200
|
|
Subject: [PATCH] add support for banan-os
|
|
|
|
---
|
|
engine/common/net_http.c | 4 +++-
|
|
engine/common/net_ws.c | 6 ++++++
|
|
engine/common/whereami.c | 2 +-
|
|
engine/platform/posix/net.h | 4 ++++
|
|
public/build.c | 2 ++
|
|
public/build.h | 3 +++
|
|
public/buildenums.h | 3 +++
|
|
7 files changed, 22 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/engine/common/net_http.c b/engine/common/net_http.c
|
|
index ff6fd41b..ebb5bbad 100644
|
|
--- a/engine/common/net_http.c
|
|
+++ b/engine/common/net_http.c
|
|
@@ -261,14 +261,16 @@ static int HTTP_FileCreateSocket( httpfile_t *file )
|
|
return 0;
|
|
}
|
|
|
|
+#if !XASH_BANAN_OS
|
|
if( ioctlsocket( file->socket, FIONBIO, (void *)&mode ) < 0 )
|
|
{
|
|
Con_Printf( S_ERROR "%s: ioctl() returned %s\n", __func__, NET_ErrorString());
|
|
HTTP_FreeFile( file, true );
|
|
return 0;
|
|
}
|
|
+#endif
|
|
|
|
-#if XASH_LINUX
|
|
+#if XASH_LINUX || XASH_BANAN_OS
|
|
|
|
res = fcntl( file->socket, F_GETFL, 0 );
|
|
|
|
diff --git a/engine/common/net_ws.c b/engine/common/net_ws.c
|
|
index 7ee4cba0..b44d5cf1 100644
|
|
--- a/engine/common/net_ws.c
|
|
+++ b/engine/common/net_ws.c
|
|
@@ -1617,7 +1617,11 @@ static int NET_IPSocket( const char *net_iface, int port, int family )
|
|
if( family == AF_INET6 )
|
|
pfamily = PF_INET6;
|
|
|
|
+#ifdef SOCK_NONBLOCK
|
|
+ if( NET_IsSocketError(( net_socket = socket( pfamily, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP ))))
|
|
+#else
|
|
if( NET_IsSocketError(( net_socket = socket( pfamily, SOCK_DGRAM, IPPROTO_UDP ))))
|
|
+#endif
|
|
{
|
|
err = WSAGetLastError();
|
|
if( err != WSAEAFNOSUPPORT )
|
|
@@ -1625,6 +1629,7 @@ static int NET_IPSocket( const char *net_iface, int port, int family )
|
|
return INVALID_SOCKET;
|
|
}
|
|
|
|
+#ifndef SOCK_NONBLOCK
|
|
if( NET_IsSocketError( ioctlsocket( net_socket, FIONBIO, (void*)&_true )))
|
|
{
|
|
struct timeval timeout;
|
|
@@ -1634,6 +1639,7 @@ static int NET_IPSocket( const char *net_iface, int port, int family )
|
|
timeout.tv_sec = timeout.tv_usec = 0;
|
|
setsockopt( net_socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout));
|
|
}
|
|
+#endif
|
|
|
|
// make it broadcast capable
|
|
if( NET_IsSocketError( setsockopt( net_socket, SOL_SOCKET, SO_BROADCAST, (char *)&_true, sizeof( _true ))))
|
|
diff --git a/engine/common/whereami.c b/engine/common/whereami.c
|
|
index 31726774..69a6cb9f 100644
|
|
--- a/engine/common/whereami.c
|
|
+++ b/engine/common/whereami.c
|
|
@@ -175,7 +175,7 @@ int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
|
|
return length;
|
|
}
|
|
|
|
-#elif defined(__linux__) || defined(__CYGWIN__) || defined(__sun) || defined(__serenity__) || defined(WAI_USE_PROC_SELF_EXE)
|
|
+#elif defined(__linux__) || defined(__CYGWIN__) || defined(__sun) || defined(__serenity__) || defined(__banan_os__) || defined(WAI_USE_PROC_SELF_EXE)
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
diff --git a/engine/platform/posix/net.h b/engine/platform/posix/net.h
|
|
index 58532927..6ab3cd1f 100644
|
|
--- a/engine/platform/posix/net.h
|
|
+++ b/engine/platform/posix/net.h
|
|
@@ -90,6 +90,10 @@ static int ioctl_stub( int d, unsigned long r, ... )
|
|
#define closesocket close
|
|
#endif
|
|
#define SOCKET int
|
|
+#if XASH_BANAN_OS
|
|
+typedef socklen_t WSAsize_t;
|
|
+#else
|
|
typedef int WSAsize_t;
|
|
+#endif
|
|
|
|
#endif // NET_H
|
|
diff --git a/public/build.c b/public/build.c
|
|
index 6c85bbaf..460b4040 100644
|
|
--- a/public/build.c
|
|
+++ b/public/build.c
|
|
@@ -151,6 +151,8 @@ const char *Q_PlatformStringByID( const int platform )
|
|
return "wasi";
|
|
case PLATFORM_SUNOS:
|
|
return "sunos";
|
|
+ case PLATFORM_BANAN_OS:
|
|
+ return "banan-os";
|
|
}
|
|
|
|
assert( 0 );
|
|
diff --git a/public/build.h b/public/build.h
|
|
index 3fdfeded..2752f8bd 100644
|
|
--- a/public/build.h
|
|
+++ b/public/build.h
|
|
@@ -82,6 +82,7 @@ Then you can use another oneliner to query all variables:
|
|
#undef XASH_RISCV_SOFTFP
|
|
#undef XASH_SERENITY
|
|
#undef XASH_SUNOS
|
|
+#undef XASH_BANAN_OS
|
|
#undef XASH_TERMUX
|
|
#undef XASH_WIN32
|
|
#undef XASH_X86
|
|
@@ -135,6 +136,8 @@ Then you can use another oneliner to query all variables:
|
|
#define XASH_WASI 1
|
|
#elif defined __sun__
|
|
#define XASH_SUNOS 1
|
|
+ #elif defined __banan_os__
|
|
+ #define XASH_BANAN_OS 1
|
|
#elif defined __EMSCRIPTEN__
|
|
#define XASH_EMSCRIPTEN 1
|
|
#else
|
|
diff --git a/public/buildenums.h b/public/buildenums.h
|
|
index 4dc327d3..57585f73 100644
|
|
--- a/public/buildenums.h
|
|
+++ b/public/buildenums.h
|
|
@@ -43,6 +43,7 @@ GNU General Public License for more details.
|
|
#define PLATFORM_PSVITA 14
|
|
#define PLATFORM_WASI 15
|
|
#define PLATFORM_SUNOS 16
|
|
+#define PLATFORM_BANAN_OS 17
|
|
|
|
#if XASH_WIN32
|
|
#define XASH_PLATFORM PLATFORM_WIN32
|
|
@@ -76,6 +77,8 @@ GNU General Public License for more details.
|
|
#define XASH_PLATFORM PLATFORM_WASI
|
|
#elif XASH_SUNOS
|
|
#define XASH_PLATFORM PLATFORM_SUNOS
|
|
+#elif XASH_BANAN_OS
|
|
+ #define XASH_PLATFORM PLATFORM_BANAN_OS
|
|
#else
|
|
#error
|
|
#endif
|
|
--
|
|
2.52.0
|
|
|