From 89adb7344e78f093f0b606156dc90bcdaeae260e Mon Sep 17 00:00:00 2001 From: phk Date: Sun, 21 Dec 2008 16:19:14 +0000 Subject: [PATCH] Move the enum MET/RET macros to vcl.h git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3483 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache.h | 1 - varnish-cache/bin/varnishd/cache_expire.c | 1 + varnish-cache/include/vcl.h | 32 ++++++++- varnish-cache/include/vcl_returns.h | 76 +++++++--------------- varnish-cache/lib/libvcl/vcc_compile.c | 6 +- varnish-cache/lib/libvcl/vcc_compile.h | 6 +- varnish-cache/lib/libvcl/vcc_fixed_token.c | 50 ++++++++++---- varnish-cache/lib/libvcl/vcc_parse.c | 2 +- varnish-cache/lib/libvcl/vcc_token_defs.h | 2 +- 9 files changed, 102 insertions(+), 74 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 81431475..d78ae2bd 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -54,7 +54,6 @@ #include "libvarnish.h" -#include "vcl_returns.h" #include "common.h" #include "heritage.h" #include "miniobj.h" diff --git a/varnish-cache/bin/varnishd/cache_expire.c b/varnish-cache/bin/varnishd/cache_expire.c index 458ba74e..bc61dc98 100644 --- a/varnish-cache/bin/varnishd/cache_expire.c +++ b/varnish-cache/bin/varnishd/cache_expire.c @@ -60,6 +60,7 @@ #include "shmlog.h" #include "binary_heap.h" #include "cache.h" +#include "vcl.h" #include "hash_slinger.h" /* diff --git a/varnish-cache/include/vcl.h b/varnish-cache/include/vcl.h index 35fc5d7f..6b29fa1b 100644 --- a/varnish-cache/include/vcl.h +++ b/varnish-cache/include/vcl.h @@ -3,7 +3,7 @@ * * NB: This file is machine generated, DO NOT EDIT! * - * Edit vcc_gen_fixed_token.tcl instead + * Edit and run vcc_gen_fixed_token.tcl instead */ struct sess; @@ -13,6 +13,36 @@ typedef void vcl_init_f(struct cli *); typedef void vcl_fini_f(struct cli *); typedef int vcl_func_f(struct sess *sp); +/* VCL Methods */ +#define VCL_MET_RECV (1 << 0) +#define VCL_MET_PIPE (1 << 1) +#define VCL_MET_PASS (1 << 2) +#define VCL_MET_HASH (1 << 3) +#define VCL_MET_MISS (1 << 4) +#define VCL_MET_HIT (1 << 5) +#define VCL_MET_FETCH (1 << 6) +#define VCL_MET_DELIVER (1 << 7) +#define VCL_MET_PREFETCH (1 << 8) +#define VCL_MET_TIMEOUT (1 << 9) +#define VCL_MET_DISCARD (1 << 10) +#define VCL_MET_ERROR (1 << 11) + +#define VCL_MET_MAX 12 + +/* VCL Returns */ +#define VCL_RET_ERROR (1 << 0) +#define VCL_RET_LOOKUP (1 << 1) +#define VCL_RET_HASH (1 << 2) +#define VCL_RET_PIPE (1 << 3) +#define VCL_RET_PASS (1 << 4) +#define VCL_RET_FETCH (1 << 5) +#define VCL_RET_DELIVER (1 << 6) +#define VCL_RET_DISCARD (1 << 7) +#define VCL_RET_KEEP (1 << 8) +#define VCL_RET_RESTART (1 << 9) + +#define VCL_RET_MAX 10 + struct VCL_conf { unsigned magic; #define VCL_CONF_MAGIC 0x7406c509 /* from /dev/random */ diff --git a/varnish-cache/include/vcl_returns.h b/varnish-cache/include/vcl_returns.h index b93928a9..c64bbc64 100644 --- a/varnish-cache/include/vcl_returns.h +++ b/varnish-cache/include/vcl_returns.h @@ -3,7 +3,7 @@ * * NB: This file is machine generated, DO NOT EDIT! * - * Edit vcc_gen_fixed_token.tcl instead + * Edit and run vcc_gen_fixed_token.tcl instead */ #ifdef VCL_RET_MAC @@ -19,57 +19,31 @@ VCL_RET_MAC(deliver, DELIVER, (1 << 6), 6) VCL_RET_MAC(discard, DISCARD, (1 << 7), 7) VCL_RET_MAC(keep, KEEP, (1 << 8), 8) VCL_RET_MAC(restart, RESTART, (1 << 9), 9) -#else -#define VCL_RET_ERROR (1 << 0) -#define VCL_RET_LOOKUP (1 << 1) -#define VCL_RET_HASH (1 << 2) -#define VCL_RET_PIPE (1 << 3) -#define VCL_RET_PASS (1 << 4) -#define VCL_RET_FETCH (1 << 5) -#define VCL_RET_DELIVER (1 << 6) -#define VCL_RET_DISCARD (1 << 7) -#define VCL_RET_KEEP (1 << 8) -#define VCL_RET_RESTART (1 << 9) -#define VCL_RET_MAX 10 #endif #ifdef VCL_MET_MAC -VCL_MET_MAC(recv,RECV,( - VCL_RET_ERROR|VCL_RET_PASS|VCL_RET_PIPE|VCL_RET_LOOKUP)) -VCL_MET_MAC(pipe,PIPE,( - VCL_RET_ERROR|VCL_RET_PIPE)) -VCL_MET_MAC(pass,PASS,( - VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS)) -VCL_MET_MAC(hash,HASH,( - VCL_RET_HASH)) -VCL_MET_MAC(miss,MISS,( - VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_FETCH)) -VCL_MET_MAC(hit,HIT,( - VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_DELIVER)) -VCL_MET_MAC(fetch,FETCH,( - VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_DELIVER)) -VCL_MET_MAC(deliver,DELIVER,( - VCL_RET_RESTART|VCL_RET_DELIVER)) -VCL_MET_MAC(prefetch,PREFETCH,( - VCL_RET_FETCH|VCL_RET_PASS)) -VCL_MET_MAC(timeout,TIMEOUT,( - VCL_RET_FETCH|VCL_RET_DISCARD)) -VCL_MET_MAC(discard,DISCARD,( - VCL_RET_DISCARD|VCL_RET_KEEP)) -VCL_MET_MAC(error,ERROR,( - VCL_RET_DELIVER)) -#else -#define VCL_MET_RECV (1 << 0) -#define VCL_MET_PIPE (1 << 1) -#define VCL_MET_PASS (1 << 2) -#define VCL_MET_HASH (1 << 3) -#define VCL_MET_MISS (1 << 4) -#define VCL_MET_HIT (1 << 5) -#define VCL_MET_FETCH (1 << 6) -#define VCL_MET_DELIVER (1 << 7) -#define VCL_MET_PREFETCH (1 << 8) -#define VCL_MET_TIMEOUT (1 << 9) -#define VCL_MET_DISCARD (1 << 10) -#define VCL_MET_ERROR (1 << 11) +VCL_MET_MAC(recv,RECV, + (VCL_RET_ERROR|VCL_RET_PASS|VCL_RET_PIPE|VCL_RET_LOOKUP)) +VCL_MET_MAC(pipe,PIPE, + (VCL_RET_ERROR|VCL_RET_PIPE)) +VCL_MET_MAC(pass,PASS, + (VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS)) +VCL_MET_MAC(hash,HASH, + (VCL_RET_HASH)) +VCL_MET_MAC(miss,MISS, + (VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_FETCH)) +VCL_MET_MAC(hit,HIT, + (VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_DELIVER)) +VCL_MET_MAC(fetch,FETCH, + (VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_DELIVER)) +VCL_MET_MAC(deliver,DELIVER, + (VCL_RET_RESTART|VCL_RET_DELIVER)) +VCL_MET_MAC(prefetch,PREFETCH, + (VCL_RET_FETCH|VCL_RET_PASS)) +VCL_MET_MAC(timeout,TIMEOUT, + (VCL_RET_FETCH|VCL_RET_DISCARD)) +VCL_MET_MAC(discard,DISCARD, + (VCL_RET_DISCARD|VCL_RET_KEEP)) +VCL_MET_MAC(error,ERROR, + (VCL_RET_DELIVER)) #endif -#define N_METHODS 12 diff --git a/varnish-cache/lib/libvcl/vcc_compile.c b/varnish-cache/lib/libvcl/vcc_compile.c index 7ffa6b77..e1de28d2 100644 --- a/varnish-cache/lib/libvcl/vcc_compile.c +++ b/varnish-cache/lib/libvcl/vcc_compile.c @@ -500,7 +500,7 @@ vcc_NewTokenList(void) assert(tl->ff != NULL); /* body code of methods */ - for (i = 0; i < N_METHODS; i++) { + for (i = 0; i < VCL_MET_MAX; i++) { tl->fm[i] = vsb_newauto(); assert(tl->fm[i] != NULL); } @@ -532,7 +532,7 @@ vcc_DestroyTokenList(struct tokenlist *tl, char *ret) vsb_delete(tl->fc); vsb_delete(tl->fi); vsb_delete(tl->ff); - for (i = 0; i < N_METHODS; i++) + for (i = 0; i < VCL_MET_MAX; i++) vsb_delete(tl->fm[i]); free(tl); @@ -611,7 +611,7 @@ vcc_CompileSource(struct vsb *sb, struct source *sp) return (vcc_DestroyTokenList(tl, NULL)); /* Emit method functions */ - for (i = 0; i < N_METHODS; i++) { + for (i = 0; i < VCL_MET_MAX; i++) { Fc(tl, 1, "\nstatic int\n"); Fc(tl, 1, "VGC_function_%s (struct sess *sp)\n", method_tab[i].name); diff --git a/varnish-cache/lib/libvcl/vcc_compile.h b/varnish-cache/lib/libvcl/vcc_compile.h index 78d3d6d8..b27daa03 100644 --- a/varnish-cache/lib/libvcl/vcc_compile.h +++ b/varnish-cache/lib/libvcl/vcc_compile.h @@ -31,7 +31,7 @@ #include "vqueue.h" -#include "vcl_returns.h" +#include "vcl.h" #define INDENT 2 @@ -77,7 +77,7 @@ struct tokenlist { int findent; unsigned cnt; struct vsb *fc, *fh, *fi, *ff, *fb; - struct vsb *fm[N_METHODS]; + struct vsb *fm[VCL_MET_MAX]; VTAILQ_HEAD(, ref) refs; struct vsb *sb; int err; @@ -85,7 +85,7 @@ struct tokenlist { int ndirector; VTAILQ_HEAD(, proc) procs; struct proc *curproc; - struct proc *mprocs[N_METHODS]; + struct proc *mprocs[VCL_MET_MAX]; VTAILQ_HEAD(, acl_e) acl; diff --git a/varnish-cache/lib/libvcl/vcc_fixed_token.c b/varnish-cache/lib/libvcl/vcc_fixed_token.c index a94c7fcd..1d0fa6ff 100644 --- a/varnish-cache/lib/libvcl/vcc_fixed_token.c +++ b/varnish-cache/lib/libvcl/vcc_fixed_token.c @@ -3,7 +3,7 @@ * * NB: This file is machine generated, DO NOT EDIT! * - * Edit vcc_gen_fixed_token.tcl instead + * Edit and run vcc_gen_fixed_token.tcl instead */ #include "config.h" @@ -167,14 +167,38 @@ vcl_output_lang_h(struct vsb *sb) /* ../../include/vcl.h */ - vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 3377 2008-11-10 11"); - vsb_cat(sb, ":55:15Z tfheen $\n *\n * NB: This file is machine gen"); - vsb_cat(sb, "erated, DO NOT EDIT!\n *\n * Edit vcc_gen_fixed_token."); - vsb_cat(sb, "tcl instead\n */\n\nstruct sess;\n"); + vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 3482 2008-12-21 16"); + vsb_cat(sb, ":18:39Z phk $\n *\n * NB: This file is machine genera"); + vsb_cat(sb, "ted, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_t"); + vsb_cat(sb, "oken.tcl instead\n */\n\nstruct sess;\n"); vsb_cat(sb, "struct cli;\n\ntypedef void vcl_init_f(struct cli *);\n"); vsb_cat(sb, "typedef void vcl_fini_f(struct cli *);\n"); vsb_cat(sb, "typedef int vcl_func_f(struct sess *sp);\n"); - vsb_cat(sb, "\nstruct VCL_conf {\n\tunsigned\tmagic;\n"); + vsb_cat(sb, "\n/* VCL Methods */\n#define VCL_MET_RECV\t\t(1 << 0)\n"); + vsb_cat(sb, "#define VCL_MET_PIPE\t\t(1 << 1)\n"); + vsb_cat(sb, "#define VCL_MET_PASS\t\t(1 << 2)\n"); + vsb_cat(sb, "#define VCL_MET_HASH\t\t(1 << 3)\n"); + vsb_cat(sb, "#define VCL_MET_MISS\t\t(1 << 4)\n"); + vsb_cat(sb, "#define VCL_MET_HIT\t\t(1 << 5)\n"); + vsb_cat(sb, "#define VCL_MET_FETCH\t\t(1 << 6)\n"); + vsb_cat(sb, "#define VCL_MET_DELIVER\t\t(1 << 7)\n"); + vsb_cat(sb, "#define VCL_MET_PREFETCH\t(1 << 8)\n"); + vsb_cat(sb, "#define VCL_MET_TIMEOUT\t\t(1 << 9)\n"); + vsb_cat(sb, "#define VCL_MET_DISCARD\t\t(1 << 10)\n"); + vsb_cat(sb, "#define VCL_MET_ERROR\t\t(1 << 11)\n"); + vsb_cat(sb, "\n#define VCL_MET_MAX\t\t12\n\n"); + vsb_cat(sb, "/* VCL Returns */\n#define VCL_RET_ERROR\t\t(1 << 0)\n"); + vsb_cat(sb, "#define VCL_RET_LOOKUP\t\t(1 << 1)\n"); + vsb_cat(sb, "#define VCL_RET_HASH\t\t(1 << 2)\n"); + vsb_cat(sb, "#define VCL_RET_PIPE\t\t(1 << 3)\n"); + vsb_cat(sb, "#define VCL_RET_PASS\t\t(1 << 4)\n"); + vsb_cat(sb, "#define VCL_RET_FETCH\t\t(1 << 5)\n"); + vsb_cat(sb, "#define VCL_RET_DELIVER\t\t(1 << 6)\n"); + vsb_cat(sb, "#define VCL_RET_DISCARD\t\t(1 << 7)\n"); + vsb_cat(sb, "#define VCL_RET_KEEP\t\t(1 << 8)\n"); + vsb_cat(sb, "#define VCL_RET_RESTART\t\t(1 << 9)\n"); + vsb_cat(sb, "\n#define VCL_RET_MAX\t\t10\n\n"); + vsb_cat(sb, "struct VCL_conf {\n\tunsigned\tmagic;\n"); vsb_cat(sb, "#define VCL_CONF_MAGIC\t0x7406c509\t/* from /dev/rando"); vsb_cat(sb, "m */\n\n\tstruct director\t**director;\n"); vsb_cat(sb, "\tunsigned\tndirector;\n\tstruct vrt_ref\t*ref;\n"); @@ -223,10 +247,10 @@ vcl_output_lang_h(struct vsb *sb) vsb_cat(sb, " * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWI"); vsb_cat(sb, "SE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFT"); vsb_cat(sb, "WARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n"); - vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 3393 2008-11-14 09:"); - vsb_cat(sb, "49:28Z phk $\n *\n * Runtime support for compiled VCL "); - vsb_cat(sb, "programs.\n *\n * XXX: When this file is changed, lib/"); - vsb_cat(sb, "libvcl/vcc_gen_fixed_token.tcl\n"); + vsb_cat(sb, " * SUCH DAMAGE.\n *\n * $Id: vrt.h 3406 2008-11-19 14:"); + vsb_cat(sb, "13:57Z petter $\n *\n * Runtime support for compiled V"); + vsb_cat(sb, "CL programs.\n *\n * XXX: When this file is changed, l"); + vsb_cat(sb, "ib/libvcl/vcc_gen_fixed_token.tcl\n"); vsb_cat(sb, " * XXX: *MUST* be rerun.\n */\n"); vsb_cat(sb, "\nstruct sess;\nstruct vsb;\nstruct cli;\n"); vsb_cat(sb, "struct director;\nstruct VCL_conf;\n"); @@ -311,9 +335,9 @@ vcl_output_lang_h(struct vsb *sb) /* ../../include/vrt_obj.h */ - vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 3324 2008-10-18 20:50:10Z "); - vsb_cat(sb, "phk $\n *\n * NB: This file is machine generated, DO "); - vsb_cat(sb, "NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n"); + vsb_cat(sb, "/*\n * $Id: vrt_obj.h 3406 2008-11-19 14:13:57Z petter"); + vsb_cat(sb, " $\n *\n * NB: This file is machine generated, DO NOT"); + vsb_cat(sb, " EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n"); vsb_cat(sb, " */\n\nstruct sockaddr * VRT_r_client_ip(const struct "); vsb_cat(sb, "sess *);\nstruct sockaddr * VRT_r_server_ip(struct ses"); vsb_cat(sb, "s *);\nint VRT_r_server_port(struct sess *);\n"); diff --git a/varnish-cache/lib/libvcl/vcc_parse.c b/varnish-cache/lib/libvcl/vcc_parse.c index 6dcefa04..2e805a31 100644 --- a/varnish-cache/lib/libvcl/vcc_parse.c +++ b/varnish-cache/lib/libvcl/vcc_parse.c @@ -540,7 +540,7 @@ Function(struct tokenlist *tl) m = IsMethod(tl->t); if (m != -1) { - assert(m < N_METHODS); + assert(m < VCL_MET_MAX); tl->fb = tl->fm[m]; if (tl->mprocs[m] == NULL) { tl->mprocs[m] = vcc_AddProc(tl, tl->t); diff --git a/varnish-cache/lib/libvcl/vcc_token_defs.h b/varnish-cache/lib/libvcl/vcc_token_defs.h index d417655a..26b0b1bd 100644 --- a/varnish-cache/lib/libvcl/vcc_token_defs.h +++ b/varnish-cache/lib/libvcl/vcc_token_defs.h @@ -3,7 +3,7 @@ * * NB: This file is machine generated, DO NOT EDIT! * - * Edit vcc_gen_fixed_token.tcl instead + * Edit and run vcc_gen_fixed_token.tcl instead */ #define LOW_TOKEN 128 -- 2.39.5