Skip to content

Commit

Permalink
Use HW_NCPUONLINE on OpenBSD / NetBSD (#3813)
Browse files Browse the repository at this point in the history
HW_NCPUONLINE is the proper sysctl to use for the logical processor
count.
  • Loading branch information
brad0 authored Dec 17, 2024
1 parent 1ebb3f1 commit fc1605c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion codec/common/src/WelsThreadLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
#endif
#ifdef __APPLE__
#define HW_NCPU_NAME "hw.logicalcpu"
#elif defined(HW_NCPUONLINE)
#define HW_NCPU_NAME "hw.ncpuonline"
#else
#define HW_NCPU_NAME "hw.ncpu"
#endif
Expand Down Expand Up @@ -522,7 +524,7 @@ WELS_THREAD_ERROR_CODE WelsQueryLogicalProcessInfo (WelsLogicalProcessInfo* p
size_t len = sizeof (pInfo->ProcessorCount);

#if defined(__OpenBSD__)
int scname[] = { CTL_HW, HW_NCPU };
int scname[] = { CTL_HW, HW_NCPUONLINE };
if (sysctl (scname, 2, &pInfo->ProcessorCount, &len, NULL, 0) == -1)
#else
if (sysctlbyname (HW_NCPU_NAME, &pInfo->ProcessorCount, &len, NULL, 0) == -1)
Expand Down

0 comments on commit fc1605c

Please sign in to comment.