From 1b306f66bcd15e9bf6b27882e2daa6375ac4cd2e Mon Sep 17 00:00:00 2001 From: Yuri Date: Wed, 14 Nov 2018 22:15:09 -0800 Subject: [PATCH] FreeBSD compatibility patch --- SimTKcommon/src/ParallelExecutor.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/SimTKcommon/src/ParallelExecutor.cpp b/SimTKcommon/src/ParallelExecutor.cpp index 311712d32..fbd95cbcb 100644 --- a/SimTKcommon/src/ParallelExecutor.cpp +++ b/SimTKcommon/src/ParallelExecutor.cpp @@ -29,6 +29,11 @@ #include #include +#if defined(__FreeBSD__) +#include +#include +#endif + using namespace std; namespace SimTK { @@ -187,6 +192,9 @@ void ParallelExecutor::execute(Task& task, int times) { #elif __linux__ #include #include +#elif __FreeBSD__ + #include + #include #else #error "Architecture unsupported" #endif @@ -210,6 +218,17 @@ int ParallelExecutor::getNumProcessors() { } else { return( (int)nProcessorsOnline ); } +#else +#ifdef __FreeBSD__ + int ncpu,retval; + size_t len = 4; + + retval = sysctlbyname( "hw.ncpu", &ncpu, &len, NULL, 0 ); + if( retval == 0 ) { + return (ncpu ); + } else { + return(1); + } #else // Windows @@ -227,6 +246,7 @@ int ParallelExecutor::getNumProcessors() { return(ncpu); #endif #endif +#endif } bool ParallelExecutor::isWorkerThread() {