#include <common/config.h>
-#define MAX_THREADS_MASK ((unsigned long)-1)
-extern THREAD_LOCAL unsigned int tid; /* The thread id */
-extern THREAD_LOCAL unsigned long tid_bit; /* The bit corresponding to the thread id */
-
/* Note about all_threads_mask :
* - with threads support disabled, this symbol is defined as zero (0UL).
* - with threads enabled, this variable is never zero, it contains the mask
#ifndef USE_THREAD
#define MAX_THREADS 1
-#define all_threads_mask 0UL
+#define MAX_THREADS_MASK 1
+
+/* Only way found to replace variables with constants that are optimized away
+ * at build time.
+ */
+enum { all_threads_mask = 1UL };
+enum { tid_bit = 1UL };
+enum { tid = 0 };
#define __decl_hathreads(decl)
#define ha_sigmask(how, set, oldset) sigprocmask(how, set, oldset)
+static inline void ha_set_tid(unsigned int tid)
+{
+}
static inline void __ha_barrier_load(void)
{
#include <import/plock.h>
#define MAX_THREADS LONGBITS
+#define MAX_THREADS_MASK ((unsigned long)-1)
#define __decl_hathreads(decl) decl
int thread_no_sync(void);
int thread_need_sync(void);
+extern THREAD_LOCAL unsigned int tid; /* The thread id */
+extern THREAD_LOCAL unsigned long tid_bit; /* The bit corresponding to the thread id */
extern volatile unsigned long all_threads_mask;
#define ha_sigmask(how, set, oldset) pthread_sigmask(how, set, oldset)
+/* sets the thread ID and the TID bit for the current thread */
+static inline void ha_set_tid(unsigned int data)
+{
+ tid = data;
+ tid_bit = (1UL << tid);
+}
+
#if defined(DEBUG_THREAD) || defined(DEBUG_FULL)
nbproc = my_ffsl(bind_conf->bind_proc);
mask = bind_conf->bind_thread[nbproc - 1];
- if (mask && !(mask & (all_threads_mask ? all_threads_mask : 1UL))) {
+ if (mask && !(mask & all_threads_mask)) {
unsigned long new_mask = 0;
while (mask) {
- new_mask |= mask & (all_threads_mask ? all_threads_mask : 1UL);
+ new_mask |= mask & all_threads_mask;
mask >>= global.nbthread;
}
struct per_thread_deinit_fct *ptdf;
__decl_hathreads(static HA_SPINLOCK_T start_lock);
- tid = *((unsigned int *)data);
- tid_bit = (1UL << tid);
+ ha_set_tid(*((unsigned int *)data));
tv_update_date(-1,-1);
list_for_each_entry(ptif, &per_thread_init_list, list) {
#include <common/standard.h>
#include <proto/fd.h>
-THREAD_LOCAL unsigned int tid = 0;
-THREAD_LOCAL unsigned long tid_bit = (1UL << 0);
/* Dummy I/O handler used by the sync pipe.*/
void thread_sync_io_handler(int fd)
static int threads_sync_pipe[2];
static unsigned long threads_want_sync = 0;
volatile unsigned long all_threads_mask = 1; // nbthread 1 assumed by default
+THREAD_LOCAL unsigned int tid = 0;
+THREAD_LOCAL unsigned long tid_bit = (1UL << 0);
+
#if defined(DEBUG_THREAD) || defined(DEBUG_FULL)
struct lock_stat lock_stats[LOCK_LABELS];
{
static volatile unsigned long barrier = 0;
- if (!all_threads_mask)
+ if (!(all_threads_mask & (all_threads_mask - 1)))
return;
thread_sync_barrier(&barrier);
{
static volatile unsigned long barrier = 0;
- if (!all_threads_mask)
+ if (!(all_threads_mask & (all_threads_mask - 1)))
return;
if (threads_want_sync & tid_bit)