From 3b6207d4bd9143204745f90a38278891dbaa4474 Mon Sep 17 00:00:00 2001 From: Sean Purcell Date: Thu, 13 Apr 2017 14:03:56 -0700 Subject: [PATCH] Fix compilation on windows --- programs/util.h | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/programs/util.h b/programs/util.h index 104f8dad..63cfa964 100644 --- a/programs/util.h +++ b/programs/util.h @@ -536,12 +536,16 @@ UTIL_STATIC int UTIL_countPhysicalCores(void) } } - while (byteOffset + sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION) <= returnLength) { - ptr = buffer; + ptr = buffer; - if (ptr->RelationShip == RelationProcessorCore) { + while (byteOffset + sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION) <= returnLength) { + + if (ptr->Relationship == RelationProcessorCore) { numPhysicalCores++; } + + ptr++; + byteOffset += sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); } free(buffer); @@ -551,10 +555,11 @@ UTIL_STATIC int UTIL_countPhysicalCores(void) failed: /* try to fall back on GetSystemInfo */ - SYSTEM_INFO sysinfo; - GetSystemInfo(&sysinfo); - numPhysicalCores = sysinfo.dwNumberOfProcessors; - if (numPhysicalCores == 0) numPhysicalCores = 1; /* just in case */ + { SYSTEM_INFO sysinfo; + GetSystemInfo(&sysinfo); + numPhysicalCores = sysinfo.dwNumberOfProcessors; + if (numPhysicalCores == 0) numPhysicalCores = 1; /* just in case */ + } return numPhysicalCores; }