X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/b9957414a5fc9a661fed27d95838726eeeedadd9..e57c8b2e5601aacd3655a7c1a5c47a7cab66d914:/client/util.c?ds=sidebyside diff --git a/client/util.c b/client/util.c index 5c2579b1..13067ec1 100644 --- a/client/util.c +++ b/client/util.c @@ -656,3 +656,19 @@ uint64_t msclock() { return (t.tv_sec * 1000 + t.tv_nsec / 1000000); #endif } + +// determine number of logical CPU cores (use for multithreaded functions) +extern int num_CPUs(void) +{ +#if defined(_WIN32) + #include + SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + return sysinfo.dwNumberOfProcessors; +#elif defined(__linux__) || defined(__APPLE__) + #include + return sysconf(_SC_NPROCESSORS_ONLN); +#else + return 1; +#endif +}