[igt-dev] [PATCH i-g-t v3] lib/igt_collection: Adding combinatorics facility

Chris Wilson chris at chris-wilson.co.uk
Tue Jan 21 10:17:46 UTC 2020


Quoting Zbigniew Kempczyński (2020-01-21 10:03:57)
> On Tue, Jan 21, 2020 at 11:44:48AM +0200, Petri Latvala wrote:
> 
> <cut>
> 
> I'll check formatting and send in v4.
>  
> > > + */
> > > +
> > > +#if defined(__GNUC__)
> > > +#define NUM_BITS(v) __builtin_popcount(v)
> > > +#else
> > > +/* Taken from Hacker's Delight, for non-gcc compiler */
> > 
> > Hmm, what's the license for these bits?
> >
> 
> I've no idea. It is just O(1) pattern known for years collected
> in the book mentioned above. I guess I could put it here without
> any annotation.

If in doubt, leave it for the next person ;)

We'll want a compiler.h, compiler-gcc.h, compiler-meh.h in that
eventually and hide all the builtins behind defines and fallbacks.

See lib/igt_aux.h igt_hweight() for defence.
-Chris


More information about the igt-dev mailing list