REORG: thread: move ha_get_pthread_id() to thread.c
It's the last function which directly accesses the pthread_t, let's move
it to thread.c and leave a static inline for non-thread.
diff --git a/include/haproxy/thread.h b/include/haproxy/thread.h
index a8b0478..1881fa9 100644
--- a/include/haproxy/thread.h
+++ b/include/haproxy/thread.h
@@ -163,6 +163,11 @@
{
}
+static inline unsigned long long ha_get_pthread_id(unsigned int thr)
+{
+ return 0;
+}
+
#else /* !USE_THREAD */
/********************** THREADS ENABLED ************************/
@@ -181,6 +186,7 @@
void setup_extra_threads(void *(*handler)(void *));
void wait_for_threads_completion();
void set_thread_cpu_affinity();
+unsigned long long ha_get_pthread_id(unsigned int thr);
extern volatile unsigned long all_threads_mask;
extern volatile unsigned long threads_harmless_mask;
diff --git a/include/haproxy/tinfo.h b/include/haproxy/tinfo.h
index 40b64b0..be6cddf 100644
--- a/include/haproxy/tinfo.h
+++ b/include/haproxy/tinfo.h
@@ -29,38 +29,4 @@
extern struct thread_info ha_thread_info[MAX_THREADS];
extern THREAD_LOCAL struct thread_info *ti; /* thread_info for the current thread */
-/* Retrieves the opaque pthread_t of thread <thr> cast to an unsigned long long
- * since POSIX took great care of not specifying its representation, making it
- * hard to export for post-mortem analysis. For this reason we copy it into a
- * union and will use the smallest scalar type at least as large as its size,
- * which will keep endianness and alignment for all regular sizes. As a last
- * resort we end up with a long long ligned to the first bytes in memory, which
- * will be endian-dependent if pthread_t is larger than a long long (not seen
- * yet).
- */
-static inline unsigned long long ha_get_pthread_id(unsigned int thr)
-{
-#ifdef USE_THREAD
- union {
- pthread_t t;
- unsigned long long ll;
- unsigned int i;
- unsigned short s;
- unsigned char c;
- } u = { 0 };
-
- u.t = ha_thread_info[thr].pthread;
-
- if (sizeof(u.t) <= sizeof(u.c))
- return u.c;
- else if (sizeof(u.t) <= sizeof(u.s))
- return u.s;
- else if (sizeof(u.t) <= sizeof(u.i))
- return u.i;
- return u.ll;
-#else
- return 0;
-#endif
-}
-
#endif /* _HAPROXY_TINFO_H */
diff --git a/src/thread.c b/src/thread.c
index 25ee3ab..c0b7bdb 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -254,6 +254,36 @@
#endif /* USE_CPU_AFFINITY */
}
+/* Retrieves the opaque pthread_t of thread <thr> cast to an unsigned long long
+ * since POSIX took great care of not specifying its representation, making it
+ * hard to export for post-mortem analysis. For this reason we copy it into a
+ * union and will use the smallest scalar type at least as large as its size,
+ * which will keep endianness and alignment for all regular sizes. As a last
+ * resort we end up with a long long ligned to the first bytes in memory, which
+ * will be endian-dependent if pthread_t is larger than a long long (not seen
+ * yet).
+ */
+unsigned long long ha_get_pthread_id(unsigned int thr)
+{
+ union {
+ pthread_t t;
+ unsigned long long ll;
+ unsigned int i;
+ unsigned short s;
+ unsigned char c;
+ } u = { 0 };
+
+ u.t = ha_thread_info[thr].pthread;
+
+ if (sizeof(u.t) <= sizeof(u.c))
+ return u.c;
+ else if (sizeof(u.t) <= sizeof(u.s))
+ return u.s;
+ else if (sizeof(u.t) <= sizeof(u.i))
+ return u.i;
+ return u.ll;
+}
+
/* send signal <sig> to thread <thr> */
void ha_tkill(unsigned int thr, int sig)
{