diff options
Diffstat (limited to 'mysys/my_getncpus.c')
-rw-r--r-- | mysys/my_getncpus.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/mysys/my_getncpus.c b/mysys/my_getncpus.c index 82e87dee2e4..4cb96ac0bca 100644 --- a/mysys/my_getncpus.c +++ b/mysys/my_getncpus.c @@ -16,24 +16,26 @@ /* get the number of (online) CPUs */ #include "mysys_priv.h" +#ifdef HAVE_UNISTD_H #include <unistd.h> +#endif static int ncpus=0; -#ifdef _SC_NPROCESSORS_ONLN int my_getncpus() { if (!ncpus) + { +#ifdef _SC_NPROCESSORS_ONLN ncpus= sysconf(_SC_NPROCESSORS_ONLN); - return ncpus; -} - +#elif defined(__WIN__) + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + ncpus= sysinfo.dwNumberOfProcessors; #else -/* unknown */ -int my_getncpus() -{ - return 2; -} - +/* unknown so play safe: assume SMP and forbid uniprocessor build */ + ncpus= 2; #endif - + } + return ncpus; +} |