MINOR: threads: add a MAX_THREADS define instead of LONGBITS

This one allows not to inflate some structures when threads are
disabled. Now struct global is 1.4 kB instead of 33 kB.

Should be backported to 1.8 for ease of backporting of upcoming
patches.
diff --git a/include/common/hathreads.h b/include/common/hathreads.h
index 5f0b969..f819536 100644
--- a/include/common/hathreads.h
+++ b/include/common/hathreads.h
@@ -30,6 +30,8 @@
 
 #ifndef USE_THREAD
 
+#define MAX_THREADS 1
+
 #define __decl_hathreads(decl)
 
 #define HA_ATOMIC_CAS(val, old, new) ({((*val) == (*old)) ? (*(val) = (new) , 1) : (*(old) = *(val), 0);})
@@ -95,6 +97,8 @@
 #include <pthread.h>
 #include <import/plock.h>
 
+#define MAX_THREADS LONGBITS
+
 #define __decl_hathreads(decl) decl
 
 /* TODO: thread: For now, we rely on GCC builtins but it could be a good idea to
diff --git a/include/types/global.h b/include/types/global.h
index 6f3fedc..5c5cf73 100644
--- a/include/types/global.h
+++ b/include/types/global.h
@@ -168,7 +168,7 @@
 #ifdef USE_CPU_AFFINITY
 	struct {
 		unsigned long proc[LONGBITS];             /* list of CPU masks for the 32/64 first processes */
-		unsigned long thread[LONGBITS][LONGBITS]; /* list of CPU masks for the 32/64 first threads per process */
+		unsigned long thread[LONGBITS][MAX_THREADS]; /* list of CPU masks for the 32/64 first threads per process */
 	} cpu_map;
 #endif
 };
diff --git a/src/cfgparse.c b/src/cfgparse.c
index baf9e60..eea820a 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -1175,12 +1175,6 @@
 			goto out;
 		}
 		global.nbthread = atol(args[1]);
-		if (global.nbthread < 1 || global.nbthread > LONGBITS) {
-			ha_alert("parsing [%s:%d] : '%s' must be between 1 and %d (was %d).\n",
-				 file, linenum, args[0], LONGBITS, global.nbthread);
-			err_code |= ERR_ALERT | ERR_FATAL;
-			goto out;
-		}
 #ifndef USE_THREAD
 		if (global.nbthread > 1) {
 			ha_alert("HAProxy is not compiled with threads support, please check build options for USE_THREAD.\n");
@@ -1189,6 +1183,12 @@
 			goto out;
 		}
 #endif
+		if (global.nbthread < 1 || global.nbthread > MAX_THREADS) {
+			ha_alert("parsing [%s:%d] : '%s' must be between 1 and %d (was %d).\n",
+				 file, linenum, args[0], MAX_THREADS, global.nbthread);
+			err_code |= ERR_ALERT | ERR_FATAL;
+			goto out;
+		}
 	}
 	else if (!strcmp(args[0], "maxconn")) {
 		if (alertif_too_many_args(1, file, linenum, args, &err_code))
@@ -1801,7 +1801,7 @@
 			}
 
 			/* Mapping at the thread level */
-			for (j = 0; j < LONGBITS; j++) {
+			for (j = 0; j < MAX_THREADS; j++) {
 				/* Np mapping for this thread */
 				if (!(thread & (1UL << j)))
 					continue;
diff --git a/src/haproxy.c b/src/haproxy.c
index 20b18f8..a8d0fad 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -2986,7 +2986,7 @@
 			if (global.cpu_map.proc[relative_pid-1])
 				global.cpu_map.thread[relative_pid-1][i] &= global.cpu_map.proc[relative_pid-1];
 
-			if (i < LONGBITS &&       /* only the first 32/64 threads may be pinned */
+			if (i < MAX_THREADS &&       /* only the first 32/64 threads may be pinned */
 			    global.cpu_map.thread[relative_pid-1][i]) {/* only do this if the thread has a THREAD map */
 #if defined(__FreeBSD__) || defined(__NetBSD__)
 				cpuset_t cpuset;
diff --git a/src/listener.c b/src/listener.c
index dfd36cc..fd70726 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -963,7 +963,7 @@
 
 	conf->bind_proc |= proc;
 	if (thread) {
-		for (i = 0; i < LONGBITS; i++)
+		for (i = 0; i < MAX_THREADS; i++)
 			if (!proc || (proc & (1UL << i)))
 				conf->bind_thread[i] |= thread;
 	}