]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: include: move MAX_THREADS to defaults.h
authorWilly Tarreau <w@1wt.eu>
Thu, 11 Jun 2020 06:14:01 +0000 (08:14 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 11 Jun 2020 08:18:59 +0000 (10:18 +0200)
That's already where MAX_PROCS is set, and we already handle the case of
the default value so there is no reason for placing it in thread.h given
that most call places don't need the rest of the threads definitions. The
include was removed from global-t.h and activity.c.

include/haproxy/defaults.h
include/haproxy/global-t.h
include/haproxy/thread-t.h
src/activity.c

index ef393dcb373fb92e4e19f5b26e81b114e2a9d28d..ae4def1ffc89dc85304a6a36b168064d1e2ce52f 100644 (file)
 #define MAX_PROCS LONGBITS
 #endif
 
+/* MAX_THREADS defines the highest limit for the global nbthread value. It
+ * defaults to the number of bits in a long integer when threads are enabled
+ * but may be lowered to save resources on embedded systems.
+*/
+#ifndef USE_THREAD
+/* threads disabled, 1 thread max */
+#define MAX_THREADS 1
+#define MAX_THREADS_MASK 1
+
+#else
+/* threads enabled, max_threads defaults to long bits */
+#ifndef MAX_THREADS
+#define MAX_THREADS LONGBITS
+#endif
+#define MAX_THREADS_MASK (~0UL >> (LONGBITS - MAX_THREADS))
+#endif
+
 /*
  * BUFSIZE defines the size of a read and write buffer. It is the maximum
  * amount of bytes which can be stored by the proxy for each stream. However,
index bee8de7a982df6bbf0e2720bdf2e0b35cc8edb43..9cf30fa7dcdad189ae9bcff1c6b2f98e40c8bdb0 100644 (file)
@@ -25,7 +25,6 @@
 #include <haproxy/buf-t.h>
 #include <haproxy/freq_ctr-t.h>
 #include <haproxy/list-t.h>
-#include <haproxy/thread-t.h>
 #include <haproxy/api-t.h>
 #include <haproxy/vars-t.h>
 
index d54ec844693d9cf4bbd46ee0c46899513a5c4599..20c84ded0394a9155bf8534dd4d1fcf0548b98b7 100644 (file)
@@ -28,6 +28,7 @@
 #endif
 #include <time.h>
 
+#include <haproxy/defaults.h>
 
 /* Note: this file mainly contains 3 sections:
  *   - one used solely when USE_THREAD is *not* set
@@ -40,8 +41,6 @@
 /********************** THREADS DISABLED ************************/
 
 #define THREAD_LOCAL  /* empty */
-#define MAX_THREADS 1
-#define MAX_THREADS_MASK 1
 
 /* These macros allow to make some struct fields or local variables optional */
 #define __decl_thread(decl)
 
 #define THREAD_LOCAL __thread
 
-#ifndef MAX_THREADS
-#define MAX_THREADS LONGBITS
-#endif
-
-#define MAX_THREADS_MASK (~0UL >> (LONGBITS - MAX_THREADS))
-
 #define __decl_thread(decl) decl
 
 /* declare a self-initializing spinlock */
index 17eb13c1a1b3ba18c358c4b5d5ee4c7ab01e32d4..5ef38c969eca1194d7225a56572a3ae792be4cfb 100644 (file)
@@ -16,7 +16,6 @@
 #include <haproxy/cli.h>
 #include <haproxy/stream_interface.h>
 #include <haproxy/tools.h>
-#include <haproxy/thread-t.h>
 #include <haproxy/activity-t.h>
 #include <haproxy/freq_ctr.h>