Skip to content

Commit fc1605c

Browse files
authored
Use HW_NCPUONLINE on OpenBSD / NetBSD (#3813)
HW_NCPUONLINE is the proper sysctl to use for the logical processor count.
1 parent 1ebb3f1 commit fc1605c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

codec/common/src/WelsThreadLib.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
#endif
5656
#ifdef __APPLE__
5757
#define HW_NCPU_NAME "hw.logicalcpu"
58+
#elif defined(HW_NCPUONLINE)
59+
#define HW_NCPU_NAME "hw.ncpuonline"
5860
#else
5961
#define HW_NCPU_NAME "hw.ncpu"
6062
#endif
@@ -522,7 +524,7 @@ WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo (WelsLogicalProcessInfo* p
522524
size_t len = sizeof (pInfo->ProcessorCount);
523525

524526
#if defined(__OpenBSD__)
525-
int scname[] = { CTL_HW, HW_NCPU };
527+
int scname[] = { CTL_HW, HW_NCPUONLINE };
526528
if (sysctl (scname, 2, &pInfo->ProcessorCount, &len, NULL, 0) == -1)
527529
#else
528530
if (sysctlbyname (HW_NCPU_NAME, &pInfo->ProcessorCount, &len, NULL, 0) == -1)

0 commit comments

Comments
 (0)