summaryrefslogtreecommitdiffstats
path: root/crypto/engine/engine_int.h
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/engine/engine_int.h')
-rw-r--r--crypto/engine/engine_int.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/crypto/engine/engine_int.h b/crypto/engine/engine_int.h
index d44f648559..54cfe47af7 100644
--- a/crypto/engine/engine_int.h
+++ b/crypto/engine/engine_int.h
@@ -66,6 +66,29 @@
extern "C" {
#endif
+#define ENGINE_REF_COUNT_DEBUG
+
+/* If we compile with this symbol defined, then both reference counts in the
+ * ENGINE structure will be monitored with a line of output on stderr for each
+ * change. This prints the engine's pointer address (truncated to unsigned int),
+ * "struct" or "funct" to indicate the reference type, the before and after
+ * reference count, and the file:line-number pair. The "engine_ref_debug"
+ * statements must come *after* the change. */
+#ifdef ENGINE_REF_COUNT_DEBUG
+
+#define engine_ref_debug(e, isfunct, diff) \
+ fprintf(stderr, "blargle: %08x %s from %d to %d (%s:%d)\n", \
+ (unsigned int)(e), (isfunct ? "funct" : "struct"), \
+ ((isfunct) ? ((e)->funct_ref - (diff)) : ((e)->struct_ref - (diff))), \
+ ((isfunct) ? (e)->funct_ref : (e)->struct_ref), \
+ (__FILE__), (__LINE__));
+
+#else
+
+#define engine_ref_debug(e, isfunct, diff)
+
+#endif
+
/* NB: Bitwise OR-able values for the "flags" variable in ENGINE are now exposed
* in engine.h. */