Hello Ben, > I checked this in.
OK, then we have to do the review after it's already in CVS. > 2007-07-22 Ben Pfaff <[EMAIL PROTECTED]> > > New module: popcount. 'popcount' is not a particularly good name. When I first stumbled on a function of this name in the sources of GNU gettext, it took me some time to understand what it meant. The ANSI Common Lisp name for this function is 'logcount', where the prefix 'log' means a "logical" interpretation of integers. This is not mainstream understandable either. So, how about renaming it to 'bitcount'? > +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR >= 4) > +#define POPCOUNT_CALCULATION(NAME) \ > + return __builtin_##NAME (x); This will not work with CC="gcc -fno-builtin". Better use an autoconf test. > x = ((x & 0xaaaaaaaa) >> 1) + (x & 0x55555555); > x = ((x & 0xcccccccc) >> 2) + (x & 0x33333333); > x = ((x & 0xf0f0f0f0) >> 4) + (x & 0x0f0f0f0f); > x = ((x & 0xff00ff00) >> 8) + (x & 0x00ff00ff); > return (x >> 16) + (x & 0xff); You can reduce the size of some of the constants somewhat, allowing more efficient code, and eliminate one & operation, like this: x = ((x & 0xaaaaaaaa) >> 1) + (x & 0x55555555); x = ((x & 0xcccccccc) >> 2) + (x & 0x33333333); x = (x >> 16) + (x & 0xffff); x = ((x & 0xf0f0) >> 4) + (x & 0x0f0f); return (x >> 8) + (x & 0x00ff); Also, to avoid compiler warnings, can you add an 'U' suffix to the constants? Bruno