X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fpbd%2Fcpus.cc;h=fed7725b766d819f33aef2148e3030edbc25a9db;hb=587a2dee55fe545587dde2d42c829fe16b845c3d;hp=fb94b475de69735c8990f1f85dc50c619b8929d0;hpb=f5f89d8c7e7e0cb6dad8c3f255b3871ef99a78cf;p=ardour.git diff --git a/libs/pbd/cpus.cc b/libs/pbd/cpus.cc index fb94b475de..fed7725b76 100644 --- a/libs/pbd/cpus.cc +++ b/libs/pbd/cpus.cc @@ -22,6 +22,8 @@ #include "libpbd-config.h" #endif +#include + #ifdef __linux__ #include #elif defined(__APPLE__) || defined(__FreeBSD__) @@ -41,20 +43,30 @@ uint32_t hardware_concurrency() { + if (getenv("CONCURRENCY")) { + int c = atoi (getenv("CONCURRENCY")); + if (c > 0) { + return c; + } + } #if defined(PTW32_VERSION) || defined(__hpux) - return pthread_num_processors_np(); -#elif defined(__APPLE__) || defined(__FreeBSD__) - int count; - size_t size=sizeof(count); - return sysctlbyname("hw.physicalcpu",&count,&size,NULL,0)?0:count; + return pthread_num_processors_np(); +#elif defined(__APPLE__) + int count; + size_t size=sizeof(count); + return sysctlbyname("hw.physicalcpu",&count,&size,NULL,0)?0:count; +#elif defined(__FreeBSD__) + int count; + size_t size=sizeof(count); + return sysctlbyname("hw.ncpu",&count,&size,NULL,0)?0:count; #elif defined(HAVE_UNISTD) && defined(_SC_NPROCESSORS_ONLN) - int const count=sysconf(_SC_NPROCESSORS_ONLN); - return (count>0)?count:0; + int const count=sysconf(_SC_NPROCESSORS_ONLN); + return (count>0)?count:0; #elif defined(PLATFORM_WINDOWS) - SYSTEM_INFO sys_info; - GetSystemInfo( &sys_info ); - return sys_info.dwNumberOfProcessors; + SYSTEM_INFO sys_info; + GetSystemInfo( &sys_info ); + return sys_info.dwNumberOfProcessors; #else - return 0; + return 0; #endif }