Only use CPU_COUNT if available

Fixes build error on Linux hosts with GLIBC < 2.6.

Resolves issue #2089
This commit is contained in:
Nathan Kidd 2015-09-02 18:14:10 -04:00 committed by Nathan Kidd
parent fd7a02b557
commit fdabca4cc9

View File

@ -476,10 +476,21 @@ WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo (WelsLogicalProcessInfo* p
CPU_ZERO (&cpuset);
if (!sched_getaffinity (0, sizeof (cpuset), &cpuset))
if (!sched_getaffinity (0, sizeof (cpuset), &cpuset)) {
#ifdef CPU_COUNT
pInfo->ProcessorCount = CPU_COUNT (&cpuset);
else
#else
int32_t count = 0;
for (int i = 0; i < CPU_SETSIZE; i++) {
if (CPU_ISSET(i, &cpuset)) {
count++;
}
}
pInfo->ProcessorCount = count;
#endif
} else {
pInfo->ProcessorCount = 1;
}
return WELS_THREAD_ERROR_OK;