X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fovs-thread.c;h=02436e5b5015941bf36623fa290e58395f71cc3f;hb=0122f6e65c5f92da210d3fc024b781cc4faa8a6f;hp=b3a87bb12bc9db88630cb59a10f0dde936705a90;hpb=a1aeea86475db086ce95679962fb6d03d0a645f3;p=sliver-openvswitch.git diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c index b3a87bb12..02436e5b5 100644 --- a/lib/ovs-thread.c +++ b/lib/ovs-thread.c @@ -309,4 +309,14 @@ may_fork(void) { return !must_not_fork; } + +/* Returns the total number of cores on this system, or 0 if the number cannot + * be determined. */ +unsigned int +count_cpu_cores(void) +{ + long int n_cores = sysconf(_SC_NPROCESSORS_ONLN); + + return n_cores > 0 ? n_cores : 0; +} #endif