Skip to content

Commit a7a0291

Browse files
brad0zpostfacto
authored andcommitted
Add OpenBSD support
1 parent 7a217b7 commit a7a0291

9 files changed

Lines changed: 28 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ function(set_target_common_gns_properties TGT)
163163
target_compile_definitions(${TGT} PUBLIC OSX)
164164
elseif(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
165165
target_compile_definitions(${TGT} PUBLIC FREEBSD)
166+
elseif(CMAKE_SYSTEM_NAME MATCHES OpenBSD)
167+
target_compile_definitions(${TGT} PUBLIC OPENBSD)
166168
elseif(CMAKE_SYSTEM_NAME MATCHES Windows)
167169
target_compile_definitions(${TGT} PUBLIC _WINDOWS)
168170
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")

include/steam/steamclientpublic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ enum ESteamIPv6ConnectivityState
11571157
// Define compile time assert macros to let us validate the structure sizes.
11581158
#define VALVE_COMPILE_TIME_ASSERT( pred ) typedef char compile_time_assert_type[(pred) ? 1 : -1];
11591159

1160-
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
1160+
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__)
11611161
// The 32-bit version of gcc has the alignment requirement for uint64 and double set to
11621162
// 4 meaning that even with #pragma pack(8) these types will only be four-byte aligned.
11631163
// The 64-bit version of gcc has the alignment requirement for these types set to

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ macro(set_clientlib_target_properties GNS_TARGET)
313313
#endif()
314314
elseif(CMAKE_SYSTEM_NAME MATCHES FreeBSD)
315315

316+
elseif(CMAKE_SYSTEM_NAME MATCHES OpenBSD)
317+
316318
elseif(CMAKE_SYSTEM_NAME MATCHES Windows)
317319
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
318320
get_target_property(TARGET_TYPE ${GNS_TARGET} TYPE)

src/public/minbase/minbase_identify.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@
169169
#elif defined(__FreeBSD__)
170170
#define IsFreeBSD() true
171171
#define IsPosix() true
172+
#elif defined(__OpenBSD__)
173+
#define IsOpenBSD() true
174+
#define IsPosix() true
172175
#elif defined( _POSIX_VERSION ) || defined( POSIX ) || defined( VALVE_POSIX )
173176
#define IsPosix() true
174177
#else
@@ -235,6 +238,9 @@
235238
#ifndef IsFreeBSD
236239
#define IsFreeBSD() false
237240
#endif
241+
#ifndef IsOpenBSD
242+
#define IsOpenBSD() false
243+
#endif
238244

239245
// Detect ARM
240246
#ifndef IsARM

src/public/minbase/minbase_types.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ typedef uint32 uint32_t;
7575
// NOTE: int64_t must match the compiler stdint.h definition
7676
// and so may not match the Steam int64. Mixing the two is
7777
// error-prone so always use the Steam non-_t types in Steam code.
78-
#if defined(COMPILER_GCC) && defined(PLATFORM_64BITS) && !defined(__MINGW32__) && !IsOSX() && !(defined(IOS) || defined(TVOS))
78+
#if defined(COMPILER_GCC) && defined(PLATFORM_64BITS) && !defined(__MINGW32__) && !IsOSX() && !IsIOS() && !IsTVOS() && !IsOpenBSD()
7979
#define INT64_DIFFERENT_FROM_INT64_T 1
8080
typedef long int int64_t;
8181
typedef unsigned long int uint64_t;

src/public/tier0/platform_sockets.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ typedef char SteamNetworkingErrMsg[ 1024 ];
145145
// Does this work? If somebody who uses FreeBSD
146146
// wants to test, I would appreciate it!
147147
#define PlatformSupportsRecvTOS() false
148+
#elif defined(__OpenBSD__)
149+
150+
// OpenBSD provides kqueue, but we don't support it, so just use old-school poll()
151+
#define USE_POLL
152+
153+
// Does this work? If somebody who uses OpenBSD
154+
// wants to test, I would appreciate it!
155+
#define PlatformSupportsRecvTOS() false
148156
#else
149157
#define USE_EPOLL
150158
#include <sys/epoll.h>

src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2454,8 +2454,10 @@ const char *CSteamNetworkingUtils::GetPlatformString()
24542454
return "windows";
24552455
#elif IsLinux()
24562456
return "linux";
2457-
#elif defined( FREEBSD ) || defined( __FreeBSD__ )
2457+
#elif IsFreeBSD()
24582458
return "freebsd";
2459+
#elif IsOpenBSD()
2460+
return "openbsd";
24592461
#else
24602462
#error "Unknown platform"
24612463
#endif

src/steamnetworkingsockets/clientlib/steamnetworkingsockets_lowlevel.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4369,7 +4369,11 @@ bool ResolveHostname( const char* pszHostname, CUtlVector< SteamNetworkingIPAddr
43694369

43704370
addrinfo hints;
43714371
V_memset( &hints, 0, sizeof( hints ) );
4372+
#ifdef AI_V4MAPPED
43724373
hints.ai_flags = AI_V4MAPPED | AI_ADDRCONFIG;
4374+
#else
4375+
hints.ai_flags = AI_ADDRCONFIG;
4376+
#endif
43734377
hints.ai_family = AF_UNSPEC;
43744378
hints.ai_socktype = 0;
43754379
hints.ai_protocol = 0;

src/tier0/dbg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ bool Plat_IsInDebugSession()
8686
return (nTracePid != 0);
8787
#elif IsPlaystation()
8888
// NDA material
89-
#elif IsNintendoSwitch()
89+
#elif IsNintendoSwitch() || IsOpenBSD()
9090
return false;
9191
#else
9292
#error "HALP"

0 commit comments

Comments
 (0)