Skip to content

Commit 5ff1fc7

Browse files
authored
win: fix uv_available_parallelism on win32 (libuv#4525)
Fixes commit 58dfb6c from a few days ago. DWORD_PTR is 32 bits on x86 Windows. Use the right bit count when checking the population count. Interestingly enough, it manifested itself as double counting online processors, presumably because the compiler emits a ROR instead of SHR. Fixes: libuv#4524
1 parent f00d4b6 commit 5ff1fc7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/win/util.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ unsigned int uv_available_parallelism(void) {
516516
*/
517517
count = 0;
518518
if (GetProcessAffinityMask(GetCurrentProcess(), &procmask, &sysmask))
519-
for (i = 0; i < 64; i++) /* a.k.a. count = popcount(procmask); */
519+
for (i = 0; i < 8 * sizeof(procmask); i++)
520520
count += 1 & (procmask >> i);
521521

522522
if (count > 0)

0 commit comments

Comments
 (0)