X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb/blobdiff_plain/11b179777b6b29afe0c960f62d7e2ea33b01cccd..fac645f7780c7673775f09fe625651f600f7ee7b:/base/dispatch.h diff --git a/base/dispatch.h b/base/dispatch.h index 612cfcd3..bbb81f30 100644 --- a/base/dispatch.h +++ b/base/dispatch.h @@ -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