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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100129100431.GA6513@elte.hu>
Date:	Fri, 29 Jan 2010 11:04:31 +0100
From:	Ingo Molnar <mingo@...e.hu>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	mingo@...hat.com, hpa@...or.com, eranian@...gle.com,
	linux-kernel@...r.kernel.org, a.p.zijlstra@...llo.nl,
	torvalds@...ux-foundation.org, tglx@...utronix.de,
	linux-tip-commits@...r.kernel.org
Subject: Re: [tip:perf/core] bitops: Provide compile time HWEIGHT{8,16,32,64}


* Andrew Morton <akpm@...ux-foundation.org> wrote:

> On Fri, 29 Jan 2010 09:28:04 GMT tip-bot for Peter Zijlstra <a.p.zijlstra@...llo.nl> wrote:
> 
> > +#define HWEIGHT8(w)			\
> > +      (	(!!((w) & (1ULL << 0))) +	\
> > +	(!!((w) & (1ULL << 1))) +	\
> > +	(!!((w) & (1ULL << 2))) +	\
> > +	(!!((w) & (1ULL << 3))) +	\
> > +	(!!((w) & (1ULL << 4))) +	\
> > +	(!!((w) & (1ULL << 5))) +	\
> > +	(!!((w) & (1ULL << 6))) +	\
> > +	(!!((w) & (1ULL << 7)))	)
> > +
> > +#define HWEIGHT16(w) (HWEIGHT8(w)  + HWEIGHT8(w >> 8))
> > +#define HWEIGHT32(w) (HWEIGHT16(w) + HWEIGHT16(w >> 16))
> > +#define HWEIGHT64(w) (HWEIGHT32(w) + HWEIGHT32(w >> 32))
> 
> Would be nice if it had a comment explaining why it exists.  If people
> accidentally use this with non-constant arguments, the generated code
> will be pretty ghastly.
> 
> Or add some barf-if-not-__constant_p() thing, perhaps.

Yeah, agreed.

	Ingo
--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ