From a92c5cec2d60caaabc8b6b741a8676e02d254e24 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Fri, 13 Sep 2019 05:03:12 +0100 Subject: [PATCH] BUILD/MEDIUM: threads: rename thread_info struct to ha_thread_info On Darwin, the thread_info name exists as a standard function thus we need to rename our array to ha_thread_info to fix this conflict. --- include/common/hathreads.h | 10 +++++----- src/debug.c | 6 +++--- src/haproxy.c | 8 ++++---- src/hathreads.c | 8 ++++---- src/wdt.c | 12 ++++++------ 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/include/common/hathreads.h b/include/common/hathreads.h index 8e780142c..02568de12 100644 --- a/include/common/hathreads.h +++ b/include/common/hathreads.h @@ -38,7 +38,7 @@ * only one thread is enabled, it equals 1. */ -/* thread info flags, for thread_info[].flags */ +/* thread info flags, for ha_thread_info[].flags */ #define TI_FL_STUCK 0x00000001 @@ -67,7 +67,7 @@ extern struct thread_info { /* pad to cache line (64B) */ char __pad[0]; /* unused except to check remaining room */ char __end[0] __attribute__((aligned(64))); -} thread_info[MAX_THREADS]; +} ha_thread_info[MAX_THREADS]; extern THREAD_LOCAL struct thread_info *ti; /* thread_info for the current thread */ @@ -167,7 +167,7 @@ extern THREAD_LOCAL struct thread_info *ti; /* thread_info for the current threa static inline void ha_set_tid(unsigned int tid) { - ti = &thread_info[tid]; + ti = &ha_thread_info[tid]; } static inline void ha_thread_relax(void) @@ -437,7 +437,7 @@ extern struct thread_info { /* pad to cache line (64B) */ char __pad[0]; /* unused except to check remaining room */ char __end[0] __attribute__((aligned(64))); -} thread_info[MAX_THREADS]; +} ha_thread_info[MAX_THREADS]; extern THREAD_LOCAL unsigned int tid; /* The thread id */ extern THREAD_LOCAL unsigned long tid_bit; /* The bit corresponding to the thread id */ @@ -480,7 +480,7 @@ static inline void ha_set_tid(unsigned int data) { tid = data; tid_bit = (1UL << tid); - ti = &thread_info[tid]; + ti = &ha_thread_info[tid]; } static inline void ha_thread_relax(void) diff --git a/src/debug.c b/src/debug.c index 5c4aa880a..8dbc41848 100644 --- a/src/debug.c +++ b/src/debug.c @@ -45,9 +45,9 @@ volatile unsigned long threads_to_dump = 0; void ha_thread_dump(struct buffer *buf, int thr, int calling_tid) { unsigned long thr_bit = 1UL << thr; - unsigned long long p = thread_info[thr].prev_cpu_time; - unsigned long long n = now_cpu_time_thread(&thread_info[thr]); - int stuck = !!(thread_info[thr].flags & TI_FL_STUCK); + unsigned long long p = ha_thread_info[thr].prev_cpu_time; + unsigned long long n = now_cpu_time_thread(&ha_thread_info[thr]); + int stuck = !!(ha_thread_info[thr].flags & TI_FL_STUCK); chunk_appendf(buf, "%c%cThread %-2u: act=%d glob=%d wq=%d rq=%d tl=%d tlsz=%d rqsz=%d\n" diff --git a/src/haproxy.c b/src/haproxy.c index 05b0afa32..db6f21f56 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -3362,9 +3362,9 @@ int main(int argc, char **argv) pthread_sigmask(SIG_SETMASK, &blocked_sig, &old_sig); /* Create nbthread-1 thread. The first thread is the current process */ - thread_info[0].pthread = pthread_self(); + ha_thread_info[0].pthread = pthread_self(); for (i = 1; i < global.nbthread; i++) - pthread_create(&thread_info[i].pthread, NULL, &run_thread_poll_loop, (void *)(long)i); + pthread_create(&ha_thread_info[i].pthread, NULL, &run_thread_poll_loop, (void *)(long)i); #ifdef USE_CPU_AFFINITY /* Now the CPU affinity for all threads */ @@ -3391,7 +3391,7 @@ int main(int argc, char **argv) CPU_SET(j - 1, &cpuset); cpu_map &= ~(1UL << (j - 1)); } - pthread_setaffinity_np(thread_info[i].pthread, + pthread_setaffinity_np(ha_thread_info[i].pthread, sizeof(cpuset), &cpuset); } } @@ -3405,7 +3405,7 @@ int main(int argc, char **argv) /* Wait the end of other threads */ for (i = 1; i < global.nbthread; i++) - pthread_join(thread_info[i].pthread, NULL); + pthread_join(ha_thread_info[i].pthread, NULL); #if defined(DEBUG_THREAD) || defined(DEBUG_FULL) show_lock_stats(); diff --git a/src/hathreads.c b/src/hathreads.c index 693852367..14c565897 100644 --- a/src/hathreads.c +++ b/src/hathreads.c @@ -29,8 +29,8 @@ #include #include -struct thread_info thread_info[MAX_THREADS] = { }; -THREAD_LOCAL struct thread_info *ti = &thread_info[0]; +struct thread_info ha_thread_info[MAX_THREADS] = { }; +THREAD_LOCAL struct thread_info *ti = &ha_thread_info[0]; #ifdef USE_THREAD @@ -134,7 +134,7 @@ void thread_sync_release() /* send signal to thread */ void ha_tkill(unsigned int thr, int sig) { - pthread_kill(thread_info[thr].pthread, sig); + pthread_kill(ha_thread_info[thr].pthread, sig); } /* send signal to all threads. The calling thread is signaled last in @@ -149,7 +149,7 @@ void ha_tkillall(int sig) continue; if (thr == tid) continue; - pthread_kill(thread_info[thr].pthread, sig); + pthread_kill(ha_thread_info[thr].pthread, sig); } raise(sig); } diff --git a/src/wdt.c b/src/wdt.c index aa89fd443..8f31e9492 100644 --- a/src/wdt.c +++ b/src/wdt.c @@ -43,7 +43,7 @@ int wdt_ping(int thr) its.it_value.tv_sec = 1; its.it_value.tv_nsec = 0; its.it_interval.tv_sec = 0; its.it_interval.tv_nsec = 0; - return timer_settime(thread_info[thr].wd_timer, 0, &its, NULL) == 0; + return timer_settime(ha_thread_info[thr].wd_timer, 0, &its, NULL) == 0; } /* This is the WDTSIG signal handler */ @@ -68,8 +68,8 @@ void wdt_handler(int sig, siginfo_t *si, void *arg) if (thr < 0 || thr >= global.nbthread) break; - p = thread_info[thr].prev_cpu_time; - n = now_cpu_time_thread(&thread_info[thr]); + p = ha_thread_info[thr].prev_cpu_time; + n = now_cpu_time_thread(&ha_thread_info[thr]); /* not yet reached the deadline of 1 sec */ if (n - p < 1000000000UL) @@ -94,8 +94,8 @@ void wdt_handler(int sig, siginfo_t *si, void *arg) * If it's already set, then it's our second call with no * progress and the thread is dead. */ - if (!(thread_info[thr].flags & TI_FL_STUCK)) { - _HA_ATOMIC_OR(&thread_info[thr].flags, TI_FL_STUCK); + if (!(ha_thread_info[thr].flags & TI_FL_STUCK)) { + _HA_ATOMIC_OR(&ha_thread_info[thr].flags, TI_FL_STUCK); goto update_and_leave; } @@ -118,7 +118,7 @@ void wdt_handler(int sig, siginfo_t *si, void *arg) * the current one not involved in this. */ if (thr != tid) - pthread_kill(thread_info[thr].pthread, sig); + pthread_kill(ha_thread_info[thr].pthread, sig); else ha_panic(); return;