REORG: clock: move the clock_id initialization to clock.c

This was previously open-coded in run_thread_poll_loop(). Now that
we have clock.c dedicated to such stuff, let's move the code there
so that we don't need to keep such ifdefs nor to depend on the
clock_id.
diff --git a/include/haproxy/clock.h b/include/haproxy/clock.h
index 73d4ef3..77fd7ec 100644
--- a/include/haproxy/clock.h
+++ b/include/haproxy/clock.h
@@ -35,6 +35,7 @@
 uint64_t now_cpu_time_thread(const struct thread_info *thr);
 uint64_t now_mono_time(void);
 uint64_t now_cpu_time(void);
+void clock_set_local_source(void);
 void clock_update_date(int max_wait, int interrupted);
 void clock_init_process_date(void);
 void clock_init_thread_date(void);
diff --git a/src/clock.c b/src/clock.c
index ccb59c3..5a3447f 100644
--- a/src/clock.c
+++ b/src/clock.c
@@ -13,6 +13,10 @@
 #include <sys/time.h>
 #include <time.h>
 
+#ifdef USE_THREAD
+#include <pthread.h>
+#endif
+
 #include <haproxy/api.h>
 #include <haproxy/activity.h>
 #include <haproxy/clock.h>
@@ -73,6 +77,18 @@
 	return ret;
 }
 
+/* set the clock source for the local thread */
+void clock_set_local_source(void)
+{
+#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) && defined(_POSIX_THREAD_CPUTIME)
+#ifdef USE_THREAD
+	pthread_getcpuclockid(pthread_self(), &ti->clock_id);
+#else
+	ti->clock_id = CLOCK_THREAD_CPUTIME_ID;
+#endif
+#endif
+}
+
 /* clock_update_date: sets <date> to system time, and sets <now> to something as
  * close as possible to real time, following a monotonic function. The main
  * principle consists in detecting backwards and forwards time jumps and adjust
diff --git a/src/haproxy.c b/src/haproxy.c
index 618efb3..885cc26 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -2700,14 +2700,8 @@
 	ha_set_tid((unsigned long)data);
 	set_thread_cpu_affinity();
 	sched = &task_per_thread[tid];
+	clock_set_local_source();
 
-#if (_POSIX_TIMERS > 0) && defined(_POSIX_THREAD_CPUTIME)
-#ifdef USE_THREAD
-	pthread_getcpuclockid(pthread_self(), &ti->clock_id);
-#else
-	ti->clock_id = CLOCK_THREAD_CPUTIME_ID;
-#endif
-#endif
 	/* Now, initialize one thread init at a time. This is better since
 	 * some init code is a bit tricky and may release global resources
 	 * after reallocating them locally. This will also ensure there is