summaryrefslogtreecommitdiff
path: root/lib/nproc.c
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2009-10-18 11:22:22 +0200
committerBruno Haible <bruno@clisp.org>2009-10-18 11:22:22 +0200
commitfe8e9df2bc219bfa84ca8c04e75bca37ef5fda41 (patch)
treeef12130d3c2df7c7f2fe91f3a4569a84bedce7c4 /lib/nproc.c
parentc1c314994ba1f47f5af0be7600c400841c5d34da (diff)
downloadgnulib-fe8e9df2bc219bfa84ca8c04e75bca37ef5fda41.tar.gz
Implement nproc for mingw.
Diffstat (limited to 'lib/nproc.c')
-rw-r--r--lib/nproc.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/nproc.c b/lib/nproc.c
index 04a047cfb4..b5a70b193a 100644
--- a/lib/nproc.c
+++ b/lib/nproc.c
@@ -41,6 +41,11 @@
# include <sys/sysctl.h>
#endif
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#endif
+
#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
/* Return the total number of processors. The result is guaranteed to
@@ -90,5 +95,14 @@ num_processors (void)
}
#endif
+#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+ { /* This works on native Windows platforms. */
+ SYSTEM_INFO system_info;
+ GetSystemInfo (&system_info);
+ if (0 < system_info.dwNumberOfProcessors)
+ return system_info.dwNumberOfProcessors;
+ }
+#endif
+
return 1;
}