/* Based on code from: http://lists.gnu.org/archive/html/autoconf/2002-08/msg00126.html */ #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN #include #else #include #endif #include #include #include #include #include "numberOfProcessors.h" bool numberOfProcessors( int &num, int &max ) { long nprocs = -1; long nprocs_max = -1; #ifdef _WIN32 #ifndef _SC_NPROCESSORS_ONLN SYSTEM_INFO info; GetSystemInfo(&info); #define sysconf(a) info.dwNumberOfProcessors #define _SC_NPROCESSORS_ONLN #endif #endif #ifdef _SC_NPROCESSORS_ONLN nprocs = sysconf(_SC_NPROCESSORS_ONLN); if (nprocs < 1) { return false; } nprocs_max = sysconf(_SC_NPROCESSORS_CONF); if (nprocs_max < 1) { return false; } num = nprocs; max = nprocs_max; return true; #else return false; #endif }