bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: new module 'popcount'


From: Bruno Haible
Subject: Re: new module 'popcount'
Date: Tue, 24 Jul 2007 10:19:11 +0200
User-agent: KMail/1.5.4

Ben Pfaff wrote:
> I do agree that 'hamming_weight' is a precise name for this
> function.  But it is not a descriptive name: one must know by
> rote what a Hamming weight is.

Yes, 'hamming_weight' does not help the understanding unless you are
already familiar with it.

> Bruno Haible <address@hidden> continues:
> >> +#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.
> 
> Actual testing with GCC bears this out:
> 
>     address@hidden:~/gnulib/gnulib(1)$ cat test.c
>     #include <stdio.h>
>     int
>     main (void)
>     {
>         printf ("%d\n", __builtin_popcount (5));
>         return 0;
>     }
>     address@hidden:~/gnulib/gnulib(0)$ gcc -Wall -Wextra -fno-builtin test.c
>     address@hidden:~/gnulib/gnulib(0)$ ./a.out 
>     2

You're right. Sorry, my mistake.

Bruno





reply via email to

[Prev in Thread] Current Thread [Next in Thread]