aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2016-03-15 19:12:03 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2016-03-22 22:20:18 +0100
commit7ee606230e6b7645d92365d9b39179368e83ac54 (patch)
treec757b955f233c40337678b881623f303762621ba /include
parent541957361e0728c2ffe8330a712099cc872986a0 (diff)
qemu-log: Avoid function call for disabled qemu_log_mask logging
Make qemu_log_mask() a macro which only calls the function to do the actual work if the logging is enabled. This avoids making a function call in possible fast paths where logging is disabled. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include')
-rw-r--r--include/qemu/log.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/include/qemu/log.h b/include/qemu/log.h
index 40c24fda40..523c886078 100644
--- a/include/qemu/log.h
+++ b/include/qemu/log.h
@@ -66,10 +66,17 @@ qemu_log_vprintf(const char *fmt, va_list va)
}
}
-/* log only if a bit is set on the current loglevel mask
+/* log only if a bit is set on the current loglevel mask:
+ * @mask: bit to check in the mask
+ * @fmt: printf-style format string
+ * @args: optional arguments for format string
*/
-void GCC_FMT_ATTR(2, 3) qemu_log_mask(int mask, const char *fmt, ...);
-
+#define qemu_log_mask(MASK, FMT, ...) \
+ do { \
+ if (unlikely(qemu_loglevel_mask(MASK))) { \
+ qemu_log(FMT, ## __VA_ARGS__); \
+ } \
+ } while (0)
/* Maintenance: */