Fixes build error on Linux hosts with GLIBC < 2.6. Resolves issue #2089
Showing the changes to codec/common/src/WelsThreadLib.cpp (1 of 1 file). Show all
Unified · Split
| @@ -476,10 +476,21 @@ WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo (WelsLogicalProcessInfo* p · 475 unmodified lines | ||
| 476 | 476 | |
| 477 | 477 | CPU_ZERO (&cpuset); |
| 478 | 478 | |
| 479 | − if (!sched_getaffinity (0, sizeof (cpuset), &cpuset)) | |
| 479 | + if (!sched_getaffinity (0, sizeof (cpuset), &cpuset)) { | |
| 480 | +#ifdef CPU_COUNT | |
| 480 | 481 | pInfo->ProcessorCount = CPU_COUNT (&cpuset); |
| 481 | − else | |
| 482 | +#else | |
| 483 | + int32_t count = 0; | |
| 484 | + for (int i = 0; i < CPU_SETSIZE; i++) { | |
| 485 | + if (CPU_ISSET(i, &cpuset)) { | |
| 486 | + count++; | |
| 487 | + } | |
| 488 | + } | |
| 489 | + pInfo->ProcessorCount = count; | |
| 490 | +#endif | |
| 491 | + } else { | |
| 482 | 492 | pInfo->ProcessorCount = 1; |
| 493 | + } | |
| 483 | 494 | |
| 484 | 495 | return WELS_THREAD_ERROR_OK; |
| 485 | 496 | |