[master] dc4a889cb Implementing ZERO_OBJ macro proposal.

Poul-Henning Kamp phk at FreeBSD.org
Mon Sep 16 11:37:05 UTC 2019


commit dc4a889cb300e9a22d6ba4970ab7079a572bf337
Author: David Carlier <devnexen at gmail.com>
Date:   Wed Sep 11 09:56:59 2019 +0100

    Implementing ZERO_OBJ macro proposal.
    
    - According to #3051, this does not seem too obvious to be
    properly detected on Linux systems.
    - Some other OSes prefer to play in their own 'backyard',
    having similar feature but named differently (e.g. NetBSD)
    would need addition autotools check.
    - Thus proposing implementing the macro with the volatile
    pointer approach rather than memory fence's, sufficient to
    prevent compiler optimisations.

diff --git a/include/miniobj.h b/include/miniobj.h
index b714c70e1..8da6ef42e 100644
--- a/include/miniobj.h
+++ b/include/miniobj.h
@@ -5,11 +5,11 @@
  *
  */
 
-#ifdef HAVE_EXPLICIT_BZERO
-#  define ZERO_OBJ(to, sz)	explicit_bzero(to, sz)
-#else
-#  define ZERO_OBJ(to, sz)	(void)memset(to, 0, sz)
-#endif
+#define ZERO_OBJ(to, sz)						\
+	do {								\
+		void *(*volatile z_obj)(void *, int, size_t) = memset;	\
+		(void)z_obj(to, 0, sz);					\
+	} while (0)
 
 #define INIT_OBJ(to, type_magic)					\
 	do {								\
diff --git a/varnish.m4 b/varnish.m4
index 392c36c60..b9899f613 100644
--- a/varnish.m4
+++ b/varnish.m4
@@ -62,12 +62,6 @@ AC_DEFUN([_VARNISH_SEARCH_LIBS], [
 	LIBS="${save_LIBS}"
 ])
 
-# _VARNISH_CHECK_EXPLICIT_BZERO()
-# -------------------------------
-AC_DEFUN([_VARNISH_CHECK_EXPLICIT_BZERO], [
-	AC_CHECK_FUNCS([explicit_bzero])
-])
-
 # _VARNISH_PKG_CONFIG
 # --------------------
 AC_DEFUN([_VARNISH_PKG_CONFIG], [


More information about the varnish-commit mailing list