Skip to contentSkip to conversation

spapr: Fix spapr_populate_memory() to compile on windows

PATCH In review Alexey Kardashevskiy 3 participants 3 messages Sep 7, 2014 – Sep 8, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spapr: Fix spapr_populate_memory() to compile on windows

This replaces gcc's ffsl() function ("find first bit set in a word") with QEMU's ctzl ("count trailing zeros"). There are no corner cases in the affected code so simple replacement ffsl()-1 by ctzl() works.

---
 hw/ppc/spapr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/ppc/spapr.c +2 -2
index 4b20e36..2ab4460 100644
@@ -705,8 +705,8 @@ static int spapr_populate_memory(sPAPREnvironment *spapr, void *fdt)
             hwaddr sizetmp = pow2floor(node_size);
 
             /* mem_start != 0 here */
-            if (ffsl(mem_start) < ffsl(sizetmp)) {
-                sizetmp = 1ULL << (ffsl(mem_start) - 1);
+            if (ctzl(mem_start) < ctzl(sizetmp)) {
+                sizetmp = 1ULL << ctzl(mem_start);
             }
 
             spapr_populate_memory_node(fdt, i, mem_start, sizetmp);
Signature · 1 line
2.0.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Alexey Kardashevskiy

This replaces gcc's ffsl() function ("find first bit set in a word") with QEMU's ctzl ("count trailing zeros"). There are no corner cases in the affected code so simple replacement ffsl()-1 by ctzl() works.

Looks sane to me.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson