Skip to content

Commit 69814ce

Browse files
bnoordhuisgiordano
authored andcommitted
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 (cherry picked from commit 5ff1fc7)
1 parent c57e7f0 commit 69814ce

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
@@ -523,7 +523,7 @@ unsigned int uv_available_parallelism(void) {
523523
*/
524524
count = 0;
525525
if (GetProcessAffinityMask(GetCurrentProcess(), &procmask, &sysmask))
526-
for (i = 0; i < 64; i++) /* a.k.a. count = popcount(procmask); */
526+
for (i = 0; i < 8 * sizeof(procmask); i++)
527527
count += 1 & (procmask >> i);
528528

529529
if (count > 0)

0 commit comments

Comments
 (0)