public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Yury Norov <ynorov@nvidia.com>
Cc: Yury Norov <yury.norov@gmail.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	linux-kernel@vger.kernel.org,
	Frank Binns <frank.binns@imgtec.com>,
	Alessio Belle <alessio.belle@imgtec.com>,
	Brajesh Gupta <brajesh.gupta@imgtec.com>,
	Alexandru Dadu <alexandru.dadu@imgtec.com>,
	Vincent Mailhol <mailhol@kernel.org>,
	Matt Coster <matt.coster@imgtec.com>
Subject: Re: [PATCH] bitfield: wire __bf_shf to __builtin_ctzll
Date: Tue, 28 Apr 2026 03:04:43 +0100	[thread overview]
Message-ID: <20260428030443.521e91e3@pumpkin> (raw)
In-Reply-To: <20260427225705.418802-1-ynorov@nvidia.com>

On Mon, 27 Apr 2026 18:57:05 -0400
Yury Norov <ynorov@nvidia.com> wrote:

> __bf_shf() is currently based on built-in ffsll. It's more
> straightforward to wire it to __builtin_ctzll, which makes it a pure
> rename.
> 
> Worth to notice that __builtin_ffsll() is buggy on GCC before 14.1:
> 
>   int main() {
>       sizeof(struct {
>           int t : !(__builtin_ffsll(~0ULL) + 1 < 0);
>       });
>   }
> 
>   test.c: In function 'main':
>   test.c:3:21: error: bit-field 't' width not an integer constant
>       3 |                 int t : !(__builtin_ffsll(~0ULL) + 1 < 0);
>         |                     ^
> 
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124699
> 
> Reported-by: Matt Coster <matt.coster@imgtec.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202603222211.A2XiR1YU-lkp@intel.com/
> Signed-off-by: Yury Norov <ynorov@nvidia.com>
> ---
>  include/linux/bitfield.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h
> index cd44013281c7..ddf6d1a70473 100644
> --- a/include/linux/bitfield.h
> +++ b/include/linux/bitfield.h
> @@ -44,7 +44,7 @@
>   *  FIELD_MODIFY(REG_FIELD_C, &reg, c);
>   */
>  
> -#define __bf_shf(x) (__builtin_ffsll(x) - 1)
> +#define __bf_shf __builtin_ctzll

I'd leave in the (x).

	David

>  
>  #define __scalar_type_to_unsigned_cases(type)				\
>  		unsigned type:	(unsigned type)0,			\


      reply	other threads:[~2026-04-28  2:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-27 22:57 [PATCH] bitfield: wire __bf_shf to __builtin_ctzll Yury Norov
2026-04-28  2:04 ` David Laight [this message]

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=20260428030443.521e91e3@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=alessio.belle@imgtec.com \
    --cc=alexandru.dadu@imgtec.com \
    --cc=brajesh.gupta@imgtec.com \
    --cc=frank.binns@imgtec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mailhol@kernel.org \
    --cc=matt.coster@imgtec.com \
    --cc=ynorov@nvidia.com \
    --cc=yury.norov@gmail.com \
    /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