DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Tyler Retzlaff" <roretzla@linux.microsoft.com>
Cc: "Stephen Hemminger" <stephen@networkplumber.org>, <dev@dpdk.org>,
	<anatoly.burakov@intel.com>, "Ray Kinsella" <mdr@ashroe.eu>,
	"Neil Horman" <nhorman@tuxdriver.com>
Subject: Re: [dpdk-dev] [PATCH] librte_eal/common: fix return type of rte_bsf64
Date: Sat, 13 Mar 2021 08:29:10 +0100	[thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35C6167B@smartserver.smartshare.dk> (raw)
In-Reply-To: <20210313011007.GA20712@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>

> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Tyler Retzlaff
> Sent: Saturday, March 13, 2021 2:10 AM
> 
> On Fri, Mar 12, 2021 at 10:13:30PM +0100, Morten Brørup wrote:
> > > >
> > > > Please also update the similar math functions in rte_common.h, so the
> > > return type is consistent across these functions:
> > > > - rte_bsf32()
> > > > - rte_bsf32_safe()
> > > > - rte_fls_u32()
> > > > - rte_bsf64()
> > > > - rte_fls_u64()
> > > > - rte_log2_u32()
> > > > - rte_log2_u64()
> > >
> > > agreed, happy to review the whole set and deal with it all at once.
> >
> > Ups. I should have omitted rte_bsf32_safe() from the list. It returns a
> Boolean.
> 
> if we can agree that we can use C11 as a base we could just do away with
> all this dumb 32-bit vs 64-bit static selection at the call site (at
> least for rte_bsf32() and rte_bsf64() and probably others).
> 
> i could just introduce the following macro and deprecate the current
> inline functions.
> 
> #define rte_bsf(v) \
>     (uint32_t)_Generic((v), \
>         uint8_t: __builtin_ctz, \
>         uint16_t: __builtin_ctz, \
>         uint32_t: __builtin_ctz, \
>         default: __builtin_ctzll)(v)
> 
> uint8_t a = ...;
> uint16_t b = ...;
> uint32_t c = ...;
> uint64_t d = ...;
> 
> the following would jw as intended, though given the range of the value
> that may be returned we could narrow the cast to uint8_t so we don't
> have to sprinkle casts in places where usage like uint8_t x = rte_bsf(v);
> exists.
> 
> rte_bsf(a);
> rte_bsf(b);
> rte_bsf(c);
> rte_bsf(d);
> 
> anyway, if people care let me know otherwise i'm just going to review
> and fix what is already there.

That would certainly be a nice improvement. But going down that road should include reviewing and fixing all DPDK libraries with 32/64 versions of the same functions, e.g. rte_bitops.h - which probably requires a significant effort.

So just limit the task to fixing what is already there.


  reply	other threads:[~2021-03-13  7:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10  6:41 Tyler Retzlaff
2021-03-10 18:31 ` Ranjit Menon
2021-03-10 18:49 ` Stephen Hemminger
2021-03-10 22:52   ` Tyler Retzlaff
2021-03-12  7:34     ` Morten Brørup
2021-03-12 11:46       ` Kinsella, Ray
2021-03-12 18:10         ` Tyler Retzlaff
2021-03-12 18:24       ` Tyler Retzlaff
2021-03-12 21:13         ` Morten Brørup
2021-03-13  1:10           ` Tyler Retzlaff
2021-03-13  7:29             ` Morten Brørup [this message]
2021-03-13 16:04               ` Tyler Retzlaff

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=98CBD80474FA8B44BF855DF32C47DC35C6167B@smartserver.smartshare.dk \
    --to=mb@smartsharesystems.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=mdr@ashroe.eu \
    --cc=nhorman@tuxdriver.com \
    --cc=roretzla@linux.microsoft.com \
    --cc=stephen@networkplumber.org \
    /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).