Add OpenBSD support

This commit is contained in:
Brad Smith
2026-04-16 01:22:56 -04:00
committed by Fletcher Dunn
parent 7a217b74c6
commit a7a0291666
9 changed files with 28 additions and 4 deletions
+2
View File
@@ -163,6 +163,8 @@ function(set_target_common_gns_properties TGT)
target_compile_definitions(${TGT} PUBLIC OSX)
elseif(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
target_compile_definitions(${TGT} PUBLIC FREEBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES OpenBSD)
target_compile_definitions(${TGT} PUBLIC OPENBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES Windows)
target_compile_definitions(${TGT} PUBLIC _WINDOWS)
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
+1 -1
View File
@@ -1157,7 +1157,7 @@ enum ESteamIPv6ConnectivityState
// Define compile time assert macros to let us validate the structure sizes.
#define VALVE_COMPILE_TIME_ASSERT( pred ) typedef char compile_time_assert_type[(pred) ? 1 : -1];
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
// The 32-bit version of gcc has the alignment requirement for uint64 and double set to
// 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
// The 64-bit version of gcc has the alignment requirement for these types set to
+2
View File
@@ -313,6 +313,8 @@ macro(set_clientlib_target_properties GNS_TARGET)
#endif()
elseif(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES OpenBSD)
elseif(CMAKE_SYSTEM_NAME MATCHES Windows)
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
get_target_property(TARGET_TYPE ${GNS_TARGET} TYPE)
+6
View File
@@ -169,6 +169,9 @@
#elif defined(__FreeBSD__)
#define IsFreeBSD() true
#define IsPosix() true
#elif defined(__OpenBSD__)
#define IsOpenBSD() true
#define IsPosix() true
#elif defined( _POSIX_VERSION ) || defined( POSIX ) || defined( VALVE_POSIX )
#define IsPosix() true
#else
@@ -235,6 +238,9 @@
#ifndef IsFreeBSD
#define IsFreeBSD() false
#endif
#ifndef IsOpenBSD
#define IsOpenBSD() false
#endif
// Detect ARM
#ifndef IsARM
+1 -1
View File
@@ -75,7 +75,7 @@ typedef uint32 uint32_t;
// NOTE: int64_t must match the compiler stdint.h definition
// and so may not match the Steam int64. Mixing the two is
// error-prone so always use the Steam non-_t types in Steam code.
#if defined(COMPILER_GCC) && defined(PLATFORM_64BITS) && !defined(__MINGW32__) && !IsOSX() && !(defined(IOS) || defined(TVOS))
#if defined(COMPILER_GCC) && defined(PLATFORM_64BITS) && !defined(__MINGW32__) && !IsOSX() && !IsIOS() && !IsTVOS() && !IsOpenBSD()
#define INT64_DIFFERENT_FROM_INT64_T 1
typedef long int int64_t;
typedef unsigned long int uint64_t;
+8
View File
@@ -145,6 +145,14 @@ typedef char SteamNetworkingErrMsg[ 1024 ];
// Does this work? If somebody who uses FreeBSD
// wants to test, I would appreciate it!
#define PlatformSupportsRecvTOS() false
#elif defined(__OpenBSD__)
// OpenBSD provides kqueue, but we don't support it, so just use old-school poll()
#define USE_POLL
// Does this work? If somebody who uses OpenBSD
// wants to test, I would appreciate it!
#define PlatformSupportsRecvTOS() false
#else
#define USE_EPOLL
#include <sys/epoll.h>
@@ -2454,8 +2454,10 @@ const char *CSteamNetworkingUtils::GetPlatformString()
return "windows";
#elif IsLinux()
return "linux";
#elif defined( FREEBSD ) || defined( __FreeBSD__ )
#elif IsFreeBSD()
return "freebsd";
#elif IsOpenBSD()
return "openbsd";
#else
#error "Unknown platform"
#endif
@@ -4369,7 +4369,11 @@ bool ResolveHostname( const char* pszHostname, CUtlVector< SteamNetworkingIPAddr
addrinfo hints;
V_memset( &hints, 0, sizeof( hints ) );
#ifdef AI_V4MAPPED
hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG;
#else
hints.ai_flags = AI_ADDRCONFIG;
#endif
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = 0;
hints.ai_protocol = 0;
+1 -1
View File
@@ -86,7 +86,7 @@ bool Plat_IsInDebugSession()
return (nTracePid != 0);
#elif IsPlaystation()
// NDA material
#elif IsNintendoSwitch()
#elif IsNintendoSwitch() || IsOpenBSD()
return false;
#else
#error "HALP"