[Xen-devel] [PATCH] xen/bitops: Further reduce the #ifdef-ary in generic_hweight64()

Andrew Cooper posted 1 patch 4 years, 10 months ago
Failed in applying to current master (apply log)
xen/include/xen/bitops.h | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
[Xen-devel] [PATCH] xen/bitops: Further reduce the #ifdef-ary in generic_hweight64()
Posted by Andrew Cooper 4 years, 10 months ago
This #ifdef-ary isn't necessary, and the logic can live in a plain if()

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/include/xen/bitops.h | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h
index b512800..dfb7041 100644
--- a/xen/include/xen/bitops.h
+++ b/xen/include/xen/bitops.h
@@ -184,10 +184,9 @@ static inline unsigned int generic_hweight8(unsigned int w)
 
 static inline unsigned int generic_hweight64(uint64_t w)
 {
-#if BITS_PER_LONG < 64
-    return generic_hweight32((unsigned int)(w >> 32)) +
-        generic_hweight32((unsigned int)w);
-#else
+    if ( BITS_PER_LONG < 64 )
+        return generic_hweight32(w >> 32) + generic_hweight32(w);
+
     w -= (w >> 1) & 0x5555555555555555ul;
     w =  (w & 0x3333333333333333ul) + ((w >> 2) & 0x3333333333333333ul);
     w =  (w + (w >> 4)) & 0x0f0f0f0f0f0f0f0ful;
@@ -199,7 +198,6 @@ static inline unsigned int generic_hweight64(uint64_t w)
     w += w >> 16;
 
     return (w + (w >> 32)) & 0xFF;
-#endif
 }
 
 static inline unsigned long hweight_long(unsigned long w)
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH] xen/bitops: Further reduce the #ifdef-ary in generic_hweight64()
Posted by Jan Beulich 4 years, 10 months ago
>>> On 04.06.19 at 14:40, <andrew.cooper3@citrix.com> wrote:
> This #ifdef-ary isn't necessary, and the logic can live in a plain if()
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Jan Beulich <jbeulich@suse.com>



_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel