[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <201207202202.28723.arnd@arndb.de>
Date: Fri, 20 Jul 2012 22:02:28 +0000
From: Arnd Bergmann <arnd@...db.de>
To: David Howells <dhowells@...hat.com>
Cc: linux-security-module@...r.kernel.org,
linux-kernel@...r.kernel.org,
"David S. Miller" <davem@...emloft.net>,
Dmitry Kasatkin <dmitry.kasatkin@...el.com>
Subject: Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions
On Friday 20 July 2012, David Howells wrote:
>
> Arnd Bergmann <arnd@...db.de> wrote:
>
> > I don't generally like to put stuff into asm-generic when it's unlikely
> > to be overridden by architectures. It would really belong into
> > include/linux, but then again we have all the other bitops in asm-generic
> > as well, so whatever...
>
> Some arches (such as Sparc, I think) have count-leading-zero instructions.
But I guess they would still use the same definition of
+static inline int count_leading_zeros(unsigned long x)
+{
+ if (sizeof(x) == 4)
+ return BITS_PER_LONG - fls(x);
+ else
+ return BITS_PER_LONG - fls64(x);
+}
and just provide their own fls().
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists