[master] c6ee37a57 param: Declare bits parameters in the include table
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Mon May 30 14:04:06 UTC 2022
commit c6ee37a572ca17b78dde9c8fbdc7aee3270dfc1e
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date: Fri Mar 11 18:24:56 2022 +0100
param: Declare bits parameters in the include table
With the help of PARAM_PRE and PARAM_POST macros we can deal with the
include tables bits included by the params include tables without the
nested macro evaluation limitation.
diff --git a/bin/varnishd/common/common_param.h b/bin/varnishd/common/common_param.h
index 201bfd381..4a34dfa4f 100644
--- a/bin/varnishd/common/common_param.h
+++ b/bin/varnishd/common/common_param.h
@@ -95,13 +95,17 @@ struct params {
#define ptyp_boolean unsigned
#define ptyp_bytes ssize_t
#define ptyp_bytes_u unsigned
+#define ptyp_debug debug_t
#define ptyp_double double
+#define ptyp_experimental experimental_t
+#define ptyp_feature feature_t
#define ptyp_poolparam struct poolparam
#define ptyp_thread_pool_max unsigned
#define ptyp_thread_pool_min unsigned
#define ptyp_timeout vtim_dur
#define ptyp_uint unsigned
#define ptyp_vsl_buffer unsigned
+#define ptyp_vsl_mask vsl_mask_t
#define ptyp_vsl_reclen unsigned
#define PARAM(typ, fld, nm, ...) \
ptyp_##typ fld;
@@ -109,13 +113,17 @@ struct params {
#undef ptyp_boolean
#undef ptyp_bytes
#undef ptyp_bytes_u
+#undef ptyp_debug
#undef ptyp_double
+#undef ptyp_experimental
+#undef ptyp_feature
#undef ptyp_poolparam
#undef ptyp_thread_pool_max
#undef ptyp_thread_pool_min
#undef ptyp_timeout
#undef ptyp_uint
#undef ptyp_vsl_buffer
+#undef ptyp_vsl_mask
#undef ptyp_vsl_reclen
/* Unprivileged user / group */
@@ -123,9 +131,4 @@ struct params {
gid_t gid;
struct vre_limits vre_limits;
-
- vsl_mask_t vsl_mask;
- debug_t debug_bits;
- experimental_t experimental_bits;
- feature_t feature_bits;
};
diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h
index b15286f89..694b26d31 100644
--- a/bin/varnishd/mgt/mgt_param.h
+++ b/bin/varnishd/mgt/mgt_param.h
@@ -74,6 +74,9 @@ tweak_t tweak_boolean;
tweak_t tweak_bytes;
tweak_t tweak_bytes_u;
tweak_t tweak_double;
+tweak_t tweak_debug;
+tweak_t tweak_experimental;
+tweak_t tweak_feature;
tweak_t tweak_poolparam;
tweak_t tweak_storage;
tweak_t tweak_string;
@@ -82,6 +85,7 @@ tweak_t tweak_thread_pool_max;
tweak_t tweak_timeout;
tweak_t tweak_uint;
tweak_t tweak_vsl_buffer;
+tweak_t tweak_vsl_mask;
tweak_t tweak_vsl_reclen;
extern struct parspec mgt_parspec[]; /* mgt_param_tbl.c */
diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c
index bec9625b4..96e8a6df3 100644
--- a/bin/varnishd/mgt/mgt_param_bits.c
+++ b/bin/varnishd/mgt/mgt_param_bits.c
@@ -154,7 +154,7 @@ static const char * const VSL_tags[256] = {
# include "tbl/vsl_tags.h"
};
-static int v_matchproto_(tweak_t)
+int v_matchproto_(tweak_t)
tweak_vsl_mask(struct vsb *vsb, const struct parspec *par, const char *arg)
{
@@ -172,7 +172,7 @@ static const char * const debug_tags[] = {
NULL
};
-static int v_matchproto_(tweak_t)
+int v_matchproto_(tweak_t)
tweak_debug(struct vsb *vsb, const struct parspec *par, const char *arg)
{
@@ -190,7 +190,7 @@ static const char * const experimental_tags[] = {
NULL
};
-static int v_matchproto_(tweak_t)
+int v_matchproto_(tweak_t)
tweak_experimental(struct vsb *vsb, const struct parspec *par, const char *arg)
{
@@ -208,7 +208,7 @@ static const char * const feature_tags[] = {
NULL
};
-static int v_matchproto_(tweak_t)
+int v_matchproto_(tweak_t)
tweak_feature(struct vsb *vsb, const struct parspec *par, const char *arg)
{
@@ -221,62 +221,5 @@ tweak_feature(struct vsb *vsb, const struct parspec *par, const char *arg)
*/
struct parspec VSL_parspec[] = {
- { "vsl_mask", tweak_vsl_mask, NULL,
- NULL, NULL,
- /* default */
- "-Debug,"
- "-ExpKill,"
- "-H2RxBody,"
- "-H2RxHdr,"
- "-H2TxBody,"
- "-H2TxHdr,"
- "-Hash,"
- "-ObjHeader,"
- "-ObjProtocol,"
- "-ObjReason,"
- "-ObjStatus,"
- "-VCL_trace,"
- "-VdpAcct,"
- "-VfpAcct,"
- "-WorkThread",
- NULL,
- "Mask individual VSL messages from being logged.\n"
- "\tdefault\tSet default value\n"
- "\nUse +/- prefix in front of VSL tag name to unmask/mask "
- "individual VSL messages." },
- { "debug", tweak_debug, NULL,
- NULL, NULL,
- /* default */
- "none",
- NULL,
- "Enable/Disable various kinds of debugging.\n"
- "\tnone\tDisable all debugging\n\n"
- "Use +/- prefix to set/reset individual bits:"
-#define DEBUG_BIT(U, l, d) "\n\t" #l "\t" d
-#include "tbl/debug_bits.h"
- },
- { "experimental", tweak_experimental, NULL,
- NULL, NULL,
- /* default */
- "none",
- NULL,
- "Enable/Disable experimental features.\n"
- "\tnone\tDisable all experimental features\n\n"
- "Use +/- prefix to set/reset individual bits:"
-#define EXPERIMENTAL_BIT(U, l, d) "\n\t" #l "\t" d
-#include "tbl/experimental_bits.h"
- },
- { "feature", tweak_feature, NULL,
- NULL, NULL,
- /* default */
- "+validate_headers",
- NULL,
- "Enable/Disable various minor features.\n"
- "\tdefault\tSet default value\n"
- "\tnone\tDisable all features.\n\n"
- "Use +/- prefix to enable/disable individual feature:"
-#define FEATURE_BIT(U, l, d) "\n\t" #l "\t" d
-#include "tbl/feature_bits.h"
- },
{ NULL, NULL, NULL }
};
diff --git a/include/tbl/params.h b/include/tbl/params.h
index 1adf3d429..5c69d0438 100644
--- a/include/tbl/params.h
+++ b/include/tbl/params.h
@@ -1726,102 +1726,99 @@ PARAM_PCRE2(
PARAM_ALIAS(deprecated_dummy, debug)
# undef PARAM_ALIAS
-# undef PARAM_ALL
# undef PARAM_PCRE2
# undef PARAM_STRING
# undef PARAM_VCC
#endif /* defined(PARAM_ALL) */
-#undef PARAM_MEMPOOL
-#undef PARAM_POST
-#undef PARAM_PRE
-#undef PARAM_SIMPLE
-#undef PARAM_THREAD
-#undef PARAM
+/*--------------------------------------------------------------------
+ * Bits parameters
+ */
+
+#define PARAM_BITS(nm, fld, def, descr) \
+ PARAM(nm, fld, nm, tweak_ ## nm, &mgt_param.fld, NULL, NULL, \
+ def, NULL, descr)
-#if 0 /* NOT ACTUALLY DEFINED HERE */
-/* actual location mgt_param_bits.c*/
-/* see tbl/debug_bits.h */
-PARAM(
+PARAM_PRE
+PARAM_BITS(
/* name */ debug,
- /* type */ debug,
- /* min */ NULL,
- /* max */ NULL,
- /* def */ NULL,
- /* units */ NULL,
+ /* fld */ debug_bits,
+ /* def */ "none",
/* descr */
"Enable/Disable various kinds of debugging.\n"
- " none Disable all debugging\n"
- "\n"
- "Use +/- prefix to set/reset individual bits:\n"
- " req_state VSL Request state engine\n"
- " workspace VSL Workspace operations\n"
- " waiter VSL Waiter internals\n"
- " waitinglist VSL Waitinglist events\n"
- " syncvsl Make VSL synchronous\n"
- " hashedge Edge cases in Hash\n"
- " vclrel Rapid VCL release\n"
- " lurker VSL Ban lurker\n"
- " esi_chop Chop ESI fetch to bits\n"
- " flush_head Flush after http1 head\n"
- " vtc_mode Varnishtest Mode"
-)
-
-/* actual location mgt_param_bits.c*/
-/* see tbl/experimental_bits.h */
-PARAM(
+ "\tnone\tDisable all debugging\n\n"
+ "Use +/- prefix to set/reset individual bits:")
+#ifdef PARAM_ALL
+# define DEBUG_BIT(U, l, d) "\n\t" #l "\t" d
+# include "tbl/debug_bits.h"
+#endif
+PARAM_POST
+
+PARAM_PRE
+PARAM_BITS(
/* name */ experimental,
- /* type */ experimental,
- /* min */ NULL,
- /* max */ NULL,
- /* def */ NULL,
- /* units */ NULL,
+ /* fld */ experimental_bits,
+ /* def */ "none",
/* descr */
"Enable/Disable experimental features.\n"
- " none Disable all experimental features\n"
- "\n"
- "Use +/- prefix to set/reset individual bits:\n"
- " drop_pools Drop thread pools\n"
-)
+ "\tnone\tDisable all experimental features\n\n"
+ "Use +/- prefix to set/reset individual bits:")
+#ifdef PARAM_ALL
+# define EXPERIMENTAL_BIT(U, l, d) "\n\t" #l "\t" d
+# include "tbl/experimental_bits.h"
+#endif
+PARAM_POST
-/* actual location mgt_param_bits.c*/
-/* See tbl/feature_bits.h */
-PARAM(
+PARAM_PRE
+PARAM_BITS(
/* name */ feature,
- /* type */ feature,
- /* min */ NULL,
- /* max */ NULL,
- /* def */ NULL,
- /* units */ NULL,
+ /* fld */ feature_bits,
+ /* def */ "+validate_headers",
/* descr */
"Enable/Disable various minor features.\n"
- " none Disable all features.\n"
- "\n"
- "Use +/- prefix to enable/disable individual feature:\n"
- " short_panic Short panic message.\n"
- " wait_silo Wait for persistent silo.\n"
- " no_coredump No coredumps.\n"
- " esi_ignore_https Treat HTTPS as HTTP in ESI:includes\n"
- " esi_disable_xml_check Don't check of body looks like XML\n"
- " esi_ignore_other_elements Ignore non-esi XML-elements\n"
- " esi_remove_bom Remove UTF-8 BOM"
-)
-
-/* actual location mgt_param_bits.c*/
-PARAM(
+ "\tdefault\tSet default value\n"
+ "\tnone\tDisable all features.\n\n"
+ "Use +/- prefix to enable/disable individual feature:")
+#ifdef PARAM_ALL
+# define FEATURE_BIT(U, l, d) "\n\t" #l "\t" d
+# include "tbl/feature_bits.h"
+#endif
+PARAM_POST
+
+PARAM_PRE
+PARAM_BITS(
/* name */ vsl_mask,
- /* type */ vsl_mask,
- /* min */ NULL,
- /* max */ NULL,
- /* def */ "default",
- /* units */ NULL,
+ /* fld */ vsl_mask,
+ /* def */
+ "-Debug,"
+ "-ExpKill,"
+ "-H2RxBody,"
+ "-H2RxHdr,"
+ "-H2TxBody,"
+ "-H2TxHdr,"
+ "-Hash,"
+ "-ObjHeader,"
+ "-ObjProtocol,"
+ "-ObjReason,"
+ "-ObjStatus,"
+ "-VCL_trace,"
+ "-VdpAcct,"
+ "-VfpAcct,"
+ "-WorkThread",
/* descr */
"Mask individual VSL messages from being logged.\n"
- " default Set default value\n"
- "\n"
- "Use +/- prefix in front of VSL tag name to unmask/mask "
- "individual VSL messages."
-)
-#endif /* NOT ACTUALLY DEFINED HERE */
+ "\tdefault\tSet default value\n"
+ "\nUse +/- prefix in front of VSL tag name to unmask/mask "
+ "individual VSL messages.")
+PARAM_POST
+
+#undef PARAM_ALL
+#undef PARAM_BITS
+#undef PARAM_MEMPOOL
+#undef PARAM_POST
+#undef PARAM_PRE
+#undef PARAM_SIMPLE
+#undef PARAM_THREAD
+#undef PARAM
/*lint -restore */
More information about the varnish-commit
mailing list