[master] aa0abc0 Let the include/tbl files control the emission of VSC documentation

Poul-Henning Kamp phk at FreeBSD.org
Tue Jan 3 11:28:05 CET 2017


commit aa0abc05f83d1e6459ef8e78d132d87416c36c39
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Jan 3 10:21:37 2017 +0000

    Let the include/tbl files control the emission of VSC documentation

diff --git a/bin/varnishstat/vsc2rst.c b/bin/varnishstat/vsc2rst.c
index d1a97f4..c53dc72 100644
--- a/bin/varnishstat/vsc2rst.c
+++ b/bin/varnishstat/vsc2rst.c
@@ -36,86 +36,34 @@
 #include "tbl/vsc_levels.h"
 #undef VSC_LEVEL_F
 
-#define P(x)			\
-	printf(x "\n")
+static void
+L(const char *s)
+{
+	printf("\n%s\n", s);
+	for (;*s != '\0'; s++)
+		putchar('=');
+	putchar('\n');
+	putchar('\n');
+}
 
 int main(int argc, char **argv)
 {
 	(void)argc;
 	(void)argv;
-	P("COUNTER LEVELS");
-	P("==============");
-	P("");
+	L("COUNTER LEVELS");
+
 #define VSC_LEVEL_F(v,l,e,d)		\
 	printf("%s – %s\n\t%s\n\n", l, e, d);
-#include "tbl/vsc_levels.h"
-
-	P("");
-	P("MAIN COUNTERS (MAIN.*)");
-	P("======================");
-	P("");
-#define VSC_FF(n, t, l, s, f, v, d, e)	\
-	printf("%s – %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e);
-#include "tbl/vsc_f_main.h"
-
-	P("MANAGEMENT PROCESS COUNTERS (MGT.*)");
-	P("===================================");
-	P("");
-#define VSC_DO_MGT
-#define VSC_FF(n, t, l, s, f, v, d, e)	\
-	printf("%s – %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e);
-#include "tbl/vsc_fields.h"
-#undef VSC_DO_MGT
-
-	P("");
-	P("PER MEMORY POOL COUNTERS (MEMPOOL.*)");
-	P("====================================");
-	P("");
-#define VSC_DO_MEMPOOL
-#define VSC_FF(n, t, l, s, f, v, d, e)	\
-	printf("%s – %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e);
-#include "tbl/vsc_fields.h"
-#undef VSC_DO_MEMPOOL
 
-	P("");
-	P("PER MALLOC STORAGE COUNTERS (SMA.*)");
-	P("===================================");
-	P("");
-#define VSC_DO_SMA
-#define VSC_FF(n, t, l, s, f, v, d, e)	\
-	printf("%s – %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e);
-#include "tbl/vsc_fields.h"
-#undef  VSC_DO_SMA
+#include "tbl/vsc_levels.h"
 
-	P("");
-	P("PER FILE STORAGE COUNTERS (SMF.*)");
-	P("=================================");
-	P("");
-#define VSC_DO_SMF
-#define VSC_FF(n, t, l, s, f, v, d, e)	\
-	printf("%s – %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e);
-#include "tbl/vsc_fields.h"
-#undef VSC_DO_SMF
+#define VSC_DO(U,l,t,h) L(h);
 
-	P("");
-	P("PER BACKEND COUNTERS (VBE.*)");
-	P("============================");
-	P("");
-#define VSC_DO_VBE
-#define VSC_FF(n, t, l, s, f, v, d, e)	\
+#define VSC_F(n, t, l, s, f, v, d, e)	\
 	printf("%s – %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e);
-#include "tbl/vsc_fields.h"
-#undef VSC_DO_VBE
 
-	P("");
-	P("LOCK COUNTERS (LCK.*)");
-	P("=====================");
-	P("");
-#define VSC_DO_LCK
-#define VSC_FF(n, t, l, s, f, v, d, e)	\
-	printf("%s – %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e);
-#include "tbl/vsc_fields.h"
-#undef VSC_DO_LCK
+#define VSC_DONE(U,l,t)
 
+#include "tbl/vsc_all.h"
 	return (0);
 }
diff --git a/include/tbl/vsc_all.h b/include/tbl/vsc_all.h
index 1c761d4..c77c2b8 100644
--- a/include/tbl/vsc_all.h
+++ b/include/tbl/vsc_all.h
@@ -29,13 +29,13 @@
 
 /*lint -save -e525 -e539 */
 
-VSC_DO(MAIN, main, VSC_type_main)
+VSC_DO(MAIN, main, VSC_type_main, "MAIN COUNTERS (MAIN.*)")
   #define VSC_FF VSC_F
   #include "tbl/vsc_f_main.h"
   #undef VSC_FF
 VSC_DONE(MAIN, main, VSC_type_main)
 
-VSC_DO(MGT, mgt, VSC_type_mgt)
+VSC_DO(MGT, mgt, VSC_type_mgt, "MANAGEMENT PROCESS COUNTERS (MGT.*)")
   #define VSC_DO_MGT
     #define VSC_FF VSC_F
     #include "tbl/vsc_fields.h"
@@ -43,7 +43,7 @@ VSC_DO(MGT, mgt, VSC_type_mgt)
   #undef VSC_DO_MGT
 VSC_DONE(MGT, mgt, VSC_type_mgt)
 
-VSC_DO(MEMPOOL, mempool, VSC_type_mempool)
+VSC_DO(MEMPOOL, mempool, VSC_type_mempool, "MEMORY POOL COUNTERS (MEMPOOL.*)")
   #define VSC_DO_MEMPOOL
     #define VSC_FF VSC_F
     #include "tbl/vsc_fields.h"
@@ -51,7 +51,7 @@ VSC_DO(MEMPOOL, mempool, VSC_type_mempool)
   #undef VSC_DO_MEMPOOL
 VSC_DONE(MEMPOOL, mempool, VSC_type_mempool)
 
-VSC_DO(SMA, sma, VSC_type_sma)
+VSC_DO(SMA, sma, VSC_type_sma, "MALLOC STORAGE COUNTERS (SMA.*)")
   #define VSC_DO_SMA
     #define VSC_FF VSC_F
     #include "tbl/vsc_fields.h"
@@ -59,7 +59,7 @@ VSC_DO(SMA, sma, VSC_type_sma)
   #undef VSC_DO_SMA
 VSC_DONE(SMA, sma, VSC_type_sma)
 
-VSC_DO(SMF, smf, VSC_type_smf)
+VSC_DO(SMF, smf, VSC_type_smf, "FILE STORAGE COUNTERS (SMF.*)")
   #define VSC_DO_SMF
     #define VSC_FF VSC_F
     #include "tbl/vsc_fields.h"
@@ -67,7 +67,7 @@ VSC_DO(SMF, smf, VSC_type_smf)
   #undef VSC_DO_SMF
 VSC_DONE(SMF, smf, VSC_type_smf)
 
-VSC_DO(VBE, vbe, VSC_type_vbe)
+VSC_DO(VBE, vbe, VSC_type_vbe, "BACKEND COUNTERS (VBE.*)")
   #define VSC_DO_VBE
     #define VSC_FF VSC_F
     #include "tbl/vsc_fields.h"
@@ -75,7 +75,7 @@ VSC_DO(VBE, vbe, VSC_type_vbe)
   #undef VSC_DO_VBE
 VSC_DONE(VBE, vbe, VSC_type_vbe)
 
-VSC_DO(LCK, lck, VSC_type_lck)
+VSC_DO(LCK, lck, VSC_type_lck, "LOCK COUNTERS (LCK.*)")
   #define VSC_DO_LCK
     #define VSC_FF VSC_F
     #include "tbl/vsc_fields.h"
diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h
index ded83df..bf1b1f5 100644
--- a/include/vapi/vsc.h
+++ b/include/vapi/vsc.h
@@ -185,7 +185,7 @@ const struct VSC_level_desc *VSC_LevelDesc(unsigned level);
 #include "tbl/vsc_types.h"
 #undef VSC_TYPE_F
 
-#define VSC_DO(U,l,t) extern const struct VSC_desc VSC_desc_##l[];
+#define VSC_DO(U,l,t,h) extern const struct VSC_desc VSC_desc_##l[];
 #define VSC_F(n,t,l,s,f,v,d,e)
 #define VSC_DONE(U,l,t)
 #include "tbl/vsc_all.h"
diff --git a/include/vapi/vsc_int.h b/include/vapi/vsc_int.h
index 2566724..352c8ba 100644
--- a/include/vapi/vsc_int.h
+++ b/include/vapi/vsc_int.h
@@ -35,17 +35,15 @@ enum VSC_level_e {
 #define VSC_LEVEL_F(v,l,e,d)		\
 	VSC_level_##v,
 #include "tbl/vsc_levels.h"
-#undef VSC_LEVEL_F
 	VSC_level_MAX,
 };
 
 /* Forward declare the static vsc type names */
 #define VSC_TYPE_F(n,t,l,e,d)		extern const char *VSC_type_##n;
 #include "tbl/vsc_types.h"
-#undef VSC_TYPE_F
 
 /* Define the vsc type structs */
-#define VSC_DO(u,l,t)			struct VSC_C_##l {
+#define VSC_DO(u,l,t,h)			struct VSC_C_##l {
 #define VSC_F(n,t,l,s,f,v,d,e)			t n;
 #define VSC_DONE(u,l,t)			};
 #include "tbl/vsc_all.h"
diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c
index 6aff617..74c567e 100644
--- a/lib/libvarnishapi/vsc.c
+++ b/lib/libvarnishapi/vsc.c
@@ -286,7 +286,7 @@ vsc_add_pt(struct vsc *vsc, const volatile void *ptr,
 	VTAILQ_INSERT_TAIL(&vsc->pt_list, pt, list);
 }
 
-#define VSC_DO(U,l,t)							\
+#define VSC_DO(U,l,t,h)							\
 	static void							\
 	iter_##l(struct vsc *vsc, const struct VSC_desc *descs,		\
 	    struct vsc_vf *vf)						\
@@ -337,16 +337,13 @@ vsc_build_pt_list(struct VSM_data *vd)
 	vsc_delete_pt_list(vsc);
 
 	VTAILQ_FOREACH(vf, &vsc->vf_list, list) {
-#define VSC_DO(U,l,t)						\
+#define VSC_DO(U,l,t,h)						\
 		CHECK_OBJ_NOTNULL(vf, VSC_VF_MAGIC);		\
 		if (!strcmp(vf->fantom.type, t))		\
 			iter_##l(vsc, VSC_desc_##l, vf);
 #define VSC_F(n,t,l,s,f,v,d,e)
 #define VSC_DONE(a,b,c)
 #include "tbl/vsc_all.h"
-#undef VSC_DO
-#undef VSC_F
-#undef VSC_DONE
 	}
 }
 
@@ -459,10 +456,7 @@ VSC_LevelDesc(unsigned level)
 	const struct VSC_type_desc VSC_type_desc_##n = {l,e,d};
 #include "tbl/vsc_types.h"
 
-#define VSC_DO(U,l,t)		const struct VSC_desc VSC_desc_##l[] = {
+#define VSC_DO(U,l,t,h)		const struct VSC_desc VSC_desc_##l[] = {
 #define VSC_F(n,t,l,s,f,v,d,e)		{#n,#t,s,f,&VSC_level_desc_##v,d,e},
 #define VSC_DONE(U,l,t)		};
 #include "tbl/vsc_all.h"
-#undef VSC_DO
-#undef VSC_F
-#undef VSC_DONE



More information about the varnish-commit mailing list