-/// cpu_count() tries to detect the number of CPU cores
-
-int cpu_count() {
-
-#if defined(_MSC_VER)
- SYSTEM_INFO s;
- GetSystemInfo(&s);
- return std::min(int(s.dwNumberOfProcessors), MAX_THREADS);
-#else
-
-# if defined(_SC_NPROCESSORS_ONLN)
- return std::min((int)sysconf(_SC_NPROCESSORS_ONLN), MAX_THREADS);
-# elif defined(__hpux)
- struct pst_dynamic psd;
- if (pstat_getdynamic(&psd, sizeof(psd), (size_t)1, 0) == -1)
- return 1;
- return std::min((int)psd.psd_proc_cnt, MAX_THREADS);
-# else
- return 1;
-# endif
-
-#endif
-}