DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Wiles, Keith" <keith.wiles@intel.com>
To: Aleksey Baulin <aleksey.baulin@gmail.com>
Cc: Thomas Monjalon <thomas@monjalon.net>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] eal/common: better likely() and unlikely()
Date: Mon, 20 Nov 2017 13:36:28 +0000	[thread overview]
Message-ID: <D3302FD6-A529-497E-A470-5EBC1729EDF5@intel.com> (raw)
In-Reply-To: <1511129764-23123-1-git-send-email-Aleksey.Baulin@gmail.com>



> On Nov 19, 2017, at 4:16 PM, Aleksey Baulin <aleksey.baulin@gmail.com> 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 <Aleksey.Baulin@gmail.com>
> ---
> 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

  reply	other threads:[~2017-11-20 13:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-19 22:16 Aleksey Baulin
2017-11-20 13:36 ` Wiles, Keith [this message]
2017-11-20 17:21   ` Jim Thompson
2017-11-21  7:05   ` Aleksey Baulin
2018-01-12 15:35     ` Thomas Monjalon
2018-01-13 22:05       ` Aleksey Baulin
2018-01-13 22:24         ` Thomas Monjalon
2018-01-13 22:45           ` Aleksey Baulin
2018-01-14 17:17             ` Stephen Hemminger
2018-01-20 16:28 ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D3302FD6-A529-497E-A470-5EBC1729EDF5@intel.com \
    --to=keith.wiles@intel.com \
    --cc=aleksey.baulin@gmail.com \
    --cc=dev@dpdk.org \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).