__decl_thread() already exists but is more suited for struct members.
When using it in a variables block, it appends the final trailing
semi-colon which is a statement that ends the variable block. Better
clean this up and have one precisely for variable blocks. In this
case we can simply define an unused enum value that will consume the
semi-colon. That's what the new macro __decl_thread_var() does.
(cherry picked from commit
69ac4cd315f05c69f3c34f824ef4e7f3221966cf)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit
f7f2c888b113a3789a4c794f3380c8696e3bbf31)
Signed-off-by: Willy Tarreau <w@1wt.eu>
#define __decl_thread(decl)
#endif
+/* The __decl_thread_var() statement declares a variable when threads are enabled
+ * or replaces it with an dummy statement to avoid placing a lone semi-colon. The
+ * purpose is to condition the presence of some variables or to the fact that
+ * threads are enabled, without having to enclose them inside an ugly
+ * #ifdef USE_THREAD/#endif clause.
+ */
+#ifdef USE_THREAD
+#define __decl_thread_var(decl) decl
+#else
+#define __decl_thread_var(decl) enum { CONCAT(_dummy_var_decl_,__LINE__), }
+#endif
+
/* clang has a __has_feature() macro which reports true/false on a number of
* internally supported features. Let's make sure this macro is always defined
* and returns zero when not supported.