Commit 38ec8770 authored by Tollef Fog Heen's avatar Tollef Fog Heen

Merge r3482+r3483: Move the enum MET/RET macros to vcl.h



git-svn-id: http://www.varnish-cache.org/svn/branches/2.0@3675 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 3df2a6fe
......@@ -54,7 +54,6 @@
#include "libvarnish.h"
#include "vcl_returns.h"
#include "common.h"
#include "heritage.h"
#include "miniobj.h"
......
......@@ -60,6 +60,7 @@
#include "shmlog.h"
#include "binary_heap.h"
#include "cache.h"
#include "vcl.h"
#include "hash_slinger.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 */
......
......@@ -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
......@@ -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);
......
......@@ -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;
......
......@@ -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"
......@@ -169,12 +169,36 @@ vcl_output_lang_h(struct vsb *sb)
vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 3601 2009-02-05 10");
vsb_cat(sb, ":21:48Z 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, "erated, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixe");
vsb_cat(sb, "d_token.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");
......@@ -311,9 +335,9 @@ vcl_output_lang_h(struct vsb *sb)
/* ../../include/vrt_obj.h */
vsb_cat(sb, "/*\n * $Id: vrt_obj.h 3616 2009-02-05 11:43:20Z tfheen");
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 * $Id: vcc_gen_obj.tcl 3616 2009-02-05 11:43:20Z ");
vsb_cat(sb, "tfheen $\n *\n * NB: This file is machine generated, ");
vsb_cat(sb, "DO NOT 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");
......
......@@ -109,7 +109,7 @@ proc warns {fd} {
puts $fd " *"
puts $fd " * NB: This file is machine generated, DO NOT EDIT!"
puts $fd " *"
puts $fd " * Edit vcc_gen_fixed_token.tcl instead"
puts $fd " * Edit and run vcc_gen_fixed_token.tcl instead"
puts $fd " */"
puts $fd ""
}
......@@ -126,6 +126,29 @@ typedef void vcl_init_f(struct cli *);
typedef void vcl_fini_f(struct cli *);
typedef int vcl_func_f(struct sess *sp);
}
puts $fo "/* VCL Methods */"
set u 0
foreach m $methods {
if {[string length [lindex $m 0]] < 8} {
set sp "\t"
} else {
set sp ""
}
puts $fo "#define VCL_MET_[string toupper [lindex $m 0]]\t${sp}(1 << $u)"
incr u
}
puts $fo "\n#define VCL_MET_MAX\t\t$u\n"
puts $fo "/* VCL Returns */"
set i 0
foreach k $returns {
puts $fo "#define VCL_RET_[string toupper $k]\t\t(1 << $i)"
incr i
}
puts $fo "\n#define VCL_RET_MAX\t\t$i\n"
puts $fo "struct VCL_conf {"
puts $fo { unsigned magic;
#define VCL_CONF_MAGIC 0x7406c509 /* from /dev/random */
......@@ -171,13 +194,6 @@ foreach k $returns {
}
incr i
}
puts $for "#else"
set i 0
foreach k $returns {
puts $for "#define VCL_RET_[string toupper $k] (1 << $i)"
incr i
}
puts $for "#define VCL_RET_MAX $i"
puts $for "#endif"
puts $for ""
puts $for "#ifdef VCL_MET_MAC"
......@@ -186,7 +202,7 @@ foreach m $methods {
puts -nonewline $for "VCL_MET_MAC([lindex $m 0]"
puts -nonewline $for ",[string toupper [lindex $m 0]]"
set l [lindex $m 1]
puts -nonewline $for ",(\n VCL_RET_[string toupper [lindex $l 0]]"
puts -nonewline $for ",\n (VCL_RET_[string toupper [lindex $l 0]]"
foreach r [lrange $l 1 end] {
puts -nonewline $for "|VCL_RET_[string toupper $r]"
}
......@@ -194,14 +210,7 @@ foreach m $methods {
puts $for ")"
incr u
}
puts $for "#else"
set u 0
foreach m $methods {
puts $for "#define VCL_MET_[string toupper [lindex $m 0]]\t(1 << $u)"
incr u
}
puts $for "#endif"
puts $for "#define N_METHODS $u"
close $for
#----------------------------------------------------------------------
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment