chiark / gitweb /
Add a pile of debug output around the CPU dispatching machinery.
[catacomb] / base / dispatch.h
index 612cfcd3a41bb49560570db2820bb34eaf054043..bbb81f30c8615e080e8290db60bcb7ec34b355a1 100644 (file)
@@ -138,8 +138,34 @@ stcls ret ext argdecls { rtn dflt args; }
 
 #endif
 
+/* --- Some macros for producing useful debugging --- */
+
+#define DISPATCH_PICK_COND(what, func, cond) do {                      \
+  if (cond) {                                                          \
+    dispatch_debug("picked `%s' for `%s'", #func, #what);              \
+    return (func);                                                     \
+  }                                                                    \
+} while (0)
+#define DISPATCH_PICK_FALLBACK(what, func) do {                                \
+  dispatch_debug("using default `%s'", #what);                         \
+  return (func);                                                       \
+} while (0)
+
 /*----- Functions provided ------------------------------------------------*/
 
+/* --- @dispatch_debug@ --- *
+ *
+ * Arguments:  @const char *fmt@ = a format string
+ *             @...@ = additional arguments
+ *
+ * Returns:    ---
+ *
+ * Use:                Writes a formatted message to standard output if dispatch
+ *             debugging is enabled.
+ */
+
+extern void dispatch_debug(const char */*fmt*/, ...);
+
 /* --- @cpu_feature_p@ --- *
  *
  * Arguments:  @unsigned feat@ = a @CPUFEAT_...@ code