Messages in this thread | | | Date | Tue, 23 Aug 2022 18:23:00 +0200 | From | Borislav Petkov <> | Subject | Re: [PATCH v5 2/2] x86/asm/bitops: __ffs,ffz: use __builtin_ctzl to evaluate constant expressions |
| |
On Fri, Aug 12, 2022 at 08:44:38PM +0900, Vincent Mailhol wrote: > __ffs(x) is equivalent to (unsigned long)__builtin_ctzl(x)
Are you sure about this?
My gcc documentation says:
"Built-in Function: int __builtin_ctz (unsigned int x)
Returns the number of trailing 0-bits in x, starting at the least significant bit position. If x is 0, the result is undefined."
Note the undefined part.
Also,
__builtin_ctzl(0): 0x40 ffs(0): 0x0
I'm using the kernel ffs() version in a small program which is basically a wrapper around BSF.
-- Regards/Gruss, Boris.
https://people.kernel.org/tglx/notes-about-netiquette
| |