From a85824d853758c64a224f59f464e8a475543ae6e Mon Sep 17 00:00:00 2001 From: Matheus Garcia Date: Wed, 24 Dec 2025 15:58:09 -0300 Subject: [PATCH] FreeBSD --- src/public/minbase/minbase_identify.h | 3 +++ src/public/tier0/platform_sockets.h | 2 +- src/tier0/dbg.cpp | 22 +++++++++++++++++----- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/public/minbase/minbase_identify.h b/src/public/minbase/minbase_identify.h index 98ae16636..2c47e80e6 100644 --- a/src/public/minbase/minbase_identify.h +++ b/src/public/minbase/minbase_identify.h @@ -166,6 +166,9 @@ #elif defined( LINUX ) || defined( __LINUX__ ) || defined(linux) || defined(__linux) || defined(__linux__) #define IsLinux() true #define IsPosix() true +#elif defined(__FreeBSD__) + #define IsFreeBSD() true + #define IsPosix() true #elif defined( _POSIX_VERSION ) || defined( POSIX ) || defined( VALVE_POSIX ) #define IsPosix() true #else diff --git a/src/public/tier0/platform_sockets.h b/src/public/tier0/platform_sockets.h index 5550c8882..51d1fdfda 100644 --- a/src/public/tier0/platform_sockets.h +++ b/src/public/tier0/platform_sockets.h @@ -112,7 +112,7 @@ typedef char SteamNetworkingErrMsg[ 1024 ]; #define PlatformSupportsRecvMsg() true - #ifdef __APPLE__ + #if defined(__APPLE__) || defined(__FreeBSD__) #define USE_POLL // I can't get this to work on MacOS. If someboddy believes that diff --git a/src/tier0/dbg.cpp b/src/tier0/dbg.cpp index dd31cc389..73ed8cbeb 100644 --- a/src/tier0/dbg.cpp +++ b/src/tier0/dbg.cpp @@ -33,8 +33,12 @@ using namespace SteamNetworkingSocketsLib; #include #endif -#if IsOSX() -#include +#if IsOSX() || IsFreeBSD() + #include + #if IsFreeBSD() + #include + #include + #endif #endif #if IsPlaystation() && defined(_DEBUG) @@ -45,7 +49,7 @@ bool Plat_IsInDebugSession() { #ifdef _WIN32 return (IsDebuggerPresent() != 0); -#elif IsOSX() +#elif IsOSX() || IsFreeBSD() int mib[4]; struct kinfo_proc info; size_t size; @@ -54,9 +58,17 @@ bool Plat_IsInDebugSession() mib[2] = KERN_PROC_PID; mib[3] = getpid(); size = sizeof(info); - info.kp_proc.p_flag = 0; +#if IsFreeBSD() + info.ki_paddr->p_flag = 0; +#else + info.kp_proc.flag = 0; +#endif sysctl(mib,4,&info,&size,NULL,0); - return ((info.kp_proc.p_flag & P_TRACED) == P_TRACED); +#if IsFreeBSD() + return ((info.ki_paddr->p_flag & P_TRACED) == P_TRACED); +#else + return ((info.kp_proc.flag & P_TRACED) == P_TRACED); +#endif #elif IsLinux() static FILE *fp; if ( !fp )