From f2090df7a50710699a8abc1356ed65de36feda68 Mon Sep 17 00:00:00 2001 From: castano Date: Sat, 21 Mar 2009 07:44:26 +0000 Subject: [PATCH] Add support for FreeBSD. Patch by AMDmi3. --- src/nvcore/Debug.cpp | 10 +++++++++- src/nvcore/nvcore.h | 5 ++++- src/nvmath/nvmath.h | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/nvcore/Debug.cpp b/src/nvcore/Debug.cpp index a3715a7..d7b201d 100644 --- a/src/nvcore/Debug.cpp +++ b/src/nvcore/Debug.cpp @@ -34,7 +34,7 @@ # endif #endif -#if NV_OS_DARWIN +#if NV_OS_DARWIN || NV_OS_FREEBSD # include // getpid # include # include // sysctl @@ -199,6 +199,14 @@ namespace return (void *) ucp->uc_mcontext->ss.eip; # endif # endif +# elif NV_OS_FREEBSD +# if NV_CPU_X86_64 + ucontext_t * ucp = (ucontext_t *)secret; + return (void *)ucp->uc_mcontext.mc_rip; +# elif NV_CPU_X86 + ucontext_t * ucp = (ucontext_t *)secret; + return (void *)ucp->uc_mcontext.mc_eip; +# endif # else # if NV_CPU_X86_64 // #define REG_RIP REG_INDEX(rip) // seems to be 16 diff --git a/src/nvcore/nvcore.h b/src/nvcore/nvcore.h index 991a8be..a91624b 100644 --- a/src/nvcore/nvcore.h +++ b/src/nvcore/nvcore.h @@ -38,6 +38,9 @@ #if defined POSH_OS_LINUX # define NV_OS_LINUX 1 # define NV_OS_UNIX 1 +#elif defined POSH_OS_FREEBSD +# define NV_OS_FREEBSD 1 +# define NV_OS_UNIX 1 #elif defined POSH_OS_CYGWIN32 # define NV_OS_CYGWIN 1 #elif defined POSH_OS_MINGW @@ -161,7 +164,7 @@ #elif NV_CC_GNUC # if NV_OS_LINUX # include "DefsGnucLinux.h" -# elif NV_OS_DARWIN +# elif NV_OS_DARWIN || NV_OS_FREEBSD # include "DefsGnucDarwin.h" # elif NV_OS_MINGW # include "DefsGnucWin32.h" diff --git a/src/nvmath/nvmath.h b/src/nvmath/nvmath.h index 0318d4e..bedf132 100644 --- a/src/nvmath/nvmath.h +++ b/src/nvmath/nvmath.h @@ -115,7 +115,7 @@ inline bool isFinite(const float f) { #if NV_OS_WIN32 return _finite(f) != 0; -#elif NV_OS_DARWIN +#elif NV_OS_DARWIN || NV_OS_FREEBSD return isfinite(f); #elif NV_OS_LINUX return finitef(f); @@ -130,7 +130,7 @@ inline bool isNan(const float f) { #if NV_OS_WIN32 return _isnan(f) != 0; -#elif NV_OS_DARWIN +#elif NV_OS_DARWIN || NV_OS_FREEBSD return isnan(f); #elif NV_OS_LINUX return isnanf(f);