[master] 74eb0df0 Make waiters a "tbl/waiters.h" table

Poul-Henning Kamp phk at FreeBSD.org
Fri Jan 27 10:01:05 CET 2017


commit 74eb0df0da7d6f415281887e74420717ec879598
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Jan 27 09:00:07 2017 +0000

    Make waiters a "tbl/waiters.h" table

diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index 0090655..652a273 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -129,18 +129,8 @@ usage(void)
 	fprintf(stderr, FMT, "-t TTL", "Default TTL");
 	fprintf(stderr, FMT, "-V", "version");
 	fprintf(stderr, FMT, "-W waiter", "Waiter implementation");
-#if defined(HAVE_KQUEUE)
-	fprintf(stderr, FMT, "", "  -W kqueue");
-#endif
-#if defined(HAVE_PORT_CREATE)
-	fprintf(stderr, FMT, "", "  -W ports");
-#endif
-#if defined(HAVE_EPOLL_CTL)
-	fprintf(stderr, FMT, "", "  -W epoll");
-#endif
-	fprintf(stderr, FMT, "", "  -W poll");
-
-#undef FMT
+#define WAITER(nm) fprintf(stderr, FMT, "", "  -W " #nm);
+#include "tbl/waiters.h"
 	exit(1);
 }
 
diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c
index 7b8530f..3010d86 100644
--- a/bin/varnishd/waiter/mgt_waiter.c
+++ b/bin/varnishd/waiter/mgt_waiter.c
@@ -37,16 +37,8 @@
 #include "waiter/mgt_waiter.h"
 
 static const struct choice waiter_choice[] = {
-    #if defined(HAVE_KQUEUE)
-	{ "kqueue",	&waiter_kqueue },
-    #endif
-    #if defined(HAVE_PORT_CREATE)
-	{ "ports",	&waiter_ports },
-    #endif
-    #if defined(HAVE_EPOLL_CTL)
-	{ "epoll",	&waiter_epoll },
-    #endif
-	{ "poll",	&waiter_poll },
+#define WAITER(nm) { #nm, &waiter_##nm },
+#include "tbl/waiters.h"
 	{ NULL,		NULL}
 };
 
diff --git a/bin/varnishd/waiter/mgt_waiter.h b/bin/varnishd/waiter/mgt_waiter.h
index 0106427..d8f6222 100644
--- a/bin/varnishd/waiter/mgt_waiter.h
+++ b/bin/varnishd/waiter/mgt_waiter.h
@@ -34,18 +34,7 @@ struct waiter_impl;
 /* mgt_waiter.c */
 extern struct waiter_impl const * waiter;
 
-#if defined(HAVE_EPOLL_CTL)
-extern const struct waiter_impl waiter_epoll;
-#endif
-
-#if defined(HAVE_KQUEUE)
-extern const struct waiter_impl waiter_kqueue;
-#endif
-
-#if defined(HAVE_PORT_CREATE)
-extern const struct waiter_impl waiter_ports;
-#endif
-
-extern const struct waiter_impl waiter_poll;
+#define WAITER(nm) extern const struct waiter_impl waiter_##nm;
+#include "tbl/waiters.h"
 
 void Wait_config(const char *arg);
diff --git a/include/Makefile.am b/include/Makefile.am
index 4534cbf..2df7780 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -44,6 +44,7 @@ nobase_pkginclude_HEADERS = \
 	tbl/vsc_types.h \
 	tbl/vsl_tags.h \
 	tbl/vsl_tags_http.h \
+	tbl/waiters.h \
 	vapi/vsm.h \
 	vapi/vsm_int.h \
 	vapi/vsc.h \
diff --git a/include/tbl/waiters.h b/include/tbl/waiters.h
new file mode 100644
index 0000000..f1f1d49
--- /dev/null
+++ b/include/tbl/waiters.h
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 2017 Varnish Software AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * WAITER(nm)
+ */
+
+/*lint -save -e525 -e539 */
+
+#if defined(HAVE_KQUEUE)
+  WAITER(kqueue)
+#endif
+
+#if defined(HAVE_PORT_CREATE)
+  WAITER(ports)
+#endif
+
+#if defined(HAVE_EPOLL_CTL)
+  WAITER(epoll)
+#endif
+
+WAITER(poll)
+#undef WAITER



More information about the varnish-commit mailing list