summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpus.h16
-rw-r--r--ct_server.c1
-rw-r--r--ifpps.c1
-rw-r--r--trafgen.c1
-rw-r--r--xutils.c10
-rw-r--r--xutils.h2
6 files changed, 19 insertions, 12 deletions
diff --git a/cpus.h b/cpus.h
new file mode 100644
index 0000000..d672daa
--- /dev/null
+++ b/cpus.h
@@ -0,0 +1,16 @@
+#ifndef CPUS_H
+#define CPUS_H
+
+#include <unistd.h>
+
+static inline int get_number_cpus(void)
+{
+ return sysconf(_SC_NPROCESSORS_CONF);
+}
+
+static inline int get_number_cpus_online(void)
+{
+ return sysconf(_SC_NPROCESSORS_ONLN);
+}
+
+#endif /* CPUS_H */
diff --git a/ct_server.c b/ct_server.c
index 045472e..7c23b52 100644
--- a/ct_server.c
+++ b/ct_server.c
@@ -34,6 +34,7 @@
#include "xmalloc.h"
#include "curvetun.h"
#include "curve.h"
+#include "cpus.h"
#include "built_in.h"
#include "ct_usermgmt.h"
#include "cpusched.h"
diff --git a/ifpps.c b/ifpps.c
index c8691a1..9ff01b3 100644
--- a/ifpps.c
+++ b/ifpps.c
@@ -21,6 +21,7 @@
#include "xmalloc.h"
#include "xutils.h"
#include "xio.h"
+#include "cpus.h"
#include "built_in.h"
struct wifi_stat {
diff --git a/trafgen.c b/trafgen.c
index 158b96e..725b360 100644
--- a/trafgen.c
+++ b/trafgen.c
@@ -35,6 +35,7 @@
#include "xmalloc.h"
#include "die.h"
#include "str.h"
+#include "cpus.h"
#include "lockme.h"
#include "mac80211.h"
#include "xutils.h"
diff --git a/xutils.c b/xutils.c
index b539d8c..9b81fea 100644
--- a/xutils.c
+++ b/xutils.c
@@ -718,16 +718,6 @@ int get_default_sched_prio(void)
return sched_get_priority_max(get_default_sched_policy());
}
-int get_number_cpus(void)
-{
- return sysconf(_SC_NPROCESSORS_CONF);
-}
-
-int get_number_cpus_online(void)
-{
- return sysconf(_SC_NPROCESSORS_ONLN);
-}
-
int get_default_proc_prio(void)
{
return -20;
diff --git a/xutils.h b/xutils.h
index e435c43..7015d57 100644
--- a/xutils.h
+++ b/xutils.h
@@ -69,8 +69,6 @@ extern int set_proc_prio(int prio);
extern int set_sched_status(int policy, int priority);
extern int get_default_sched_policy(void);
extern int get_default_sched_prio(void);
-extern int get_number_cpus(void);
-extern int get_number_cpus_online(void);
extern int get_default_proc_prio(void);
extern void set_system_socket_memory(int *vals, size_t len);
extern void reset_system_socket_memory(int *vals, size_t len);