r4884 - in trunk/varnish-cache: bin/varnishd include lib/libvarnish lib/libvarnishapi

phk at varnish-cache.org phk at varnish-cache.org
Fri Jun 4 13:19:57 CEST 2010


Author: phk
Date: 2010-06-04 13:19:57 +0200 (Fri, 04 Jun 2010)
New Revision: 4884

Added:
   trunk/varnish-cache/include/vas.h
Modified:
   trunk/varnish-cache/bin/varnishd/cache_panic.c
   trunk/varnish-cache/bin/varnishd/cache_vrt.c
   trunk/varnish-cache/include/Makefile.am
   trunk/varnish-cache/include/libvarnish.h
   trunk/varnish-cache/lib/libvarnish/assert.c
   trunk/varnish-cache/lib/libvarnish/num.c
   trunk/varnish-cache/lib/libvarnishapi/Makefile.am
   trunk/varnish-cache/lib/libvarnishapi/vsl.c
   trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c
   trunk/varnish-cache/lib/libvarnishapi/vsl_log.c
Log:
Use the same assert code in libvarnishapi as in libvarnish



Modified: trunk/varnish-cache/bin/varnishd/cache_panic.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_panic.c	2010-06-04 10:52:58 UTC (rev 4883)
+++ trunk/varnish-cache/bin/varnishd/cache_panic.c	2010-06-04 11:19:57 UTC (rev 4884)
@@ -367,7 +367,7 @@
 PAN_Init(void)
 {
 
-	lbv_assert = pan_ic;
+	vas_fail = pan_ic;
 	vsp = &vsps;
 	AN(vsb_new(vsp, loghead->panicstr, sizeof loghead->panicstr,
 	    VSB_FIXEDLEN));

Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c	2010-06-04 10:52:58 UTC (rev 4883)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c	2010-06-04 11:19:57 UTC (rev 4884)
@@ -902,7 +902,7 @@
 	va_start(ap, str);
 	b = vrt_assemble_string(sp->http, "PANIC: ", str, ap);
 	va_end(ap);
-	lbv_assert("VCL", "", 0, b, 0, 2);
+	vas_fail("VCL", "", 0, b, 0, 2);
 }
 
 /*--------------------------------------------------------------------*/

Modified: trunk/varnish-cache/include/Makefile.am
===================================================================
--- trunk/varnish-cache/include/Makefile.am	2010-06-04 10:52:58 UTC (rev 4883)
+++ trunk/varnish-cache/include/Makefile.am	2010-06-04 11:19:57 UTC (rev 4884)
@@ -29,6 +29,7 @@
 	persistent.h \
 	purge_vars.h \
 	svnid.h \
+	vas.h \
 	vsha256.h \
 	vqueue.h \
 	vpf.h \

Modified: trunk/varnish-cache/include/libvarnish.h
===================================================================
--- trunk/varnish-cache/include/libvarnish.h	2010-06-04 10:52:58 UTC (rev 4883)
+++ trunk/varnish-cache/include/libvarnish.h	2010-06-04 11:19:57 UTC (rev 4884)
@@ -33,6 +33,8 @@
 #include <time.h>
 #include <stdint.h>
 
+#include "vas.h"
+
 #ifndef NULL
 #define NULL ((void*)0)
 #endif
@@ -103,48 +105,6 @@
 int vtmpfile(char *);
 char *vreadfile(const char *fn);
 
-/*
- * assert(), AN() and AZ() are static checks that should not happen.
- *	In general asserts should be cheap, such as checking return
- *	values and similar.
- * diagnostic() are asserts which are so expensive that we may want
- *	to compile them out for performance at a later date.
- * xxxassert(), XXXAN() and XXXAZ() marks conditions we ought to
- *	handle gracefully, such as malloc failure.
- */
-
-typedef void lbv_assert_f(const char *, const char *, int, const char *,
-    int, int);
-
-extern lbv_assert_f *lbv_assert;
-
-#ifdef WITHOUT_ASSERTS
-#define assert(e)	((void)(e))
-#else /* WITH_ASSERTS */
-#define assert(e)							\
-do {									\
-	if (!(e))							\
-		lbv_assert(__func__, __FILE__, __LINE__, #e, errno, 0);	\
-} while (0)
-#endif
-
-#define xxxassert(e)							\
-do {									\
-	if (!(e))							\
-		lbv_assert(__func__, __FILE__, __LINE__, #e, errno, 1); \
-} while (0)
-
-/* Assert zero return value */
-#define AZ(foo)	do { assert((foo) == 0); } while (0)
-#define AN(foo)	do { assert((foo) != 0); } while (0)
-#define XXXAZ(foo)	do { xxxassert((foo) == 0); } while (0)
-#define XXXAN(foo)	do { xxxassert((foo) != 0); } while (0)
-#define diagnostic(foo)	assert(foo)
-#define WRONG(expl)							\
-do {									\
-	lbv_assert(__func__, __FILE__, __LINE__, expl, errno, 3);	\
-	abort();							\
-} while (0)
 const char* svn_version(void);
 
 /* Safe printf into a fixed-size buffer */

Copied: trunk/varnish-cache/include/vas.h (from rev 4881, trunk/varnish-cache/include/libvarnish.h)
===================================================================
--- trunk/varnish-cache/include/vas.h	                        (rev 0)
+++ trunk/varnish-cache/include/vas.h	2010-06-04 11:19:57 UTC (rev 4884)
@@ -0,0 +1,77 @@
+/*-
+ * Copyright (c) 2006 Verdens Gang AS
+ * Copyright (c) 2006-2009 Linpro AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id$
+ *
+ * assert(), AN() and AZ() are static checks that should not happen.
+ *	In general asserts should be cheap, such as checking return
+ *	values and similar.
+ * diagnostic() are asserts which are so expensive that we may want
+ *	to compile them out for performance at a later date.
+ * xxxassert(), XXXAN() and XXXAZ() marks conditions we ought to
+ *	handle gracefully, such as malloc failure.
+ */
+
+#ifndef VAS_H_INCLUDED
+#define VAS_H_INCLUDED
+
+#include <errno.h>
+
+typedef void vas_f(const char *, const char *, int, const char *, int, int);
+
+extern vas_f *vas_fail;
+
+#ifdef WITHOUT_ASSERTS
+#define assert(e)	((void)(e))
+#else /* WITH_ASSERTS */
+#define assert(e)							\
+do {									\
+	if (!(e))							\
+		vas_fail(__func__, __FILE__, __LINE__, #e, errno, 0);	\
+} while (0)
+#endif
+
+#define xxxassert(e)							\
+do {									\
+	if (!(e))							\
+		vas_fail(__func__, __FILE__, __LINE__, #e, errno, 1);	\
+} while (0)
+
+/* Assert zero return value */
+#define AZ(foo)		do { assert((foo) == 0); } while (0)
+#define AN(foo)		do { assert((foo) != 0); } while (0)
+#define XXXAZ(foo)	do { xxxassert((foo) == 0); } while (0)
+#define XXXAN(foo)	do { xxxassert((foo) != 0); } while (0)
+#define diagnostic(foo)	assert(foo)
+#define WRONG(expl)							\
+do {									\
+	vas_fail(__func__, __FILE__, __LINE__, expl, errno, 3);		\
+	abort();							\
+} while (0)
+
+#endif

Modified: trunk/varnish-cache/lib/libvarnish/assert.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/assert.c	2010-06-04 10:52:58 UTC (rev 4883)
+++ trunk/varnish-cache/lib/libvarnish/assert.c	2010-06-04 11:19:57 UTC (rev 4884)
@@ -41,7 +41,7 @@
 #include "libvarnish.h"
 
 static void
-lbv_assert_default(const char *func, const char *file, int line,
+vas_fail_default(const char *func, const char *file, int line,
     const char *cond, int err, int xxx)
 {
 
@@ -62,4 +62,4 @@
 	abort();
 }
 
-lbv_assert_f *lbv_assert = lbv_assert_default;
+vas_f *vas_fail = vas_fail_default;

Modified: trunk/varnish-cache/lib/libvarnish/num.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/num.c	2010-06-04 10:52:58 UTC (rev 4883)
+++ trunk/varnish-cache/lib/libvarnish/num.c	2010-06-04 11:19:57 UTC (rev 4884)
@@ -115,7 +115,7 @@
 
 #ifdef NUM_C_TEST
 /* Compile with: "cc -o foo -DNUM_C_TEST -I../.. -I../../include num.c -lm" */
-#include <assert.h>
+#include "vas.h"
 #include <math.h>
 #include <stdio.h>
 #include <string.h>

Modified: trunk/varnish-cache/lib/libvarnishapi/Makefile.am
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/Makefile.am	2010-06-04 10:52:58 UTC (rev 4883)
+++ trunk/varnish-cache/lib/libvarnishapi/Makefile.am	2010-06-04 11:19:57 UTC (rev 4884)
@@ -10,6 +10,7 @@
 	vsl.h \
 	\
 	../libvarnish/vin.c \
+	../libvarnish/assert.c \
 	base64.c \
 	vsl.c \
 	vsl_arg.c \

Modified: trunk/varnish-cache/lib/libvarnishapi/vsl.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsl.c	2010-06-04 10:52:58 UTC (rev 4883)
+++ trunk/varnish-cache/lib/libvarnishapi/vsl.c	2010-06-04 11:19:57 UTC (rev 4884)
@@ -36,7 +36,6 @@
 #include <sys/mman.h>
 #include <sys/stat.h>
 
-#include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
@@ -44,6 +43,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "vas.h"
 #include "shmlog.h"
 #include "vre.h"
 #include "vbm.h"

Modified: trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c	2010-06-04 10:52:58 UTC (rev 4883)
+++ trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c	2010-06-04 11:19:57 UTC (rev 4884)
@@ -35,7 +35,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#include <assert.h>
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -44,6 +43,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "vas.h"
 #include "shmlog.h"
 #include "vre.h"
 #include "vbm.h"

Modified: trunk/varnish-cache/lib/libvarnishapi/vsl_log.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsl_log.c	2010-06-04 10:52:58 UTC (rev 4883)
+++ trunk/varnish-cache/lib/libvarnishapi/vsl_log.c	2010-06-04 11:19:57 UTC (rev 4884)
@@ -35,12 +35,12 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 
-#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
+#include "vas.h"
 #include "shmlog.h"
 #include "vre.h"
 #include "vbm.h"




More information about the varnish-commit mailing list