]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: include: move THREAD_LOCAL and __decl_thread() to compiler.h
authorWilly Tarreau <w@1wt.eu>
Thu, 11 Jun 2020 06:33:02 +0000 (08:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Jun 2020 08:18:59 +0000 (10:18 +0200)
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.

15 files changed:
include/haproxy/compiler.h
include/haproxy/dict-t.h
include/haproxy/global.h
include/haproxy/log.h
include/haproxy/regex-t.h
include/haproxy/regex.h
include/haproxy/thread-t.h
include/haproxy/trace.h
src/dict.c
src/ev_epoll.c
src/ev_evports.c
src/ev_kqueue.c
src/ev_poll.c
src/ev_select.c
src/time.c

index 0e594fa84456496499955d39d6f26cf4556b3d19..ec9d4f393a7302bc12412dcc05f25c317ee1ece3 100644 (file)
 #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 */
index b026d305ed099fb7a996200c4e4a7accff93bd2e..cb2ea9003c5c154566ce99b3ee23f3f144572bfa 100644 (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;
index cf8ac1bc55b81c7713d1d732d306491b065053d8..416784b5b334d87497a69103584c367e29320387 100644 (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>
 
index 5346ce467a86c456bfd311b67812a29f8259b752..4fccb531309792acb6c86e8c72ebeb0fc9a5cfda 100644 (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;
index 7b7fa03e8c432fcda9c0dd09a356a6da07809c60..f265994301013df181fb94cc50893113f3855b52 100644 (file)
@@ -26,7 +26,6 @@
 #include <string.h>
 
 #include <haproxy/api.h>
-#include <haproxy/thread-t.h>
 
 #ifdef USE_PCRE
 #include <pcre.h>
index 6d84ea6138bebf2b82f283f178558b5ca290e2ee..e093051a6d5083fc2eba2bbcc3baf1b7cced7301 100644 (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];
 
index 20c84ded0394a9155bf8534dd4d1fcf0548b98b7..2861d40d436160e218d7ac30544dc992c2cadf00 100644 (file)
 
 /********************** 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)
 
 /********************** THREADS ENABLED ************************/
 
-#define THREAD_LOCAL __thread
-
-#define __decl_thread(decl) decl
-
 /* declare a self-initializing spinlock */
 #define __decl_spinlock(lock)                               \
        HA_SPINLOCK_T (lock);                               \
index ae5a3c189b9806120e8bb671b818cc31b9f299fd..596b70646d4bb315c17113bb1bfd29cd0a995a69 100644 (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>
 
index 50fe1eb8252a6a7f5fd1ba197353f79707538294..903f0732379666691229835c80ae11bdd847c7e8 100644 (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)
 {
index b79db740a0e9faedd83f56b4d48ec7a08a497095..8096988bd89d8f2a27e1d4b13ad36b0b4f15ecca 100644 (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>
index 81cbe5138f01d5ec8001cf20ed06603ca87a9c4b..cbb1bc8fd33eb7dc30665765518ba3b0390be485 100644 (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>
 
index e1d74d6b22426ebaf4838fa46e503246cfb34d65..c699fe23ce251f8be4ccc349aa43fcb78b1ae03d 100644 (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>
 
index 8781e6c0d0184b8760e09a9cc08e26fb586cc038..53ae81ffe74a737fb194d3f1e5c0d2ed0a633cfb 100644 (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>
 
index cee5e8e70fc4420dd709cd668c4453e6b382757f..bf69f35fdfa214c285e5daa45745cc2ad7a99395 100644 (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>
 
index f81ffff57b63b889b1c6eb5c64bdb8f599a8dbee..9c99fd53099c48bd6e4b05500df1a8ac978a825c 100644 (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) */