ref: fdabca4cc902d07aebdd97fab4534b5fc57e705d
parent: fd7a02b557062f2657d6ae13578b000480187fe0
author: Nathan Kidd <[email protected]>
date: Wed Sep 2 14:14:10 EDT 2015
Only use CPU_COUNT if available Fixes build error on Linux hosts with GLIBC < 2.6. Resolves issue #2089
--- a/codec/common/src/WelsThreadLib.cpp
+++ b/codec/common/src/WelsThreadLib.cpp
@@ -476,10 +476,21 @@
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;