[master] 519f383 Don't have two copies of the param->bitmap magic

Poul-Henning Kamp phk at FreeBSD.org
Wed Sep 27 08:45:11 UTC 2017


commit 519f3839e0b26b304306a9bf5b64bbefc87d705d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Sep 27 08:32:32 2017 +0000

    Don't have two copies of the param->bitmap magic

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 7f0a3c7..987cbd1 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1062,19 +1062,8 @@ Tlen(const txt t)
  */
 #define W_TIM_real(w) ((w)->lastused = VTIM_real())
 
-static inline int
-FEATURE(enum feature_bits x)
-{
-	return (cache_param->feature_bits[(unsigned)x>>3] &
-	    (0x80U >> ((unsigned)x & 7)));
-}
-
-static inline int
-DO_DEBUG(enum debug_bits x)
-{
-	return (cache_param->debug_bits[(unsigned)x>>3] &
-	    (0x80U >> ((unsigned)x & 7)));
-}
+#define FEATURE(x)	COM_FEATURE(cache_param->feature_bits, x)
+#define DO_DEBUG(x)	COM_DO_DEBUG(cache_param->debug_bits, x)
 
 #define DSL(debug_bit, id, ...)					\
 	do {							\
diff --git a/bin/varnishd/common/common_param.h b/bin/varnishd/common/common_param.h
index a131697..ee9a12b 100644
--- a/bin/varnishd/common/common_param.h
+++ b/bin/varnishd/common/common_param.h
@@ -44,12 +44,25 @@ enum debug_bits {
        DBG_Reserved
 };
 
+static inline int
+COM_DO_DEBUG(uint8_t volatile *p, enum debug_bits x)
+{
+	return (p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7)));
+}
+
 enum feature_bits {
 #define FEATURE_BIT(U, l, d, ld) FEATURE_##U,
 #include "tbl/feature_bits.h"
        FEATURE_Reserved
 };
 
+static inline int
+COM_FEATURE(uint8_t volatile *p, enum feature_bits x)
+{
+	return (p[(unsigned)x>>3] & (0x80U >> ((unsigned)x & 7)));
+}
+
+
 struct poolparam {
 	unsigned		min_pool;
 	unsigned		max_pool;
diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index 0262880..b8f23bf 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -226,16 +226,5 @@ extern unsigned mgt_vcc_unsafe_path;
 #error "Keep pthreads out of in manager process"
 #endif
 
-static inline int
-MGT_FEATURE(enum feature_bits x)
-{
-	return (mgt_param.feature_bits[(unsigned)x>>3] &
-	    (0x80U >> ((unsigned)x & 7)));
-}
-
-static inline int
-MGT_DO_DEBUG(enum debug_bits x)
-{
-	return (mgt_param.debug_bits[(unsigned)x>>3] &
-	    (0x80U >> ((unsigned)x & 7)));
-}
+#define MGT_FEATURE(x)	COM_FEATURE(mgt_param.feature_bits, x)
+#define MGT_DO_DEBUG(x)	COM_DO_DEBUG(mgt_param.feature_bits, x)


More information about the varnish-commit mailing list