On Fri, 21 Nov 2025, LIU Hao wrote:

在 2025-11-21 17:18, Martin Storsjö 写道:
+#define GetActiveProcessorCount __GetActiveProcessorCount
+#include <windows.h>
+#undef GetActiveProcessorCount
+
+DWORD WINAPI GetActiveProcessorCount(WORD GroupNumber)
+{
+    if (GroupNumber == ALL_PROCESSOR_GROUPS) {
+        SYSTEM_INFO info;
+        GetSystemInfo(&info);
+        return info.dwNumberOfProcessors;

Shouldn't this return

  #ifdef _WIN64
      return __builtin_popcountll(info.dwActiveProcessorMask);
  #else
      return __builtin_popcount(info.dwActiveProcessorMask);
  #endif


However I do wonder whether such configuration exists in practice, so the proposed change may be acceptable, too.

Right, that might perhaps be more accurate - and yeah, I'm not aware of any actual case where it would make a difference.

FWIW, this came up as libc++ is changing to use GetActiveProcessorCount instead of dwNumberOfProcessors for thread::hardware_concurrency - see https://github.com/llvm/llvm-project/pull/168229. So for that usecase, I'm stubbing in the old code for UWP compat.

// Martin

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to