From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua0-f195.google.com (mail-ua0-f195.google.com [209.85.217.195]) by dpdk.org (Postfix) with ESMTP id A7D34F1F for ; Tue, 21 Nov 2017 08:05:31 +0100 (CET) Received: by mail-ua0-f195.google.com with SMTP id 31so2437526uaj.6 for ; Mon, 20 Nov 2017 23:05:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ZoYaBOPXK8nxhZyqY59k916kNlkVLMd9s7k8eSrJQR8=; b=ZnfHHnZFRQS74wc8bxJSC/9faalds5SuI9kjwuFIEGZmx73qaUNS/pb6jf1EP252UV NEs5GDzTl7SVaMpHbtFljYcQRdj+RcPQ1JiIRY6gr1QBpRJ3MTIYCGhy2BCKsDuCPjnP QtRNQwn6so6xk159dAAT0b5nDyCSonM6rW6EL5uXpocGJzehnYQihHjh8Qxx0RdKGKTi Ub/f0IDZ8xplPDpBHGsh/okHRGSHLkIqDQ6HIugIfsry9/+xDr9b1qYj6i6SExBjSRdT Ki46JO+R12+fTAMsdn5g1d8m0veT0PzpOcSfvyxeKqJUmmtyv+JDv7dX7IobUkcSJmCT 7EOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=ZoYaBOPXK8nxhZyqY59k916kNlkVLMd9s7k8eSrJQR8=; b=BZpH5Y+E/dtbwETR8cSXuGUx6z7tLyhD90ekQEDd3Pp6m/SjySUSClVC0hHlO4JgOc Uic+Awyd+cfFw4QhrPxl1AvkcCJH/5tXPb6C3qvlU4s2Ah9ClGjUObV4iw2398gBqh/u +fNrdZDWy7ZoFPdDf7dbfd6FhvYvbq4FGPH64L8KRxZDO3JKEkHXjGN3sihq7illrNmv zwFgofIbGCBjfFkaQWwcjv3VxvNA6B0tde7m44rkOg7NBG2i+pxQnSNwVz2yGMGqhxGx mLfNmlzFsj7Sp90V1X+V7tk+jKok4FXOaMUJUW7pqvoGHEZqnhNbcrk3epLh/yANd6/c fHCg== X-Gm-Message-State: AJaThX47PSnguyvuFetDKCIt548Q+fHhBpVutsZP94hHlW3Yqaom4wR1 1j9V8MRIIDaUGvI/2NYVuwriQ/7kgspraA4+CAw= X-Google-Smtp-Source: AGs4zMYIElGGiaV1Y4p1Lu7y7cehgW5lckR0SAkBXthEImA1KCyw7SG93xKvoY+XgRPZFnezl6kN6pXBlIwGzXNo5aQ= X-Received: by 10.176.10.28 with SMTP id q28mr13121677uah.17.1511247930680; Mon, 20 Nov 2017 23:05:30 -0800 (PST) MIME-Version: 1.0 Sender: keshonok@gmail.com Received: by 10.31.162.85 with HTTP; Mon, 20 Nov 2017 23:05:28 -0800 (PST) In-Reply-To: References: <1511129764-23123-1-git-send-email-Aleksey.Baulin@gmail.com> From: Aleksey Baulin Date: Tue, 21 Nov 2017 10:05:28 +0300 X-Google-Sender-Auth: QMKyzlqzStXNdhMjPc1JmsAlNoE Message-ID: To: "Wiles, Keith" Cc: Thomas Monjalon , "dev@dpdk.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH] eal/common: better likely() and unlikely() X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Nov 2017 07:05:32 -0000 Sorry for late response. Jim had given the correct answer already. You won't get an extra instruction with compiler optimization turned on. Aleksey. On Mon, Nov 20, 2017 at 4:36 PM, Wiles, Keith wrote: > > > > On Nov 19, 2017, at 4:16 PM, Aleksey Baulin > wrote: > > > > A warning is issued when using an argument to likely() or unlikely() > > builtins which is evaluated to a pointer value, as __builtin_expect() > > expects a 'long int' type for its first argument. With this fix > > a pointer value is converted to an integer with the value of 0 or 1. > > > > Signed-off-by: Aleksey Baulin > > --- > > lib/librte_eal/common/include/rte_branch_prediction.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/lib/librte_eal/common/include/rte_branch_prediction.h > b/lib/librte_eal/common/include/rte_branch_prediction.h > > index a6a56d1..2e7dc69 100644 > > --- a/lib/librte_eal/common/include/rte_branch_prediction.h > > +++ b/lib/librte_eal/common/include/rte_branch_prediction.h > > @@ -50,7 +50,7 @@ > > * > > */ > > #ifndef likely > > -#define likely(x) __builtin_expect((x),1) > > +#define likely(x) __builtin_expect(!!(x), 1) > > #endif /* likely */ > > > > /** > > @@ -64,7 +64,7 @@ > > * > > */ > > #ifndef unlikely > > -#define unlikely(x) __builtin_expect((x),0) > > +#define unlikely(x) __builtin_expect(!!(x), 0) > > I have not looked at the generated code, but does this add some extra > instruction now to do the !!(x) ? > > > #endif /* unlikely */ > > > > #endif /* _RTE_BRANCH_PREDICTION_H_ */ > > -- > > 2.7.4 > > > > Regards, > Keith > > -- Aleksey Baulin