Skip to content

Commit

Permalink
math.h: fix compilation error if not on GNU/Clang, fix builtin usage …
Browse files Browse the repository at this point in the history
…condition
  • Loading branch information
XPhyro committed Aug 23, 2024
1 parent af39c0d commit 3ef8df6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/c/include/math.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
int popcountu(unsigned int x)
{
int popcount;
int i;

#if !defined(__GNUC__) || !defined(__clang__)
#if defined(__GNUC__) || defined(__clang__)
popcount = __builtin_popcount(x & 0xff);
#else
int i;
for (i = 0, popcount = 0; i < sizeof(x) * 8; popcount += (x & (1 << i++)) >> 0) {}
#endif

Expand Down

0 comments on commit 3ef8df6

Please sign in to comment.