diff --git a/CMakeLists.txt b/CMakeLists.txt index a69b7a40..763bb0fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/include/steam/steamclientpublic.h b/include/steam/steamclientpublic.h index 2bd66253..f3d6ca79 100644 --- a/include/steam/steamclientpublic.h +++ b/include/steam/steamclientpublic.h @@ -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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 26e09994..b9c3fde2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -310,6 +310,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) diff --git a/src/public/minbase/minbase_identify.h b/src/public/minbase/minbase_identify.h index 4cdf0249..8c9f9c59 100644 --- a/src/public/minbase/minbase_identify.h +++ b/src/public/minbase/minbase_identify.h @@ -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 diff --git a/src/public/minbase/minbase_types.h b/src/public/minbase/minbase_types.h index 0f35c5a0..27c9dc7b 100644 --- a/src/public/minbase/minbase_types.h +++ b/src/public/minbase/minbase_types.h @@ -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; diff --git a/src/public/tier0/platform_sockets.h b/src/public/tier0/platform_sockets.h index 1d33955f..917bf171 100644 --- a/src/public/tier0/platform_sockets.h +++ b/src/public/tier0/platform_sockets.h @@ -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 diff --git a/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp b/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp index a2645465..2558e43f 100644 --- a/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp +++ b/src/steamnetworkingsockets/clientlib/csteamnetworkingsockets.cpp @@ -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 diff --git a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_lowlevel.cpp b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_lowlevel.cpp index 0011cd84..d535e58a 100644 --- a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_lowlevel.cpp +++ b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_lowlevel.cpp @@ -4289,7 +4289,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; diff --git a/src/tier0/dbg.cpp b/src/tier0/dbg.cpp index dd31cc38..9038e235 100644 --- a/src/tier0/dbg.cpp +++ b/src/tier0/dbg.cpp @@ -86,7 +86,7 @@ bool Plat_IsInDebugSession() return (nTracePid != 0); #elif IsPlaystation() // NDA material -#elif IsNintendoSwitch() +#elif IsNintendoSwitch() || IsOpenBSD() return false; #else #error "HALP"