Mercurial > hg > octave-lyh > gnulib-hg
changeset 12179:70f69bf8b898
Implement nproc for mingw.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 18 Oct 2009 11:22:22 +0200 |
parents | 9918c96ad4ac |
children | 2c71cf09ef7e |
files | ChangeLog lib/nproc.c |
diffstat | 2 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-10-18 Bruno Haible <bruno@clisp.org> + + Implement nproc for mingw. + * lib/nproc.c: Include <windows.h> + (num_processors): On native Windows platforms, try GetSystemInfo. + 2009-10-18 Bruno Haible <bruno@clisp.org> Implement nproc for IRIX.
--- 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 @@ } #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; }