diff options
Diffstat (limited to 'src/pulsecore/core-util.c')
-rw-r--r-- | src/pulsecore/core-util.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index fcb5c421..e65b1796 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -2541,3 +2541,15 @@ void pa_reduce(unsigned *num, unsigned *den) { pa_assert(pa_gcd(*num, *den) == 1); } + +unsigned pa_ncpus(void) { + long ncpus; + +#ifdef _SC_NPROCESSORS_CONF + ncpus = sysconf(_SC_NPROCESSORS_CONF); +#else + ncpus = 1; +#endif + + return ncpus <= 0 ? 1 : (unsigned) ncpus; +} |