From patchwork Mon Apr 7 11:07:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 27891 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f71.google.com (mail-yh0-f71.google.com [209.85.213.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7431D20490 for ; Mon, 7 Apr 2014 11:09:49 +0000 (UTC) Received: by mail-yh0-f71.google.com with SMTP id a41sf22262734yho.2 for ; Mon, 07 Apr 2014 04:09:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id :mime-version:cc:subject:precedence:list-id:list-unsubscribe :list-post:list-help:list-subscribe:sender:errors-to :x-original-sender:x-original-authentication-results:mailing-list :list-archive:content-type:content-transfer-encoding; bh=yvU42Fd3eVAbreTyJMUX5txyG1HyfoH4m0hUG30t1pQ=; b=aX4CE/ilj3LrZnNWbgagaJETlhThk1wXTmCqn4T+o+2lzSadPSWuF4m2AXn0mWwC8I ah9rE8tnWETMy1P+cqNgKsKwcs4fqGHoSDJhyv9xbPuptlrBytT2MgYC2kpjJ0iCp6cX x5PJSIxm+Kr0QKQxAK/5oIg1Ii548UNDw4hDMqdPqGzCvTJS3AEVxmKMNcvcmv6fePhd B6NJE+2ZNZZKSK20H1jYZ6YWcZJAGHzvAg5gUffS1/EtpXfQeLgMZU7kOxwn+UHE2lrT Y4KFzzeJtsUJW63iqoGtjL8+kKCEkw3oI/mj0rk/qPLRMhCMtScYNClRTGZ+bixcWljp KeJg== X-Gm-Message-State: ALoCoQnP+6v9ocsgVmL+lyHugLPnD0TSrY0oGl3XEP3EoOJFWyADGV71ppqfnnDajV2+JqnaCIfK X-Received: by 10.52.61.197 with SMTP id s5mr13934627vdr.8.1396868988895; Mon, 07 Apr 2014 04:09:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.103 with SMTP id k94ls1752263qgd.93.gmail; Mon, 07 Apr 2014 04:09:48 -0700 (PDT) X-Received: by 10.52.175.166 with SMTP id cb6mr23892500vdc.1.1396868988821; Mon, 07 Apr 2014 04:09:48 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id t4si3064295vcz.58.2014.04.07.04.09.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 07 Apr 2014 04:09:48 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id db12so3423576veb.38 for ; Mon, 07 Apr 2014 04:09:48 -0700 (PDT) X-Received: by 10.220.92.135 with SMTP id r7mr23738982vcm.11.1396868988708; Mon, 07 Apr 2014 04:09:48 -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 v8csp152905vcv; Mon, 7 Apr 2014 04:09:48 -0700 (PDT) X-Received: by 10.50.109.130 with SMTP id hs2mr19039595igb.29.1396868988133; Mon, 07 Apr 2014 04:09:48 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id a3si6837813igb.34.2014.04.07.04.09.47 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 07 Apr 2014 04:09:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xen.org designates 50.57.142.19 as permitted sender) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WX7PN-0003Ul-JV; Mon, 07 Apr 2014 11:08:09 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WX7PL-0003UZ-Nk for xen-devel@lists.xen.org; Mon, 07 Apr 2014 11:08:07 +0000 Received: from [193.109.254.147:60923] by server-5.bemta-14.messagelabs.com id 28/C2-26413-71782435; Mon, 07 Apr 2014 11:08:07 +0000 X-Env-Sender: Ian.Campbell@citrix.com X-Msg-Ref: server-6.tower-27.messagelabs.com!1396868885!6720894!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n X-StarScan-Received: X-StarScan-Version: 6.11.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6988 invoked from network); 7 Apr 2014 11:08:06 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-6.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 7 Apr 2014 11:08:06 -0000 X-IronPort-AV: E=Sophos;i="4.97,809,1389744000"; d="scan'208";a="118632091" Received: from accessns.citrite.net (HELO FTLPEX01CL01.citrite.net) ([10.9.154.239]) by FTLPIPO01.CITRIX.COM with ESMTP; 07 Apr 2014 11:07:05 +0000 Received: from norwich.cam.xci-test.com (10.80.248.129) by smtprelay.citrix.com (10.13.107.78) with Microsoft SMTP Server id 14.2.342.4; Mon, 7 Apr 2014 07:07:05 -0400 Received: from drall.uk.xensource.com ([10.80.16.71] helo=drall.uk.xensource.com.) by norwich.cam.xci-test.com with esmtp (Exim 4.72) (envelope-from ) id 1WX7OK-0005lt-KP; Mon, 07 Apr 2014 11:07:04 +0000 From: Ian Campbell To: Date: Mon, 7 Apr 2014 12:07:04 +0100 Message-ID: <1396868824-16769-1-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-DLP: MIA2 Cc: Tim Deegan , Ian Campbell , Jan Beulich , xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH] xen: make sure that likely and unlikely convert the expression to a boolean X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ian.campbell@citrix.com X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.179 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 List-Archive: According to http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html __builtin_expect has the prototype: long __builtin_expect (long exp, long c) If sizeof(exp) > sizeof(long) then this will effectively mask off the top bits of exp, meaning that the if in "if (unlikey(x))" will see the masked version, which might be false when true was expected, likely has the same issue. With the x86_32 hypervisor no longer existing this is mostly likely to affect arm32 builds. A quick grep however shows that all the existing arm32 uses of both likely and unlikely already pass a boolean. I noticed this with an as yet unposted patch which did not have this property. Also the defintion of likely might not have had the expected affect for cases where a true value > 1 might be passed. Signed-off-by: Ian Campbell Cc: Keir Fraser Cc: Jan Beulich Cc: Tim Deegan Reviewed-by: Jan Beulich --- xen/include/xen/compiler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/include/xen/compiler.h b/xen/include/xen/compiler.h index 6e07990..4b3472d 100644 --- a/xen/include/xen/compiler.h +++ b/xen/include/xen/compiler.h @@ -7,8 +7,8 @@ #define barrier() __asm__ __volatile__("": : :"memory") -#define likely(x) __builtin_expect((x),1) -#define unlikely(x) __builtin_expect((x),0) +#define likely(x) __builtin_expect(!!(x),1) +#define unlikely(x) __builtin_expect(!!(x),0) #define inline __inline__ #define always_inline __inline__ __attribute__ ((always_inline))