Commit 18ad341a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Support for optional Summing function.

We don't optimize but emit straight C-code summing each element in
turn, so that it will work with any arithmetic C type down the road.
parent 78cb6599
......@@ -7,6 +7,7 @@
.. varnish_vsc_begin:: main
:oneliner: Main counters
:sumfunction:
.. varnish_vsc:: uptime
:oneliner: Child process uptime
......
......@@ -120,11 +120,18 @@ class vscset(object):
fo.write("\tuint64_t\t%s;\n" % i.arg)
fo.write("};\n")
fo.write("\n");
fo.write(self.struct + " *VSC_" + self.name + "_New")
fo.write("(const char *fmt, ...);\n");
fo.write("void VSC_" + self.name + "_Destroy")
fo.write("(" + self.struct + "**);\n")
if 'sumfunction' in self.head.param:
fo.write("void VSC_" + self.name + "_Summ")
fo.write("(" + self.struct + " *, ")
fo.write("const " + self.struct + " *);\n")
def emit_c(self):
fon="VSC_" + self.name + ".c"
fo = open(fon, "w")
......@@ -140,6 +147,7 @@ class vscset(object):
(self.name, self.name.upper()))
self.emit_json(fo)
fo.write("\n")
fo.write(self.struct + "*\n");
fo.write("VSC_" + self.name + "_New")
......@@ -159,6 +167,7 @@ class vscset(object):
fo.write("\tva_end(ap);\n")
fo.write("\treturn(retval);\n")
fo.write("}\n")
fo.write("\n")
fo.write("void\n")
fo.write("VSC_" + self.name + "_Destroy")
......@@ -170,6 +179,21 @@ class vscset(object):
fo.write("\t*pp = NULL;\n")
fo.write("}\n")
if 'sumfunction' in self.head.param:
fo.write("\n")
fo.write("void\n")
fo.write("VSC_" + self.name + "_Summ")
fo.write("(" + self.struct + " *dst, ")
fo.write("const " + self.struct + " *src)\n")
fo.write("{\n")
fo.write("\n")
fo.write("\tAN(dst);\n")
fo.write("\tAN(src);\n")
for i in self.mbrs:
fo.write("\tdst->" + i.arg)
fo.write(" += src->" + i.arg + ";\n")
fo.write("}\n")
#######################################################################
class directive(object):
......
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