ref: 9add9883b16b8e361405bd3d4c43af9484bae8e6
parent: fd7a02b557062f2657d6ae13578b000480187fe0
parent: fdabca4cc902d07aebdd97fab4534b5fc57e705d
author: HaiboZhu <[email protected]>
date: Sun Sep 6 05:18:29 EDT 2015
Merge pull request #2100 from nathankidd/fix-CPU_COUNT-error Only use CPU_COUNT if available
--- 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;