From da7eefd60e3900e0430f52e2c0e601027f9342f0 Mon Sep 17 00:00:00 2001 From: Gleb Popov <6yearold@gmail.com> Date: Sun, 10 Nov 2019 01:03:28 +0400 Subject: [PATCH] Implement get_count() from cpu.c for FreeBSD. --- spa/plugins/support/cpu.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/spa/plugins/support/cpu.c b/spa/plugins/support/cpu.c index 67b83c222..d8978fad9 100644 --- a/spa/plugins/support/cpu.c +++ b/spa/plugins/support/cpu.c @@ -29,6 +29,10 @@ #include #include +#ifdef __FreeBSD__ +#include +#endif + #include #include #include @@ -75,6 +79,7 @@ impl_cpu_force_flags(void *object, uint32_t flags) return 0; } +#ifndef __FreeBSD__ static uint32_t get_count(struct impl *this) { cpu_set_t cpuset; @@ -83,6 +88,17 @@ static uint32_t get_count(struct impl *this) return CPU_COUNT(&cpuset); return 1; } +#else +static uint32_t get_count(struct impl *this) +{ + int mib[] = {CTL_HW, HW_NCPU}; + int r; + size_t rSize = sizeof(r); + if(-1 == sysctl(mib, 2, &r, &rSize, 0, 0)) + return 1; + return r; +} +#endif static uint32_t impl_cpu_get_count(void *object)