CLEANUP: thread: uninline ha_tkill/ha_tkillall/ha_cpu_relax()
These ones are rarely used or only to waste CPU cycles waiting, and are
the last ones requiring system includes in thread.h. Let's uninline them
and move them to thread.c.
diff --git a/include/haproxy/thread.h b/include/haproxy/thread.h
index 1881fa9..7598327 100644
--- a/include/haproxy/thread.h
+++ b/include/haproxy/thread.h
@@ -23,12 +23,6 @@
#ifndef _HAPROXY_THREAD_H
#define _HAPROXY_THREAD_H
-#include <signal.h>
-#include <unistd.h>
-#ifdef _POSIX_PRIORITY_SCHEDULING
-#include <sched.h>
-#endif
-
#include <haproxy/api.h>
#include <haproxy/thread-t.h>
#include <haproxy/tinfo.h>
@@ -46,6 +40,9 @@
/* Generic exports */
int parse_nbthread(const char *arg, char **err);
+void ha_tkill(unsigned int thr, int sig);
+void ha_tkillall(int sig);
+void ha_thread_relax(void);
extern int thread_cpus_enabled_at_boot;
@@ -95,25 +92,6 @@
ti = &ha_thread_info[tid];
}
-static inline void ha_thread_relax(void)
-{
-#ifdef _POSIX_PRIORITY_SCHEDULING
- sched_yield();
-#endif
-}
-
-/* send signal <sig> to thread <thr> */
-static inline void ha_tkill(unsigned int thr, int sig)
-{
- raise(sig);
-}
-
-/* send signal <sig> to all threads */
-static inline void ha_tkillall(int sig)
-{
- raise(sig);
-}
-
static inline void thread_idle_now()
{
}
@@ -179,8 +157,6 @@
void thread_isolate_full(void);
void thread_release(void);
void thread_sync_release(void);
-void ha_tkill(unsigned int thr, int sig);
-void ha_tkillall(int sig);
void ha_spin_init(HA_SPINLOCK_T *l);
void ha_rwlock_init(HA_RWLOCK_T *l);
void setup_extra_threads(void *(*handler)(void *));
@@ -232,15 +208,6 @@
ti = &ha_thread_info[tid];
}
-static inline void ha_thread_relax(void)
-{
-#ifdef _POSIX_PRIORITY_SCHEDULING
- sched_yield();
-#else
- pl_cpu_relax();
-#endif
-}
-
/* Marks the thread as idle, which means that not only it's not doing anything
* dangerous, but in addition it has not started anything sensitive either.
* This essentially means that the thread currently is in the poller, thus
diff --git a/src/thread.c b/src/thread.c
index 0858aca..a340001 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -15,6 +15,12 @@
#include <stdlib.h>
#include <fcntl.h>
+#include <signal.h>
+#include <unistd.h>
+#ifdef _POSIX_PRIORITY_SCHEDULING
+#include <sched.h>
+#endif
+
#ifdef USE_THREAD
# include <pthread.h>
#endif
@@ -312,6 +318,15 @@
raise(sig);
}
+void ha_thread_relax(void)
+{
+#ifdef _POSIX_PRIORITY_SCHEDULING
+ sched_yield();
+#else
+ pl_cpu_relax();
+#endif
+}
+
/* these calls are used as callbacks at init time when debugging is on */
void ha_spin_init(HA_SPINLOCK_T *l)
{
@@ -956,6 +971,25 @@
#else
+/* send signal <sig> to thread <thr> (send to process in fact) */
+void ha_tkill(unsigned int thr, int sig)
+{
+ raise(sig);
+}
+
+/* send signal <sig> to all threads (send to process in fact) */
+void ha_tkillall(int sig)
+{
+ raise(sig);
+}
+
+void ha_thread_relax(void)
+{
+#ifdef _POSIX_PRIORITY_SCHEDULING
+ sched_yield();
+#endif
+}
+
REGISTER_BUILD_OPTS("Built without multi-threading support (USE_THREAD not set).");
#endif // USE_THREAD