diff --git a/include/haproxy/thread-t.h b/include/haproxy/thread-t.h index 2861d40d4..d2bf8d365 100644 --- a/include/haproxy/thread-t.h +++ b/include/haproxy/thread-t.h @@ -26,7 +26,6 @@ #ifdef USE_THREAD #include #endif -#include #include @@ -75,26 +74,6 @@ /*** Common parts below ***/ -/* thread info flags, for ha_thread_info[].flags */ -#define TI_FL_STUCK 0x00000001 - -/* This structure describes all the per-thread info we need. When threads are - * disabled, it contains the same info for the single running thread (except - * the pthread identifier which does not exist). - */ -struct thread_info { - __decl_thread(pthread_t pthread); - clockid_t clock_id; - timer_t wd_timer; /* valid timer or TIMER_INVALID if not set */ - uint64_t prev_cpu_time; /* previous per thread CPU time */ - uint64_t prev_mono_time; /* previous system wide monotonic time */ - unsigned int idle_pct; /* idle to total ratio over last sample (percent) */ - unsigned int flags; /* thread info flags, TI_FL_* */ - /* pad to cache line (64B) */ - char __pad[0]; /* unused except to check remaining room */ - char __end[0] __attribute__((aligned(64))); -}; - /* storage types used by spinlocks and RW locks */ #define __HA_SPINLOCK_T unsigned long #define __HA_RWLOCK_T unsigned long diff --git a/include/haproxy/thread.h b/include/haproxy/thread.h index cf9ed12a4..a9a4b62a5 100644 --- a/include/haproxy/thread.h +++ b/include/haproxy/thread.h @@ -31,6 +31,7 @@ #include #include +#include /* Note: this file mainly contains 5 sections: @@ -47,8 +48,6 @@ int parse_nbthread(const char *arg, char **err); int thread_get_default_count(); extern int thread_cpus_enabled_at_boot; -extern struct thread_info ha_thread_info[MAX_THREADS]; -extern THREAD_LOCAL struct thread_info *ti; /* thread_info for the current thread */ #ifndef USE_THREAD diff --git a/include/haproxy/tinfo-t.h b/include/haproxy/tinfo-t.h new file mode 100644 index 000000000..b27266128 --- /dev/null +++ b/include/haproxy/tinfo-t.h @@ -0,0 +1,48 @@ +/* + * include/haproxy/tinfo-t.h + * Definitions of the thread_info structure. + * + * Copyright (C) 2020 Willy Tarreau - w@1wt.eu + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, version 2.1 + * exclusively. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _HAPROXY_TINFO_T_H +#define _HAPROXY_TINFO_T_H + +#include +#include + +/* thread info flags, for ha_thread_info[].flags */ +#define TI_FL_STUCK 0x00000001 + +/* This structure describes all the per-thread info we need. When threads are + * disabled, it contains the same info for the single running thread (except + * the pthread identifier which does not exist). + */ +struct thread_info { + __decl_thread(pthread_t pthread); + clockid_t clock_id; + timer_t wd_timer; /* valid timer or TIMER_INVALID if not set */ + uint64_t prev_cpu_time; /* previous per thread CPU time */ + uint64_t prev_mono_time; /* previous system wide monotonic time */ + unsigned int idle_pct; /* idle to total ratio over last sample (percent) */ + unsigned int flags; /* thread info flags, TI_FL_* */ + /* pad to cache line (64B) */ + char __pad[0]; /* unused except to check remaining room */ + char __end[0] __attribute__((aligned(64))); +}; + +#endif /* _HAPROXY_TINFO_T_H */ diff --git a/include/haproxy/tinfo.h b/include/haproxy/tinfo.h new file mode 100644 index 000000000..be6cddf17 --- /dev/null +++ b/include/haproxy/tinfo.h @@ -0,0 +1,32 @@ +/* + * include/haproxy/tinfo.h + * Export of ha_thread_info[] and ti pointer. + * + * Copyright (C) 2020 Willy Tarreau - w@1wt.eu + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, version 2.1 + * exclusively. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _HAPROXY_TINFO_H +#define _HAPROXY_TINFO_H + +#include +#include + +/* the struct is in thread.c */ +extern struct thread_info ha_thread_info[MAX_THREADS]; +extern THREAD_LOCAL struct thread_info *ti; /* thread_info for the current thread */ + +#endif /* _HAPROXY_TINFO_H */