# HG changeset patch
# User Edouard Gomez <[email protected]>
# Date 1277506060 -7200
# Node ID 60c650cbe05863de827408f93fcc39e28ed12067
# Parent dc503a8af513fce5183e041e193c50d6d1c8d0c4
Use more generic way to find online processors on Unix, add win32 equivalent
and add a failcase to numcpu=1
diff --git a/librawstudio/rs-utils.c b/librawstudio/rs-utils.c
--- a/librawstudio/rs-utils.c
+++ b/librawstudio/rs-utils.c
@@ -155,6 +155,12 @@
g_static_mutex_lock (&lock);
if (num == 0)
{
+#if defined(_SC_NPROCESSORS_ONLN)
+ /* Use the POSIX way of getting the number of processors */
+ num = sysconf(_SC_NPROCESSORS_ONLN);
+ num = (num < 0) ? 1 : num;
+#elif defined (__linux__) && (defined (__i386__) || defined (__x86_64__))
+ /* Parse the /proc/cpuinfo exposed by Linux i386/amd64 kernels
*/
GIOChannel *io;
gchar *line;
@@ -174,7 +180,18 @@
}
else
num = 1;
+#elif defined(_WIN32)
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+ SYSTEM_INFO info;
+ GetSystemInfo(&info);
+ num = info.dwNumberOfProcessors;
+#else
+ /* No way to know, act as if in presence of a single cpu */
+ num = 1;
+#endif
}
+
g_static_mutex_unlock (&lock);
return num;
_______________________________________________
Rawstudio-dev mailing list
[email protected]
http://rawstudio.org/cgi-bin/mailman/listinfo/rawstudio-dev