From 4dc191646750a15c7f92f945816b59cd91c5728c Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 22 Jan 2009 02:16:53 +0100 Subject: add API pa_ncpus() --- src/pulsecore/core-util.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/pulsecore/core-util.c') 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; +} -- cgit