mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
Implement get_count() from cpu.c for FreeBSD.
This commit is contained in:
parent
ef3ebbed46
commit
da7eefd60e
1 changed files with 16 additions and 0 deletions
|
|
@ -29,6 +29,10 @@
|
|||
#include <stdio.h>
|
||||
#include <sched.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
#include <spa/support/log.h>
|
||||
#include <spa/support/cpu.h>
|
||||
#include <spa/support/plugin.h>
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue