bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

nproc: port to mingw


From: Bruno Haible
Subject: nproc: port to mingw
Date: Sun, 18 Oct 2009 11:25:46 +0200
User-agent: KMail/1.9.9

And this finally adds mingw support to the nprocs module. Quite trivial
once you have found out which Win32 function to use
(GetLogicalProcessorInformation? NtQuerySystemInformation? GetSystemInfo?).


2009-10-18  Bruno Haible  <address@hidden>

        Implement nproc for mingw.
        * lib/nproc.c: Include <windows.h>
        (num_processors): On native Windows platforms, try GetSystemInfo.

*** lib/nproc.c.orig    2009-10-18 11:21:15.000000000 +0200
--- lib/nproc.c 2009-10-18 11:15:28.000000000 +0200
***************
*** 41,46 ****
--- 41,51 ----
  # 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,94 ****
--- 95,108 ----
    }
  #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;
  }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]