Patchwork [07/10] target-i386: Inline bitops_flsl

login
register
mail settings
Submitter Richard Henderson
Date Feb. 14, 2013, 1:47 a.m.
Message ID <1360806463-23632-8-git-send-email-rth@twiddle.net>
Download mbox | patch
Permalink /patch/220335/
State New
Headers show

Comments

Richard Henderson - Feb. 14, 2013, 1:47 a.m.
Use clz32 directly.  Which makes slightly more sense given
that the input is type "int" and not type "long".

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 target-i386/topology.h | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Patch

diff --git a/target-i386/topology.h b/target-i386/topology.h
index 24ed525..07a6c5f 100644
--- a/target-i386/topology.h
+++ b/target-i386/topology.h
@@ -52,10 +52,8 @@  typedef uint32_t apic_id_t;
 static unsigned apicid_bitwidth_for_count(unsigned count)
 {
     g_assert(count >= 1);
-    if (count == 1) {
-        return 0;
-    }
-    return bitops_flsl(count - 1) + 1;
+    count -= 1;
+    return count ? 32 - clz32(count) : 0;
 }
 
 /* Bit width of the SMT_ID (thread ID) field on the APIC ID