From: Thomas Monjalon <thomas@monjalon.net>
To: Tyler Retzlaff <roretzla@linux.microsoft.com>
Cc: dev@dpdk.org, anatoly.burakov@intel.com, ranjit.menon@intel.com,
mb@smartsharesystems.com, Tyler Retzlaff <roretzla@microsoft.com>,
stephen@networkplumber.org
Subject: Re: [PATCH 2/3] eal: change rte_fls and rte_bsf to return uint32_t
Date: Wed, 05 Oct 2022 11:02:45 +0200 [thread overview]
Message-ID: <1849229.jbyF5MZJ3u@thomas> (raw)
In-Reply-To: <1659993692-17479-3-git-send-email-roretzla@linux.microsoft.com>
08/08/2022 23:21, Tyler Retzlaff:
> From: Tyler Retzlaff <roretzla@microsoft.com>
>
> return fixed width uint32_t to be consistent with what appears to
> be the original authors intent. it doesn't make much sense to return
> signed integers for these functions.
>
> Signed-off-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
> ---
> lib/eal/include/rte_common.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
> index a96cc2a..bd4184d 100644
> --- a/lib/eal/include/rte_common.h
> +++ b/lib/eal/include/rte_common.h
> @@ -707,7 +707,7 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
> * @return
> * The last (most-significant) bit set, or 0 if the input is 0.
> */
> -static inline int
> +static inline uint32_t
> rte_fls_u32(uint32_t x)
> {
> return (x == 0) ? 0 : 32 - __builtin_clz(x);
> @@ -724,7 +724,7 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
> * @return
> * least significant set bit in the input parameter.
> */
> -static inline int
> +static inline uint32_t
> rte_bsf64(uint64_t v)
> {
> return (uint32_t)__builtin_ctzll(v);
> @@ -766,7 +766,7 @@ static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
> * @return
> * The last (most-significant) bit set, or 0 if the input is 0.
> */
> -static inline int
> +static inline uint32_t
> rte_fls_u64(uint64_t x)
> {
> return (x == 0) ? 0 : 64 - __builtin_clzll(x);
>
You forgot the _safe versions:
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -660,7 +660,7 @@ rte_bsf32(uint32_t v)
* @return
* Returns 0 if ``v`` was 0, otherwise returns 1.
*/
-static inline int
+static inline uint32_t
rte_bsf32_safe(uint32_t v, uint32_t *pos)
{
if (v == 0)
@@ -739,7 +739,7 @@ rte_bsf64(uint64_t v)
* @return
* Returns 0 if ``v`` was 0, otherwise returns 1.
*/
-static inline int
+static inline uint32_t
rte_bsf64_safe(uint64_t v, uint32_t *pos)
{
if (v == 0)
next prev parent reply other threads:[~2022-10-05 9:02 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-10 23:24 [dpdk-dev] [PATCH] doc: propose correction rte_bsf64 return type declaration Tyler Retzlaff
2021-03-15 19:34 ` [dpdk-dev] [PATCH v2] doc: propose correction rte_{bsf, fls} inline functions type use Tyler Retzlaff
2021-10-25 19:14 ` Thomas Monjalon
2021-10-26 7:45 ` Morten Brørup
2021-11-11 4:15 ` Tyler Retzlaff
2021-11-11 11:54 ` Thomas Monjalon
2021-11-11 12:41 ` Morten Brørup
2022-07-11 14:07 ` Jerin Jacob
2022-07-13 10:13 ` Thomas Monjalon
2022-07-18 21:28 ` Tyler Retzlaff
2022-08-08 21:21 ` [PATCH 0/3] cleanup bsf and fls inline function return types Tyler Retzlaff
2022-08-08 21:21 ` [PATCH 1/3] doc: announce cleanup of rte_{bsf, fls} inline functions type use Tyler Retzlaff
2022-10-05 9:06 ` Thomas Monjalon
2022-08-08 21:21 ` [PATCH 2/3] eal: change rte_fls and rte_bsf to return uint32_t Tyler Retzlaff
2022-10-05 9:02 ` Thomas Monjalon [this message]
2022-10-05 15:15 ` Tyler Retzlaff
2022-10-05 15:23 ` Thomas Monjalon
2022-10-05 15:40 ` [PATCH] eal: fix return type of bsf safe functions Thomas Monjalon
2022-10-05 19:41 ` David Marchand
2022-10-05 22:20 ` Tyler Retzlaff
2022-10-06 0:27 ` Thomas Monjalon
2022-10-06 18:20 ` Mattias Rönnblom
2022-08-08 21:21 ` [PATCH 3/3] test: fix sign compare warning for rte_bsf64 return type change Tyler Retzlaff
2022-08-08 21:42 ` [PATCH 0/3] cleanup bsf and fls inline function return types Stephen Hemminger
2022-08-09 8:26 ` Morten Brørup
2022-10-05 10:11 ` 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=1849229.jbyF5MZJ3u@thomas \
--to=thomas@monjalon.net \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=mb@smartsharesystems.com \
--cc=ranjit.menon@intel.com \
--cc=roretzla@linux.microsoft.com \
--cc=roretzla@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).