[master] 8a7253e Rename VSM_common to CVSM and hide it from vmods

Poul-Henning Kamp phk at FreeBSD.org
Sun May 28 09:18:06 CEST 2017


commit 8a7253e25aa54e46d004e060bddc04d331e56bbf
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Sun May 28 04:44:47 2017 +0000

    Rename VSM_common to CVSM and hide it from vmods

diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am
index e35a2f2..4d3262d 100644
--- a/bin/varnishd/Makefile.am
+++ b/bin/varnishd/Makefile.am
@@ -120,6 +120,7 @@ noinst_HEADERS = \
 	cache/cache_priv.h \
 	cache/cache_transport.h \
 	common/heritage.h \
+	common/common_vsm.h \
 	hash/hash_slinger.h \
 	hpack/vhp.h \
 	http1/cache_http1.h \
diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index 310df37..969ff97 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -36,6 +36,7 @@
 #include <stdlib.h>
 
 #include "common/heritage.h"
+#include "common/common_vsm.h"
 
 #include "vend.h"
 #include "vgz.h"
@@ -547,7 +548,7 @@ vsm_cleaner(void *priv)
 	THR_SetName("vsm_cleaner");
 	while (1) {
 		AZ(pthread_mutex_lock(&vsm_mtx));
-		VSM_common_cleaner(heritage.vsm, (void*)VSC_C_main);
+		CVSM_cleaner(heritage.vsm, (void*)VSC_C_main);
 		AZ(pthread_mutex_unlock(&vsm_mtx));
 		VTIM_sleep(1.1);
 	}
@@ -603,7 +604,7 @@ VSM_Alloc(unsigned size, const char *class, const char *type,
 	volatile void *p;
 
 	AZ(pthread_mutex_lock(&vsm_mtx));
-	p = VSM_common_alloc(heritage.vsm, size, class, type, ident);
+	p = CVSM_alloc(heritage.vsm, size, class, type, ident);
 	AZ(pthread_mutex_unlock(&vsm_mtx));
 	return (TRUST_ME(p));
 }
@@ -613,6 +614,6 @@ VSM_Free(void *ptr)
 {
 
 	AZ(pthread_mutex_lock(&vsm_mtx));
-	VSM_common_free(heritage.vsm, ptr);
+	CVSM_free(heritage.vsm, ptr);
 	AZ(pthread_mutex_unlock(&vsm_mtx));
 }
diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h
index 00a8dc6..cbbeb47 100644
--- a/bin/varnishd/common/common.h
+++ b/bin/varnishd/common/common.h
@@ -78,21 +78,5 @@ const struct transport *XPORT_Find(const char *name);
 /* cache/cache_vcl.c */
 int VCL_TestLoad(const char *);
 
-/* common_vsm.c */
-struct vsm_sc;
-struct VSC_main;
-struct vsm_sc *VSM_common_new(void *ptr, ssize_t len);
-void *VSM_common_alloc(struct vsm_sc *sc, ssize_t size,
-    const char *class, const char *type, const char *ident);
-void VSM_common_free(struct vsm_sc *sc, void *ptr);
-void VSM_common_delete(struct vsm_sc **sc);
-void VSM_common_copy(struct vsm_sc *to, const struct vsm_sc *from);
-void VSM_common_cleaner(struct vsm_sc *sc, struct VSC_main *stats);
-void VSM_common_ageupdate(const struct vsm_sc *sc);
-
-void *VSC_Alloc(const char *, size_t, size_t, const unsigned char *, size_t,
-    const char *, va_list);
-void VSC_Destroy(const char *, const void *);
-
 /* mgt_cli.c */
 extern struct VCLS	*mgt_cls;
diff --git a/bin/varnishd/common/common_vsm.c b/bin/varnishd/common/common_vsm.c
index fb30c70..f900b26 100644
--- a/bin/varnishd/common/common_vsm.c
+++ b/bin/varnishd/common/common_vsm.c
@@ -40,6 +40,7 @@
 
 #include "common.h"
 #include "common/com_params.h"
+#include "common/common_vsm.h"
 
 #include "vsm_priv.h"
 #include "vmb.h"
@@ -127,7 +128,7 @@ vsm_common_insert_free(struct vsm_sc *sc, struct vsm_range *vr)
  */
 
 struct vsm_sc *
-VSM_common_new(void *p, ssize_t l)
+CVSM_new(void *p, ssize_t l)
 {
 	struct vsm_sc *sc;
 	struct vsm_range *vr;
@@ -167,7 +168,7 @@ VSM_common_new(void *p, ssize_t l)
  */
 
 void
-VSM_common_cleaner(struct vsm_sc *sc, struct VSC_main *stats)
+CVSM_cleaner(struct vsm_sc *sc, struct VSC_main *stats)
 {
 	double now = VTIM_real();
 	struct vsm_range *vr, *vr2;
@@ -195,7 +196,7 @@ VSM_common_cleaner(struct vsm_sc *sc, struct VSC_main *stats)
  */
 
 void *
-VSM_common_alloc(struct vsm_sc *sc, ssize_t size,
+CVSM_alloc(struct vsm_sc *sc, ssize_t size,
     const char *class, const char *type, const char *ident)
 {
 	struct vsm_range *vr, *vr2, *vr3;
@@ -286,7 +287,7 @@ VSM_common_alloc(struct vsm_sc *sc, ssize_t size,
  */
 
 void
-VSM_common_free(struct vsm_sc *sc, void *ptr)
+CVSM_free(struct vsm_sc *sc, void *ptr)
 {
 	struct vsm_range *vr, *vr2;
 
@@ -337,7 +338,7 @@ VSM_common_free(struct vsm_sc *sc, void *ptr)
  */
 
 void
-VSM_common_delete(struct vsm_sc **scp)
+CVSM_delete(struct vsm_sc **scp)
 {
 	struct vsm_range *vr, *vr2;
 	struct vsm_sc *sc;
@@ -366,7 +367,7 @@ VSM_common_delete(struct vsm_sc **scp)
  */
 
 void
-VSM_common_copy(struct vsm_sc *to, const struct vsm_sc *from)
+CVSM_copy(struct vsm_sc *to, const struct vsm_sc *from)
 {
 	struct vsm_range *vr;
 	void *p;
@@ -374,7 +375,7 @@ VSM_common_copy(struct vsm_sc *to, const struct vsm_sc *from)
 	CHECK_OBJ_NOTNULL(to, VSM_SC_MAGIC);
 	CHECK_OBJ_NOTNULL(from, VSM_SC_MAGIC);
 	VTAILQ_FOREACH(vr, &from->r_used, list) {
-		p = VSM_common_alloc(to, vr->chunk->len,
+		p = CVSM_alloc(to, vr->chunk->len,
 		    vr->chunk->class, vr->chunk->type, vr->chunk->ident);
 		AN(p);
 		memcpy(p, vr->chunk + 1, vr->chunk->len);
@@ -386,7 +387,7 @@ VSM_common_copy(struct vsm_sc *to, const struct vsm_sc *from)
  */
 
 void
-VSM_common_ageupdate(const struct vsm_sc *sc)
+CVSM_ageupdate(const struct vsm_sc *sc)
 {
 
 	CHECK_OBJ_NOTNULL(sc, VSM_SC_MAGIC);
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index 809c006..85113f8 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -43,6 +43,7 @@
 
 #include "mgt/mgt.h"
 #include "common/heritage.h"
+#include "common/common_vsm.h"
 
 #include "hash/hash_slinger.h"
 #include "vav.h"
@@ -448,7 +449,7 @@ mgt_uptime(const struct vev *e, int what)
 	VSC_C_mgt->uptime = static_VSC_C_mgt.uptime =
 	    (uint64_t)(VTIM_real() - mgt_uptime_t0);
 	if (heritage.vsm != NULL)
-		VSM_common_ageupdate(heritage.vsm);
+		CVSM_ageupdate(heritage.vsm);
 	return (0);
 }
 
diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c
index 914a5ef..7c05ff7 100644
--- a/bin/varnishd/mgt/mgt_shmem.c
+++ b/bin/varnishd/mgt/mgt_shmem.c
@@ -40,6 +40,7 @@
 
 #include "mgt/mgt.h"
 #include "common/heritage.h"
+#include "common/common_vsm.h"
 
 #include "vfl.h"
 #include "vsm_priv.h"
@@ -72,11 +73,11 @@ mgt_SHM_static_alloc(const void *ptr, ssize_t size,
 {
 	void *p;
 
-	p = VSM_common_alloc(static_vsm, size, class, type, ident);
+	p = CVSM_alloc(static_vsm, size, class, type, ident);
 	AN(p);
 	memcpy(p, ptr, size);
 	if (heritage.vsm != NULL) {
-		p = VSM_common_alloc(heritage.vsm, size, class, type, ident);
+		p = CVSM_alloc(heritage.vsm, size, class, type, ident);
 		AN(p);
 		memcpy(p, ptr, size);
 	}
@@ -178,17 +179,17 @@ mgt_SHM_Create(void)
 	/* This may or may not work */
 	(void)mlock(p, size);
 
-	heritage.vsm = VSM_common_new(p, size);
+	heritage.vsm = CVSM_new(p, size);
 
-	VSM_common_copy(heritage.vsm, static_vsm);
+	CVSM_copy(heritage.vsm, static_vsm);
 
-	heritage.param = VSM_common_alloc(heritage.vsm,
+	heritage.param = CVSM_alloc(heritage.vsm,
 	    sizeof *heritage.param, VSM_CLASS_PARAM, "", "");
 	AN(heritage.param);
 	*heritage.param = mgt_param;
 
 	heritage.panic_str_len = 64 * 1024;
-	heritage.panic_str = VSM_common_alloc(heritage.vsm,
+	heritage.panic_str = CVSM_alloc(heritage.vsm,
 	    heritage.panic_str_len, PAN_CLASS, "", "");
 	AN(heritage.panic_str);
 
@@ -228,7 +229,7 @@ mgt_SHM_Destroy(int keep)
 	heritage.panic_str = NULL;
 	heritage.panic_str_len = 0;
 	heritage.param = NULL;
-	VSM_common_delete(&heritage.vsm);
+	CVSM_delete(&heritage.vsm);
 	AZ(munmap(mgt_vsm_p, mgt_vsm_l));
 	mgt_vsm_p = NULL;
 	mgt_vsm_l = 0;
@@ -261,7 +262,7 @@ mgt_shm_atexit(void)
 	if (getpid() != mgt_pid)
 		return;
 	if (heritage.vsm != NULL)
-		VSM_common_delete(&heritage.vsm);
+		CVSM_delete(&heritage.vsm);
 }
 
 /*--------------------------------------------------------------------
@@ -272,7 +273,7 @@ void
 mgt_SHM_Init(void)
 {
 	/* Create our static VSM instance */
-	static_vsm = VSM_common_new(static_vsm_buf, sizeof static_vsm_buf);
+	static_vsm = CVSM_new(static_vsm_buf, sizeof static_vsm_buf);
 
 	/* Setup atexit handler */
 	AZ(atexit(mgt_shm_atexit));
diff --git a/lib/libvcc/vsctool.py b/lib/libvcc/vsctool.py
index 13f7c01..bc7abfb 100644
--- a/lib/libvcc/vsctool.py
+++ b/lib/libvcc/vsctool.py
@@ -155,7 +155,9 @@ class vscset(object):
 		fo.write('#include <stdarg.h>\n')
 		fo.write('#include <stdio.h>\n')
 		fo.write('#include <stdint.h>\n')
-		fo.write('#include "common/common.h"\n')
+		fo.write('#include "vdef.h"\n')
+		fo.write('#include "vas.h"\n')
+		fo.write('#include "common/common_vsm.h"\n')
 		fo.write('#include "VSC_%s.h"\n' % self.name)
 
 		fo.write("\n")



More information about the varnish-commit mailing list