lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 23 Apr 2009 16:57:23 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	David Daney <ddaney@...iumnetworks.com>
Cc:	rpjday@...shcourse.ca, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] Introduce a boolean "single_bit_set" function.

On Thu, 23 Apr 2009 12:57:11 -0700
David Daney <ddaney@...iumnetworks.com> wrote:

> > +static inline __attribute__((const))
> > +bool single_bit_set(unsigned long n)
> > +{
> > +        return (n != 0 && ((n & (n - 1)) == 0));
> > +}
> > +
> > +
> 
> 
> It would be nice to be able to override this per architecture.
> 
> For example a more efficient implementation on CPUs that have a 
> population count instruction (__builtin_popcountl()) might be:
> 
> static inline __attribute__((const))
> bool singe_bit_set(unsigned long n)
> {
> 	return __builtin_popcountl(n) == 1;
> }

Already done, via hweight_long().
--
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