Hi Mark,

On Jul  7 00:41, Mark Geisert wrote:
> The current version of <sys/cpuset.h> cannot be compiled by Clang due to
> the use of __builtin* functions.  Their presence here was a dubious
> optimization anyway, so their usage has been converted to standard
> library functions.  A popcnt (population count of 1 bits in a word)
> function is provided here because there isn't one in the standard library
> or elsewhere in the Cygwin DLL.

And clang really doesn't provide it?  That's unfortunate.

Do you really think it's not worth to use it if it's available?

You could workaround it like this:

> +/* Modern CPUs have popcnt* instructions but the need here is not worth
> + * worrying about builtins or inline assembler for different compilers. */ 
> +static inline int
> +__maskpopcnt (__cpu_mask mask)
> +{
#if (__GNUC__ >= 4)
     return __builtin_popcountl (mask);
#else
> +  int res = 0;
> +  unsigned long ulmask = (unsigned long) mask;
> +
> +  while (ulmask != 0)
> +    {
> +      if (ulmask & 1)
> +        ++res;
> +      ulmask >>= 1;
> +    }
> +  return res;
#endif
> +}
> +

But, if you think that's not worth it, I'll push your patch as is.


Thanks,
Corinna

Reply via email to