From fe8e9df2bc219bfa84ca8c04e75bca37ef5fda41 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 18 Oct 2009 11:22:22 +0200 Subject: [PATCH] Implement nproc for mingw. --- ChangeLog | 6 ++++++ lib/nproc.c | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 5a820cd30..fbd6694e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2009-10-18 Bruno Haible + Implement nproc for mingw. + * lib/nproc.c: Include + (num_processors): On native Windows platforms, try GetSystemInfo. + +2009-10-18 Bruno Haible + Implement nproc for IRIX. * lib/nproc.c: Include . (num_processors): On IRIX systems, try sysmp. diff --git a/lib/nproc.c b/lib/nproc.c index 04a047cfb..b5a70b193 100644 --- a/lib/nproc.c +++ b/lib/nproc.c @@ -41,6 +41,11 @@ # include #endif +#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ +# define WIN32_LEAN_AND_MEAN +# include +#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; } -- 2.11.0