From 13e32a295d71a05a12d4d4900ba6c2dd532fa371 Mon Sep 17 00:00:00 2001 From: Hesham Almatary Date: Thu, 29 Jun 2017 10:43:48 +1000 Subject: [PATCH] trivial: fixes to popcountl implementation --- include/util.h | 8 +++----- src/arch/arm/smp/ipi.c | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/include/util.h b/include/util.h index 3f6a008d6..f1817f001 100644 --- a/include/util.h +++ b/include/util.h @@ -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__ */ diff --git a/src/arch/arm/smp/ipi.c b/src/arch/arm/smp/ipi.c index 253f3a78f..10fd4917b 100644 --- a/src/arch/arm/smp/ipi.c +++ b/src/arch/arm/smp/ipi.c @@ -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,