REORG: include: move THREAD_LOCAL and __decl_thread() to compiler.h

Since these are used as type attributes or conditional clauses, they
are used about everywhere and should not require a dependency on
thread.h. Moving them to compiler.h along with other similar statements
like ALIGN() etc looks more logical; this way they become part of the
base API. This allowed to remove thread-t.h from ~12 files, one was
found to only require thread-t and not thread and dict.c was found to
require thread.h.
This commit is contained in:
Willy Tarreau 2020-06-11 08:33:02 +02:00
parent ca8b069aa7
commit 5b9cde4820
15 changed files with 22 additions and 19 deletions

View File

@ -223,4 +223,24 @@
#endif
#endif
/* The THREAD_LOCAL type attribute defines thread-local storage and is defined
* to __thread when threads are enabled or empty when disabled.
*/
#ifdef USE_THREAD
#define THREAD_LOCAL __thread
#else
#define THREAD_LOCAL
#endif
/* The __decl_thread() statement is shows the argument when threads are enabled
* or hides it when disabled. The purpose is to condition the presence of some
* variables or struct members to the fact that threads are enabled, without
* having to enclose them inside a #ifdef USE_THREAD/#endif clause.
*/
#ifdef USE_THREAD
#define __decl_thread(decl) decl
#else
#define __decl_thread(decl)
#endif
#endif /* _HAPROXY_COMPILER_H */

View File

@ -29,7 +29,7 @@
#include <import/ebpttree.h>
#include <haproxy/api-t.h>
#include <haproxy/thread.h>
#include <haproxy/thread-t.h>
struct dict_entry {
struct ebpt_node value;

View File

@ -24,7 +24,6 @@
#include <haproxy/global-t.h>
#include <haproxy/api-t.h>
#include <haproxy/thread.h>
#include <haproxy/vars-t.h>
#include <haproxy/mworker-t.h>

View File

@ -29,7 +29,6 @@
#include <haproxy/pool-t.h>
#include <haproxy/proxy-t.h>
#include <haproxy/stream.h>
#include <haproxy/thread-t.h>
extern struct pool_head *pool_head_requri;
extern struct pool_head *pool_head_uniqueid;

View File

@ -26,7 +26,6 @@
#include <string.h>
#include <haproxy/api.h>
#include <haproxy/thread-t.h>
#ifdef USE_PCRE
#include <pcre.h>

View File

@ -27,7 +27,6 @@
#include <haproxy/api.h>
#include <haproxy/regex-t.h>
#include <haproxy/thread-t.h>
extern THREAD_LOCAL regmatch_t pmatch[MAX_MATCH];

View File

@ -40,10 +40,7 @@
/********************** THREADS DISABLED ************************/
#define THREAD_LOCAL /* empty */
/* These macros allow to make some struct fields or local variables optional */
#define __decl_thread(decl)
#define __decl_spinlock(lock)
#define __decl_aligned_spinlock(lock)
#define __decl_rwlock(lock)
@ -53,10 +50,6 @@
/********************** THREADS ENABLED ************************/
#define THREAD_LOCAL __thread
#define __decl_thread(decl) decl
/* declare a self-initializing spinlock */
#define __decl_spinlock(lock) \
HA_SPINLOCK_T (lock); \

View File

@ -26,7 +26,6 @@
#include <haproxy/api.h>
#include <haproxy/list.h>
#include <haproxy/sink-t.h>
#include <haproxy/thread-t.h>
#include <haproxy/tools.h>
#include <haproxy/trace-t.h>

View File

@ -3,6 +3,7 @@
#include <import/eb32tree.h>
#include <import/ebistree.h>
#include <haproxy/dict.h>
#include <haproxy/thread.h>
struct dict *new_dict(const char *name)
{

View File

@ -17,7 +17,6 @@
#include <haproxy/api.h>
#include <haproxy/global.h>
#include <haproxy/signal.h>
#include <haproxy/thread-t.h>
#include <haproxy/tools.h>
#include <haproxy/ticks.h>
#include <haproxy/time.h>

View File

@ -20,7 +20,6 @@
#include <haproxy/api.h>
#include <haproxy/signal.h>
#include <haproxy/thread-t.h>
#include <haproxy/ticks.h>
#include <haproxy/time.h>

View File

@ -19,7 +19,6 @@
#include <haproxy/api.h>
#include <haproxy/signal.h>
#include <haproxy/thread-t.h>
#include <haproxy/ticks.h>
#include <haproxy/time.h>

View File

@ -18,7 +18,6 @@
#include <sys/types.h>
#include <haproxy/api.h>
#include <haproxy/thread-t.h>
#include <haproxy/ticks.h>
#include <haproxy/time.h>

View File

@ -15,7 +15,6 @@
#include <sys/types.h>
#include <haproxy/api.h>
#include <haproxy/thread-t.h>
#include <haproxy/ticks.h>
#include <haproxy/time.h>

View File

@ -16,7 +16,6 @@
#include <haproxy/api.h>
#include <haproxy/tools.h>
#include <haproxy/time.h>
#include <haproxy/thread-t.h>
THREAD_LOCAL unsigned int ms_left_scaled; /* milliseconds left for current second (0..2^32-1) */
THREAD_LOCAL unsigned int now_ms; /* internal date in milliseconds (may wrap) */