diff options
| author | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-09-11 07:07:09 -0400 |
|---|---|---|
| committer | Feoramund <161657516+Feoramund@users.noreply.github.com> | 2024-09-11 08:39:23 -0400 |
| commit | 2938655a3d8801d1327b0076812edcf357d760df (patch) | |
| tree | 24c2da9b7cea5892d59fd7d030548954c33f0605 /src | |
| parent | b1db33b519bf52e2d0e6e42ca9daccc7470d6b8b (diff) | |
Fix CPU count detection in FreeBSD & NetBSD
Diffstat (limited to 'src')
| -rw-r--r-- | src/gb/gb.h | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/gb/gb.h b/src/gb/gb.h index 0e65696e2..1fef4b4f5 100644 --- a/src/gb/gb.h +++ b/src/gb/gb.h @@ -3195,11 +3195,11 @@ void gb_affinity_init(gbAffinity *a) { a->core_count = 1; a->threads_per_core = 1; - if (sysctlbyname("hw.logicalcpu", &count, &count_size, NULL, 0) == 0) { + if (sysctlbyname("kern.smp.cpus", &count, &count_size, NULL, 0) == 0) { if (count > 0) { a->thread_count = count; // Get # of physical cores - if (sysctlbyname("hw.physicalcpu", &count, &count_size, NULL, 0) == 0) { + if (sysctlbyname("kern.smp.cores", &count, &count_size, NULL, 0) == 0) { if (count > 0) { a->core_count = count; a->threads_per_core = a->thread_count / count; @@ -3210,6 +3210,14 @@ void gb_affinity_init(gbAffinity *a) { } } } + } else if (sysctlbyname("hw.ncpu", &count, &count_size, NULL, 0) == 0) { + // SMP disabled or unavailable. + if (count > 0) { + a->is_accurate = true; + a->thread_count = count; + a->core_count = count; + a->threads_per_core = 1; + } } } |