trivial: fixes to popcountl implementation

This commit is contained in:
Hesham Almatary
2017-06-29 10:43:48 +10:00
parent 2e14cd3400
commit 13e32a295d
2 changed files with 4 additions and 6 deletions

View File

@@ -125,23 +125,21 @@ int __builtin_popcountl (unsigned long x);
/** DONT_TRANSLATE */
static inline long
CONST popcountl(unsigned long x)
CONST popcountl(unsigned long v)
{
#ifndef __POPCNT__
unsigned int v; // count the number of bits set in v
unsigned int c; // c accumulates the total bits set in v
for (c = 0; v; c++) {
v &= v - 1; // clear the least significant bit set
}
return v;
return c;
#else
return __builtin_popcountl(x);
#endif
}
#define POPCOUNTL(x) popcountl
#define POPCOUNTL(x) popcountl(x)
#else /* __ASSEMBLER__ */

View File

@@ -29,7 +29,7 @@ static inline void init_ipi_args(IpiModeRemoteCall_t func,
ipi_args[2] = data3;
/* get number of cores involved in this IPI */
totalCoreBarrier = POPCOUNTL(mask);
totalCoreBarrier = popcountl(mask);
}
static void handleRemoteCall(IpiModeRemoteCall_t call, word_t arg0,