git://git.onelab.eu
/
sliver-openvswitch.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib: Refactor gathering CPU core count
[sliver-openvswitch.git]
/
lib
/
ovs-thread.c
diff --git
a/lib/ovs-thread.c
b/lib/ovs-thread.c
index
b3a87bb
..
02436e5
100644
(file)
--- a/
lib/ovs-thread.c
+++ b/
lib/ovs-thread.c
@@
-309,4
+309,14
@@
may_fork(void)
{
return !must_not_fork;
}
{
return !must_not_fork;
}
+
\f
+/* 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
#endif