[master] 0f193e508 param: Introduce a PLATFORM_DEPENDENT parameter flag

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Wed Oct 21 17:24:13 UTC 2020


commit 0f193e508d18db15f5108a0cbae897ab640ef33d
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Thu Mar 12 15:27:29 2020 +0100

    param: Introduce a PLATFORM_DEPENDENT parameter flag
    
    The problem with NOT_IMPLEMENTED is that it's contextual, so we can't
    reliably generate documentation that marks all conditional parameters
    as such.
    
    While at it, unsign the flags in parameter specs.
    
    Slightly better diff with the --word-diff option.
    
    Refs #3250

diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index 6d342297c..cdd9a01af 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -108,7 +108,7 @@ static const char NOT_IMPLEMENTED_TEXT[] =
 	"This parameter depends on a feature which is not available"
 	" on this platform.";
 
-static const char NOT_IMPLEMENTED_DOC[] =
+static const char PLATFORM_DEPENDENT_TEXT[] =
 	"NB: This parameter depends on a feature which is not available"
 	" on all platforms.";
 
@@ -763,8 +763,8 @@ MCF_DumpRstParam(void)
 			printf("~");
 		printf("\n");
 
-		if (pp->flags && pp->flags & NOT_IMPLEMENTED)
-			printf("\n%s\n\n", NOT_IMPLEMENTED_DOC);
+		if (pp->flags && pp->flags & PLATFORM_DEPENDENT)
+			printf("\n%s\n\n", PLATFORM_DEPENDENT_TEXT);
 
 		if (pp->units != NULL && *pp->units != '\0')
 			printf("\t* Units: %s\n", pp->units);
@@ -783,7 +783,7 @@ MCF_DumpRstParam(void)
 		 * XXX: that say if ->min/->max are valid, so we
 		 * XXX: can emit those also in help texts.
 		 */
-		if (pp->flags & ~NOT_IMPLEMENTED) {
+		if (pp->flags & ~(NOT_IMPLEMENTED|PLATFORM_DEPENDENT)) {
 			printf("\t* Flags: ");
 			q = "";
 
diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h
index 41bc4d9f5..fd884fd02 100644
--- a/bin/varnishd/mgt/mgt_param.h
+++ b/bin/varnishd/mgt/mgt_param.h
@@ -46,16 +46,17 @@ struct parspec {
 	const char	*def;
 	const char	*units;
 	const char	*descr;
-	int		 flags;
-#define DELAYED_EFFECT	(1<<0)
-#define EXPERIMENTAL	(1<<1)
-#define MUST_RESTART	(1<<2)
-#define MUST_RELOAD	(1<<3)
-#define WIZARD		(1<<4)
-#define PROTECTED	(1<<5)
-#define OBJ_STICKY	(1<<6)
-#define ONLY_ROOT	(1<<7)
-#define NOT_IMPLEMENTED	(1<<8)
+	unsigned	 flags;
+#define DELAYED_EFFECT		(1<<0)
+#define EXPERIMENTAL		(1<<1)
+#define MUST_RESTART		(1<<2)
+#define MUST_RELOAD		(1<<3)
+#define WIZARD			(1<<4)
+#define PROTECTED		(1<<5)
+#define OBJ_STICKY		(1<<6)
+#define ONLY_ROOT		(1<<7)
+#define NOT_IMPLEMENTED		(1<<8)
+#define PLATFORM_DEPENDENT	(1<<9)
 
 	const char	*dyn_min_reason;
 	const char	*dyn_max_reason;
diff --git a/include/tbl/params.h b/include/tbl/params.h
index 5b64b462e..14986dfec 100644
--- a/include/tbl/params.h
+++ b/include/tbl/params.h
@@ -43,14 +43,14 @@
 #define PARAM_SIMPLE(nm, typ, ...) \
 	PARAM(typ, nm, nm, tweak_##typ, &mgt_param.nm, __VA_ARGS__)
 
-#if defined(XYZZY)
-  #error "Temporary macro XYZZY already defined"
+#if defined(PLATFORM_FLAGS)
+#  error "Temporary macro PLATFORM_FLAGS already defined"
 #endif
 
 #if defined(HAVE_ACCEPT_FILTERS)
-  #define XYZZY MUST_RESTART
+#  define PLATFORM_FLAGS MUST_RESTART
 #else
-  #define XYZZY NOT_IMPLEMENTED
+#  define PLATFORM_FLAGS NOT_IMPLEMENTED
 #endif
 PARAM_SIMPLE(
 	/* name */	accept_filter,
@@ -66,12 +66,12 @@ PARAM_SIMPLE(
 	"in the first place. Malformed requests may go unnoticed and not "
 	"increase the client_req_400 counter. GET or HEAD requests with a "
 	"body may be blocked altogether.",
-	/* flags */	XYZZY,
+	/* flags */	PLATFORM_DEPENDENT | PLATFORM_FLAGS,
 	/* dyn_min_reason */	NULL,
 	/* dyn_max_reason */	NULL,
 	/* dyn_def_reason */	"on (if your platform supports accept filters)"
 )
-#undef XYZZY
+#undef PLATFORM_FLAGS
 
 PARAM_SIMPLE(
 	/* name */	acceptor_sleep_decay,
@@ -610,14 +610,10 @@ PARAM_SIMPLE(
 	"of that the response is allowed to take up."
 )
 
-#if defined(XYZZY)
-  #error "Temporary macro XYZZY already defined"
-#endif
-
 #if defined(SO_SNDTIMEO_WORKS)
-  #define XYZZY DELAYED_EFFECT
+#  define PLATFORM_FLAGS DELAYED_EFFECT
 #else
-  #define XYZZY NOT_IMPLEMENTED
+#  define PLATFORM_FLAGS NOT_IMPLEMENTED
 #endif
 PARAM_SIMPLE(
 	/* name */	idle_send_timeout,
@@ -632,9 +628,9 @@ PARAM_SIMPLE(
 	"When this timeout is hit, the session is closed.\n\n"
 	"See the man page for `setsockopt(2)` or `socket(7)` under"
 	" ``SO_SNDTIMEO`` for more information.",
-	/* flags */	XYZZY
+	/* flags */	PLATFORM_DEPENDENT | PLATFORM_FLAGS
 )
-#undef XYZZY
+#undef PLATFORM_FLAGS
 
 PARAM_SIMPLE(
 	/* name */	listen_depth,
@@ -774,14 +770,10 @@ PARAM_SIMPLE(
 	/* flags */	EXPERIMENTAL
 )
 
-#if defined(XYZZY)
-  #error "Temporary macro XYZZY already defined"
-#endif
-
 #if defined(SO_SNDTIMEO_WORKS)
-  #define XYZZY DELAYED_EFFECT
+#  define PLATFORM_FLAGS DELAYED_EFFECT
 #else
-  #define XYZZY NOT_IMPLEMENTED
+#  define PLATFORM_FLAGS NOT_IMPLEMENTED
 #endif
 PARAM_SIMPLE(
 	/* name */	send_timeout,
@@ -797,9 +789,9 @@ PARAM_SIMPLE(
 	" timeout is extended unless the total time already taken for sending"
 	" the response in its entirety exceeds this many seconds.\n\n"
 	"When this timeout is hit, the session is closed",
-	/* flags */	XYZZY
+	/* flags */	PLATFORM_DEPENDENT | PLATFORM_FLAGS
 )
-#undef XYZZY
+#undef PLATFORM_FLAGS
 
 PARAM_SIMPLE(
 	/* name */	shortlived,
@@ -838,9 +830,9 @@ PARAM_SIMPLE(
 )
 
 #if defined(HAVE_TCP_FASTOPEN)
-  #define XYZZY MUST_RESTART
+#  define PLATFORM_FLAGS MUST_RESTART
 #else
-  #define XYZZY NOT_IMPLEMENTED
+#  define PLATFORM_FLAGS NOT_IMPLEMENTED
 #endif
 PARAM_SIMPLE(
 	/* name */	tcp_fastopen,
@@ -851,14 +843,14 @@ PARAM_SIMPLE(
 	/* units */	"bool",
 	/* descr */
 	"Enable TCP Fast Open extension.",
-	/* flags */	XYZZY
+	/* flags */	PLATFORM_FLAGS
 )
-#undef XYZZY
+#undef PLATFORM_FLAGS
 
 #if defined(HAVE_TCP_KEEP)
-  #define XYZZY	EXPERIMENTAL
+#  define PLATFORM_FLAGS EXPERIMENTAL
 #else
-  #define XYZZY	NOT_IMPLEMENTED
+#  define PLATFORM_FLAGS NOT_IMPLEMENTED
 #endif
 PARAM_SIMPLE(
 	/* name */	tcp_keepalive_intvl,
@@ -870,7 +862,7 @@ PARAM_SIMPLE(
 	/* descr */
 	"The number of seconds between TCP keep-alive probes. "
 	"Ignored for Unix domain sockets.",
-	/* flags */	XYZZY,
+	/* flags */	PLATFORM_DEPENDENT | PLATFORM_FLAGS,
 	/* dyn_min_reason */	NULL,
 	/* dyn_max_reason */	NULL,
 	/* dyn_def_reason */	"platform dependent"
@@ -887,7 +879,7 @@ PARAM_SIMPLE(
 	"The maximum number of TCP keep-alive probes to send before giving "
 	"up and killing the connection if no response is obtained from the "
 	"other end. Ignored for Unix domain sockets.",
-	/* flags */	XYZZY,
+	/* flags */	PLATFORM_DEPENDENT | PLATFORM_FLAGS,
 	/* dyn_min_reason */	NULL,
 	/* dyn_max_reason */	NULL,
 	/* dyn_def_reason */	"platform dependent"
@@ -904,21 +896,17 @@ PARAM_SIMPLE(
 	"The number of seconds a connection needs to be idle before TCP "
 	"begins sending out keep-alive probes. "
 	"Ignored for Unix domain sockets.",
-	/* flags */	XYZZY,
+	/* flags */	PLATFORM_DEPENDENT | PLATFORM_FLAGS,
 	/* dyn_min_reason */	NULL,
 	/* dyn_max_reason */	NULL,
 	/* dyn_def_reason */	"platform dependent"
 )
-#undef XYZZY
-
-#if defined(XYZZY)
-  #error "Temporary macro XYZZY already defined"
-#endif
+#undef PLATFORM_FLAGS
 
 #if defined(SO_RCVTIMEO_WORKS)
-  #define XYZZY 0
+#  define PLATFORM_FLAGS 0
 #else
-  #define XYZZY NOT_IMPLEMENTED
+#  define PLATFORM_FLAGS NOT_IMPLEMENTED
 #endif
 PARAM_SIMPLE(
 	/* name */	timeout_idle,
@@ -934,9 +922,9 @@ PARAM_SIMPLE(
 	"This parameter is particularly relevant for HTTP1 keepalive "
 	" connections which are closed unless the next request is received"
 	" before this timeout is reached.",
-	/* flags */	XYZZY
+	/* flags */	PLATFORM_FLAGS
 )
-#undef XYZZY
+#undef PLATFORM_FLAGS
 
 PARAM_SIMPLE(
 	/* name */	timeout_linger,


More information about the varnish-commit mailing list