REORG: include: split hathreads into haproxy/thread.h and haproxy/thread-t.h

This splits the hathreads.h file into types+macros and functions. Given
that most users of this file used to include it only to get the definition
of THREAD_LOCAL and MAXTHREADS, the bare minimum was placed into thread-t.h
(i.e. types and macros).

All the thread management was left to haproxy/thread.h. It's worth noting
the drop of the trailing "s" in the name, to remove the permanent confusion
that arises between this one and the system implementation (no "s") and the
makefile's option (no "s").

For consistency, src/hathreads.c was also renamed thread.c.

A number of files were updated to only include thread-t which is the one
they really needed.

Some future improvements are possible like replacing empty inlined
functions with macros for the thread-less case, as building at -O0 disables
inlining and causes these ones to be emitted. But this really is cosmetic.
diff --git a/src/51d.c b/src/51d.c
index ceef355..6d3e86f 100644
--- a/src/51d.c
+++ b/src/51d.c
@@ -5,7 +5,7 @@
 #include <common/chunk.h>
 #include <common/buffer.h>
 #include <haproxy/errors.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 #include <types/global.h>
 #include <proto/arg.h>
 #include <proto/http_fetch.h>
diff --git a/src/activity.c b/src/activity.c
index 6da8f40..e9a66fc 100644
--- a/src/activity.c
+++ b/src/activity.c
@@ -13,7 +13,7 @@
 #include <haproxy/api.h>
 #include <common/cfgparse.h>
 #include <common/standard.h>
-#include <common/hathreads.h>
+#include <haproxy/thread-t.h>
 #include <types/activity.h>
 #include <proto/channel.h>
 #include <proto/cli.h>
diff --git a/src/auth.c b/src/auth.c
index 6570eca..4decf84 100644
--- a/src/auth.c
+++ b/src/auth.c
@@ -28,7 +28,7 @@
 #include <haproxy/api.h>
 #include <types/global.h>
 #include <haproxy/errors.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 
 #include <proto/acl.h>
 #include <proto/log.h>
diff --git a/src/cfgparse.c b/src/cfgparse.c
index da76aa9..f4de78a 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -42,7 +42,7 @@
 #include <common/time.h>
 #include <common/uri_auth.h>
 #include <common/namespace.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 
 #include <types/capture.h>
 #include <types/filters.h>
diff --git a/src/checks.c b/src/checks.c
index 5dbbeca..92f1e4a 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -36,7 +36,7 @@
 #include <haproxy/list.h>
 #include <common/standard.h>
 #include <common/time.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 #include <common/http.h>
 #include <common/h1.h>
 #include <common/htx.h>
diff --git a/src/compression.c b/src/compression.c
index 5797a06..a63eeef 100644
--- a/src/compression.c
+++ b/src/compression.c
@@ -28,7 +28,7 @@
 
 #include <haproxy/api.h>
 #include <common/cfgparse.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 #include <common/memory.h>
 
 #include <types/global.h>
diff --git a/src/debug.c b/src/debug.c
index cf77c5b..4017232 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -22,7 +22,7 @@
 #include <haproxy/api.h>
 #include <haproxy/buf.h>
 #include <haproxy/debug.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 #include <import/ist.h>
 #include <common/net_helper.h>
 #include <common/standard.h>
diff --git a/src/ev_epoll.c b/src/ev_epoll.c
index 91670af..132d487 100644
--- a/src/ev_epoll.c
+++ b/src/ev_epoll.c
@@ -15,7 +15,7 @@
 #include <sys/types.h>
 
 #include <haproxy/api.h>
-#include <common/hathreads.h>
+#include <haproxy/thread-t.h>
 #include <common/standard.h>
 #include <common/ticks.h>
 #include <common/time.h>
diff --git a/src/ev_evports.c b/src/ev_evports.c
index c0005e1..e440f15 100644
--- a/src/ev_evports.c
+++ b/src/ev_evports.c
@@ -19,7 +19,7 @@
 #include <syslog.h>
 
 #include <haproxy/api.h>
-#include <common/hathreads.h>
+#include <haproxy/thread-t.h>
 #include <common/ticks.h>
 #include <common/time.h>
 
diff --git a/src/ev_kqueue.c b/src/ev_kqueue.c
index e9821bd..5b14d51 100644
--- a/src/ev_kqueue.c
+++ b/src/ev_kqueue.c
@@ -18,7 +18,7 @@
 #include <sys/time.h>
 
 #include <haproxy/api.h>
-#include <common/hathreads.h>
+#include <haproxy/thread-t.h>
 #include <common/ticks.h>
 #include <common/time.h>
 
diff --git a/src/ev_poll.c b/src/ev_poll.c
index 0e6dc94..c3c52f0 100644
--- a/src/ev_poll.c
+++ b/src/ev_poll.c
@@ -18,7 +18,7 @@
 #include <sys/types.h>
 
 #include <haproxy/api.h>
-#include <common/hathreads.h>
+#include <haproxy/thread-t.h>
 #include <common/ticks.h>
 #include <common/time.h>
 
diff --git a/src/ev_select.c b/src/ev_select.c
index 9dd93b8..3b02bed 100644
--- a/src/ev_select.c
+++ b/src/ev_select.c
@@ -15,7 +15,7 @@
 #include <sys/types.h>
 
 #include <haproxy/api.h>
-#include <common/hathreads.h>
+#include <haproxy/thread-t.h>
 #include <common/ticks.h>
 #include <common/time.h>
 
diff --git a/src/flt_spoe.c b/src/flt_spoe.c
index 9bd6ab1..7021e55 100644
--- a/src/flt_spoe.c
+++ b/src/flt_spoe.c
@@ -14,7 +14,7 @@
 
 #include <haproxy/api.h>
 #include <common/cfgparse.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 #include <common/memory.h>
 #include <common/time.h>
 
diff --git a/src/haproxy.c b/src/haproxy.c
index a1dff0c..b1853cf 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -95,7 +95,7 @@
 #include <common/time.h>
 #include <common/uri_auth.h>
 #include <haproxy/version.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 
 #include <types/capture.h>
 #include <types/cli.h>
diff --git a/src/hlua.c b/src/hlua.c
index 15c34cd..84fcf8b 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -25,7 +25,7 @@
 #include <import/ebpttree.h>
 
 #include <common/cfgparse.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 #include <common/xref.h>
 #include <common/h1.h>
 
diff --git a/src/memory.c b/src/memory.c
index 2caf13d..0bca712 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -18,7 +18,7 @@
 #include <types/stats.h>
 
 #include <common/cfgparse.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 #include <common/memory.h>
 #include <haproxy/list.h>
 #include <common/standard.h>
diff --git a/src/peers.c b/src/peers.c
index e530760..6d5a5de 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -24,7 +24,7 @@
 #include <common/net_helper.h>
 #include <common/time.h>
 #include <common/standard.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 
 #include <types/global.h>
 #include <types/listener.h>
diff --git a/src/pipe.c b/src/pipe.c
index b088820..8c82821 100644
--- a/src/pipe.c
+++ b/src/pipe.c
@@ -14,7 +14,7 @@
 #include <fcntl.h>
 
 #include <haproxy/api.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 #include <common/memory.h>
 
 #include <types/global.h>
diff --git a/src/queue.c b/src/queue.c
index 3c50076..f2407ed 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -72,7 +72,7 @@
 #include <haproxy/api.h>
 #include <common/memory.h>
 #include <common/time.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 #include <import/eb32tree.h>
 
 #include <proto/http_rules.h>
diff --git a/src/ring.c b/src/ring.c
index d10ebd7..ee72bb1 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -21,7 +21,7 @@
 #include <stdlib.h>
 #include <haproxy/api.h>
 #include <haproxy/buf.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 #include <types/applet.h>
 #include <proto/cli.h>
 #include <proto/ring.h>
diff --git a/src/stream.c b/src/stream.c
index 0c03037..7b5620f 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -17,7 +17,7 @@
 #include <haproxy/api.h>
 #include <common/cfgparse.h>
 #include <common/buffer.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 #include <common/htx.h>
 #include <common/memory.h>
 
diff --git a/src/hathreads.c b/src/thread.c
similarity index 98%
rename from src/hathreads.c
rename to src/thread.c
index 14c5658..47c5ab9 100644
--- a/src/hathreads.c
+++ b/src/thread.c
@@ -24,7 +24,7 @@
 #endif
 
 #include <common/cfgparse.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 #include <common/standard.h>
 #include <types/global.h>
 #include <proto/fd.h>
@@ -190,7 +190,7 @@
 }
 
 __attribute__((constructor))
-static void __hathreads_init(void)
+static void __thread_init(void)
 {
 	char *ptr = NULL;
 
diff --git a/src/time.c b/src/time.c
index 5c8ed4b..86c2469 100644
--- a/src/time.c
+++ b/src/time.c
@@ -16,7 +16,7 @@
 #include <haproxy/api.h>
 #include <common/standard.h>
 #include <common/time.h>
-#include <common/hathreads.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) */
diff --git a/src/wdt.c b/src/wdt.c
index 2d03b4a..86de286 100644
--- a/src/wdt.c
+++ b/src/wdt.c
@@ -14,7 +14,7 @@
 
 #include <haproxy/api.h>
 #include <haproxy/debug.h>
-#include <common/hathreads.h>
+#include <haproxy/thread.h>
 #include <common/standard.h>
 #include <types/global.h>
 #include <types/signal.h>