anrieff / libcpuid

a small C library for x86 CPU detection and feature extraction
Other
451 stars 106 forks source link

Use popcount64 from libc when available #152

Closed alyssais closed 3 years ago

alyssais commented 3 years ago

Without this, we get a compiler error on NetBSD because the one in libc has a slightly different prototype.

libcpuid_util.c:78:12: error: conflicting types for 'popcount64'
   78 | static int popcount64(uint64_t mask)
      |            ^~~~~~~~~~
In file included from /nix/store/155rj8nqh3xd80vpa8hl35p3hk7pacys-include-netbsd-8.0/include/string.h:98,
                 from libcpuid_util.c:30:
/nix/store/155rj8nqh3xd80vpa8hl35p3hk7pacys-include-netbsd-8.0/include/strings.h:61:14: note: previous declaration of 'popcount64' was here
   61 | unsigned int popcount64(__uint64_t) __constfunc;
      |              ^~~~~~~~~~
alyssais commented 3 years ago

Actually, we should make the popcount64 here return unsigned as well too...