From: Stefan Metzmacher Date: Fri, 11 Nov 2022 14:05:53 +0000 (+0100) Subject: tevent: add TEVENT_DEBUG() avoid argument overhead when log is not active... X-Git-Tag: tevent-0.15.0~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=812313f1c82d3679bf5f5e22bb2b0268e9bbb152;p=thirdparty%2Fsamba.git tevent: add TEVENT_DEBUG() avoid argument overhead when log is not active... It can be very costly to calculate the arguments passed to tevent_debug(), just to drop the message within tevent_debug() or the callback function. So we add a way to avoid the overhead, it will be used in the next commits. Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- diff --git a/lib/tevent/tevent_internal.h b/lib/tevent/tevent_internal.h index 4fdaa6586e6..7bb9bd67de9 100644 --- a/lib/tevent/tevent_internal.h +++ b/lib/tevent/tevent_internal.h @@ -296,6 +296,13 @@ struct tevent_debug_ops { void tevent_debug(struct tevent_context *ev, enum tevent_debug_level level, const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); +#define TEVENT_DEBUG(__ev, __level, __fmt, ...) do { \ + if (unlikely((__ev) != NULL && \ + (__level) <= (__ev)->debug_ops.max_level)) \ + { \ + tevent_debug((__ev), (__level), (__fmt), __VA_ARGS__); \ + } \ +} while(0) void tevent_abort(struct tevent_context *ev, const char *reason);