]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: thread: uninline ha_tkill/ha_tkillall/ha_cpu_relax()
authorWilly Tarreau <w@1wt.eu>
Wed, 6 Oct 2021 21:33:20 +0000 (23:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 6 Oct 2021 23:41:15 +0000 (01:41 +0200)
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.

include/haproxy/thread.h
src/thread.c

index 1881fa98df16975b3987313a4e202038a5a0dfc3..7598327d487ffe908758f5d2bb00e9f83d2f497b 100644 (file)
 #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 @@ static inline void ha_set_tid(unsigned int tid)
        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(void);
 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 @@ static inline void ha_set_tid(unsigned int data)
        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
index 0858acad87b263c0c643b93fcd4c7de1ecd6a7ff..a3400010bc3a52bff0798834b10f35ba490a128c 100644 (file)
 #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 @@ void ha_tkillall(int sig)
        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 @@ static void __thread_init(void)
 
 #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