diff --git a/include/haproxy/thread.h b/include/haproxy/thread.h index 1881fa98d..7598327d4 100644 --- a/include/haproxy/thread.h +++ b/include/haproxy/thread.h @@ -23,12 +23,6 @@ #ifndef _HAPROXY_THREAD_H #define _HAPROXY_THREAD_H -#include -#include -#ifdef _POSIX_PRIORITY_SCHEDULING -#include -#endif - #include #include #include @@ -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 to thread */ -static inline void ha_tkill(unsigned int thr, int sig) -{ - raise(sig); -} - -/* send signal 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 diff --git a/src/thread.c b/src/thread.c index 0858acad8..a3400010b 100644 --- a/src/thread.c +++ b/src/thread.c @@ -15,6 +15,12 @@ #include #include +#include +#include +#ifdef _POSIX_PRIORITY_SCHEDULING +#include +#endif + #ifdef USE_THREAD # include #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 to thread (send to process in fact) */ +void ha_tkill(unsigned int thr, int sig) +{ + raise(sig); +} + +/* send signal 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