[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YwUR35I7+5JbLvMM@zn.tnic>
Date: Tue, 23 Aug 2022 19:43:59 +0200
From: Borislav Petkov <bp@...en8.de>
To: Nick Desaulniers <ndesaulniers@...gle.com>
Cc: Vincent Mailhol <mailhol.vincent@...adoo.fr>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, x86@...nel.org,
Peter Zijlstra <peterz@...radead.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H . Peter Anvin" <hpa@...or.com>,
Nathan Chancellor <nathan@...nel.org>,
Tom Rix <trix@...hat.com>, linux-kernel@...r.kernel.org,
llvm@...ts.linux.dev, David Howells <dhowells@...hat.com>,
Jan Beulich <JBeulich@...e.com>,
Christophe Jaillet <christophe.jaillet@...adoo.fr>,
Joe Perches <joe@...ches.com>,
Josh Poimboeuf <jpoimboe@...nel.org>
Subject: Re: [PATCH v5 2/2] x86/asm/bitops: __ffs,ffz: use __builtin_ctzl to
evaluate constant expressions
On Tue, Aug 23, 2022 at 10:12:17AM -0700, Nick Desaulniers wrote:
> Callers of these need to guard against zero input, as the pre-existing
> comment notes:
>
> >> Undefined if no bit exists, so code should check against 0 first.
This is just silly.
And then there's
* ffs(value) returns 0 if value is 0 or the position of the first
* set bit if value is nonzero. The first (least significant) bit
* is at position 1.
*/
static __always_inline int ffs(int x)
Can we unify the two and move the guard against 0 inside the function
or, like ffs() does, have it return 0 if value is 0?
--
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette
Powered by blists - more mailing lists