[master] 1474cf3 Mark stuff we export in shlibs with "extern".

Poul-Henning Kamp phk at varnish-cache.org
Tue Nov 12 23:58:45 CET 2013


commit 1474cf378ca7aae8fdc95e0b984f1c0dd012c682
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Nov 12 22:41:28 2013 +0000

    Mark stuff we export in shlibs with "extern".

diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c
index 70f976a..a1d3b9b 100644
--- a/lib/libvcc/vcc_compile.c
+++ b/lib/libvcc/vcc_compile.c
@@ -355,6 +355,7 @@ EmitStruct(const struct vcc *tl)
 {
 	struct source *sp;
 
+	Fc(tl, 0, "\nextern const char *srcname[];\n");
 	Fc(tl, 0, "\nconst char *srcname[%u] = {\n", tl->nsources);
 	VTAILQ_FOREACH(sp, &tl->sources, list) {
 		Fc(tl, 0, "\t");
@@ -363,6 +364,7 @@ EmitStruct(const struct vcc *tl)
 	}
 	Fc(tl, 0, "};\n");
 
+	Fc(tl, 0, "\nextern const char *srcbody[];\n");
 	Fc(tl, 0, "\nconst char *srcbody[%u] = {\n", tl->nsources);
 	VTAILQ_FOREACH(sp, &tl->sources, list) {
 		Fc(tl, 0, "    /* ");
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index 95e4a7a..c868656 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -547,7 +547,7 @@ vcc_func(struct vcc *tl, struct expr **e, const char *cfunc,
 			p += strlen(p) + 1;
 		} else if (fmt == VOID && !strcmp(p, "PRIV_CALL")) {
 			bprintf(buf, "vmod_priv_%u", tl->nvmodpriv++);
-			Fh(tl, 0, "struct vmod_priv %s;\n", buf);
+			Fh(tl, 0, "static struct vmod_priv %s;\n", buf);
 			e2 = vcc_mk_expr(VOID, "&%s", buf);
 			p += strlen(p) + 1;
 		} else if (fmt == ENUM) {
diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py
index 2b6db42..6d62bce 100755
--- a/lib/libvcc/vmodtool.py
+++ b/lib/libvcc/vmodtool.py
@@ -145,31 +145,40 @@ class vmod(object):
 			fo.write(i + "\n")
 
 	def c_vmod(self, fo):
+		fo.write('extern const char Vmod_' + self.nam + '_Name[];\n')
 		fo.write('const char Vmod_' + self.nam + '_Name[] =')
 		fo.write(' \"' + self.nam + '";\n')
 		fo.write("\n")
 
 		cs = self.c_struct()
-		fo.write("const " + cs + ' Vmod_' + self.nam + '_Func = ')
+		fo.write(cs + ';\n')
+
+		vfn = 'Vmod_' + self.nam + '_Func';
+
+		fo.write("extern const struct " + vfn + " " + vfn + ';\n')
+		fo.write("const struct " + vfn + " " + vfn + ' =')
 		fo.write(self.c_initializer())
 		fo.write("\n")
 
 		fo.write("\n")
+		fo.write("extern const int Vmod_" + self.nam + '_Len;\n')
 		fo.write("const int Vmod_" + self.nam + '_Len =')
 		fo.write(" sizeof(Vmod_" + self.nam + "_Func);\n")
 		fo.write("\n")
 
+		fo.write("extern const char Vmod_" + self.nam + "_Proto[];\n")
 		fo.write("const char Vmod_" + self.nam + "_Proto[] =\n")
 		for t in self.c_typedefs_():
 			fo.write('\t"' + t + '\\n"\n')
 		fo.write('\t"\\n"\n')
-		for i in (cs + " Vmod_" + self.nam + '_Func;').split("\n"):
+		for i in (cs + ";").split("\n"):
 			fo.write('\n\t"' + i + '\\n"')
-		fo.write(";\n\n")
+		fo.write('\n\t"static struct ' + vfn + " " + vfn + ';";\n\n')
 
 		fo.write(self.c_strspec())
 
 		fo.write("\n")
+		fo.write('extern const char Vmod_' + self.nam + '_ABI[];\n')
 		fo.write('const char Vmod_' + self.nam + '_ABI[] =')
 		fo.write(' VMOD_ABI_Version;\n')
 		#fo.write("\n")
@@ -208,7 +217,8 @@ class vmod(object):
 		return s
 
 	def c_strspec(self):
-		s = "const char * const Vmod_" + self.nam + "_Spec[] = {\n"
+		s = "const char * const Vmod_" + self.nam + "_Spec[]"
+		s = "extern " + s + ";\n" + s + " = {\n"
 
 		for o in self.objs:
 			s += o.c_strspec(self.nam)



More information about the varnish-commit mailing list