File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -11128,9 +11128,22 @@ os_cpu_count_impl(PyObject *module)
11128
11128
{
11129
11129
int ncpu = 0 ;
11130
11130
#ifdef MS_WINDOWS
11131
- SYSTEM_INFO sysinfo ;
11132
- GetSystemInfo (& sysinfo );
11133
- ncpu = sysinfo .dwNumberOfProcessors ;
11131
+ /* Vista is supported and the GetMaximumProcessorCount API is Win7+
11132
+ Need to fallback to Vista behavior if this call isn't present */
11133
+ HINSTANCE hKernel32 ;
11134
+ hKernel32 = GetModuleHandleW (L"KERNEL32" );
11135
+
11136
+ static DWORD (CALLBACK * _GetMaximumProcessorCount )(WORD ) = NULL ;
11137
+ * (FARPROC * )& _GetMaximumProcessorCount = GetProcAddress (hKernel32 ,
11138
+ "GetMaximumProcessorCount" );
11139
+ if (_GetMaximumProcessorCount != NULL ) {
11140
+ ncpu = _GetMaximumProcessorCount (ALL_PROCESSOR_GROUPS );
11141
+ }
11142
+ else {
11143
+ SYSTEM_INFO sysinfo ;
11144
+ GetSystemInfo (& sysinfo );
11145
+ ncpu = sysinfo .dwNumberOfProcessors ;
11146
+ }
11134
11147
#elif defined(__hpux )
11135
11148
ncpu = mpctl (MPC_GETNUMSPUS , NULL , NULL );
11136
11149
#elif defined(HAVE_SYSCONF ) && defined(_SC_NPROCESSORS_ONLN )
You can’t perform that action at this time.
0 commit comments