Brian Inglis wrote:
On 2023-07-07 12:54, Brian Inglis wrote:
On 2023-07-07 03:44, Corinna Vinschen wrote:
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);

Missed the difference in spelling, but clang supports the same builtin functions __builtin_popcount{,l,ll} et. al. or provides *optimized* inline functions if not directly available as an instruction on the architecture.

Clang in its current version 16.0.x has __builtin_popcount*, but not in the ancient version 8.0.1 that is currently packaged for Cygwin. I think that's what was behind Jon's earlier comment that perhaps we should remove clang from Cygwin unless/until somebody can adopt and maintain an up-to-date version. :-(.

..mark

Reply via email to