[U-Boot-Users] [PATCH] ppc: Add u64 versions of fls64 and __ilog bitops
Wolfgang Denk
wd at denx.de
Tue Jun 10 23:58:36 CEST 2008
In message <Pine.LNX.4.64.0806101618470.3027 at blarg.am.freescale.net> you wrote:
> Signed-off-by: Kumar Gala <galak at kernel.crashing.org>
Comments and code do not match; you'r actually adding much more code.
> +/*
> + * fls: find last (most-significant) bit set.
> + * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
> + */
> +static __inline__ int fls(unsigned int x)
This is not a u64 version of fls64, or is it? ;-)
> +static __inline__ unsigned long __fls(unsigned long x)
Neither is this...
Also: is fls() vs. __fls() a good way to differentiate between int and
ulong?
> + * fls64(value) returns 0 if value is 0 or the position of the last
> + * set bit if value is nonzero. The last (most significant) bit is
Sorry, I can't parse this.
> +#elif BITS_PER_LONG == 64
> +static inline int fls64(__u64 x)
> +{
> + if (x == 0)
> + return 0;
> + return __fls(x) + 1;
Do I have to understand where the "+1" is coming from?
> +static inline int ffs64(u64 x)
> +{
> + return __ilog2_u64(x & -x) + 1ull;
Isn't there an easier way to do this?
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Beware of the Turing Tar-pit in which everything is possible but
nothing of interest is easy.
More information about the U-Boot
mailing list