]> git.zerfleddert.de Git - proxmark3-svn/blobdiff - client/util.c
fix compile errors on non-Intel CPUs:
[proxmark3-svn] / client / util.c
index 5c2579b1a904c7eb7cf3c2f1f9aeee75575427af..13067ec1d57b4773859a6affccb5e0969d05e213 100644 (file)
@@ -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 <sysinfoapi.h>
+       SYSTEM_INFO sysinfo;
+       GetSystemInfo(&sysinfo);
+       return sysinfo.dwNumberOfProcessors;
+#elif defined(__linux__) || defined(__APPLE__)
+       #include <unistd.h>
+       return sysconf(_SC_NPROCESSORS_ONLN);
+#else
+       return 1;
+#endif
+}
Impressum, Datenschutz