From patchwork Fri Mar 28 16:43:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 27368 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f200.google.com (mail-ve0-f200.google.com [209.85.128.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DE25920062 for ; Fri, 28 Mar 2014 17:40:34 +0000 (UTC) Received: by mail-ve0-f200.google.com with SMTP id oy12sf11883615veb.7 for ; Fri, 28 Mar 2014 10:40:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=bHyHk3XSEKRSNQI1OpSts1is7Uudv1Tp9iQD53R0jyI=; b=XxnFsNQvGyP84rd0juuR/iYDtwlfFsspQRf2ZYkS2xFA9ic9kvJ1QylTtdjcoWAE7O lfOF6F5Hy+qejdhDxzi7r3S10SHqPeqMiuahfZJjeaQuPGnGlHbg6xwfAlcK2/dTjmn9 M1luuiEVli9fMf7RpI+iNZEe915Ji+F2JAmVfWoZ1JbhtbuNPiYXc+4H6a+e+ztdrnhX SGYVD0cbxZ57B3Eh9+GxFPETZSD7kwmg1NDHZqcjjHJHJ++dqW4nuzSorFbaDuS5TPgv OE2UiJPEaBw+hb9hKP8RC2m3b4pPTjMXrO8qrTSvBBvy9pLpef9/tCGcknGax+fTUiQQ funw== X-Gm-Message-State: ALoCoQlSIkjeGD5OTrbvcJE62zhyGEFJ/uJyoGJJNiJ9QVAAIoAJcc/F4dIRVj3oz7xitLnGWxcy X-Received: by 10.58.170.6 with SMTP id ai6mr2510099vec.7.1396028434561; Fri, 28 Mar 2014 10:40:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.108.10 with SMTP id i10ls1643977qgf.62.gmail; Fri, 28 Mar 2014 10:40:34 -0700 (PDT) X-Received: by 10.220.109.1 with SMTP id h1mr3567069vcp.20.1396028434469; Fri, 28 Mar 2014 10:40:34 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id s7si789579vev.110.2014.03.28.10.40.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Mar 2014 10:40:34 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id ik5so6383936vcb.0 for ; Fri, 28 Mar 2014 10:40:34 -0700 (PDT) X-Received: by 10.58.57.67 with SMTP id g3mr8144804veq.3.1396028434402; Fri, 28 Mar 2014 10:40:34 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp27054vcv; Fri, 28 Mar 2014 10:40:34 -0700 (PDT) X-Received: by 10.140.38.37 with SMTP id s34mr3544447qgs.88.1396028434057; Fri, 28 Mar 2014 10:40:34 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k1si2861259qaf.28.2014.03.28.10.40.33 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 28 Mar 2014 10:40:34 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:34949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTZu3-0000eH-V2 for patch@linaro.org; Fri, 28 Mar 2014 12:45:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTZsT-00077A-Sz for qemu-devel@nongnu.org; Fri, 28 Mar 2014 12:43:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WTZsO-0002jL-Ub for qemu-devel@nongnu.org; Fri, 28 Mar 2014 12:43:33 -0400 Received: from static.88-198-71-155.clients.your-server.de ([88.198.71.155]:56329 helo=socrates.bennee.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WTZsO-0002jD-Mx for qemu-devel@nongnu.org; Fri, 28 Mar 2014 12:43:28 -0400 Received: from localhost ([127.0.0.1] helo=zen.linaro.local) by socrates.bennee.com with esmtp (Exim 4.80) (envelope-from ) id 1WTZsn-0004ll-NO; Fri, 28 Mar 2014 17:43:53 +0100 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Date: Fri, 28 Mar 2014 16:43:22 +0000 Message-Id: <1396025007-27592-3-git-send-email-alex.bennee@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1396025007-27592-1-git-send-email-alex.bennee@linaro.org> References: <1396025007-27592-1-git-send-email-alex.bennee@linaro.org> X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: alex.bennee@linaro.org X-SA-Exim-Scanned: No (on socrates.bennee.com); SAEximRunCond expanded to false X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 88.198.71.155 Cc: Peter Maydell Subject: [Qemu-devel] [PATCH v2 2/7] qemu-log: Avoid function call for disabled qemu_log_mask logging X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alex.bennee@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Peter Maydell 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 diff --git a/include/qemu/log.h b/include/qemu/log.h index d515424..da22e13 100644 --- a/include/qemu/log.h +++ b/include/qemu/log.h @@ -64,10 +64,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) /* Special cases: */ diff --git a/qemu-log.c b/qemu-log.c index 35bbb56..83e0cb4 100644 --- a/qemu-log.c +++ b/qemu-log.c @@ -36,17 +36,6 @@ void qemu_log(const char *fmt, ...) va_end(ap); } -void qemu_log_mask(int mask, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - if ((qemu_loglevel & mask) && qemu_logfile) { - vfprintf(qemu_logfile, fmt, ap); - } - va_end(ap); -} - /* enable or disable low levels log */ void do_qemu_set_log(int log_flags, bool use_own_buffers) {