Skip to contentSkip to conversation

hweight64

PATCH Pavel Machek 3 participants 3 messages Feb 17, 2004 Bitops API

lore
Share & tools
lore
#0 lore raw

Hi!

In kgdb patches you change prototype of hweight64. Why that change?

[This patch is reverse]

I do not see what it has to do with kgdb. Its true that result always fits into int, but I'd be afraid of small sideeffects somewhere...

Pavel

include/linux/bitops.h +2 -3
@@ -108,7 +108,7 @@
         return (res & 0x0F) + ((res >> 4) & 0x0F);
 }
 
-static inline unsigned int generic_hweight64(__u64 w)
+static inline unsigned long generic_hweight64(__u64 w)
 {
 #if BITS_PER_LONG < 64
 	return generic_hweight32((unsigned int)(w >> 32)) +
@@ -120,8 +120,7 @@
 	res = (res & 0x0F0F0F0F0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F0F0F0F0F);
 	res = (res & 0x00FF00FF00FF00FF) + ((res >> 8) & 0x00FF00FF00FF00FF);
 	res = (res & 0x0000FFFF0000FFFF) + ((res >> 16) & 0x0000FFFF0000FFFF);
-	res = (res & 0x00000000FFFFFFFF) + ((res >> 32) & 0x00000000FFFFFFFF);
-	return (unsigned int)res;
+	return (res & 0x00000000FFFFFFFF) + ((res >> 32) & 0x00000000FFFFFFFF);
 #endif
 }
 
Signature · 2 lines
When do you have a heart between your knees?
[Johanka's followup: and *two* hearts?]
#1 lore raw

Hi Pavel and kgdb gurus,

I inherited this change from x86_64 patch. Probably it was required on x86_64. I can't think of any reason why it is necessary.

Unless someone finds a problem with this patch, I am going to apply it.

-Amit

Quoted 32 lines · Pavel Machek

Hi!

In kgdb patches you change prototype of hweight64. Why that change?

[This patch is reverse]

I do not see what it has to do with kgdb. Its true that result always fits into int, but I'd be afraid of small sideeffects somewhere...

Pavel

include/linux/bitops.h +2 -3
@@ -108,7 +108,7 @@
         return (res & 0x0F) + ((res >> 4) & 0x0F);
 }
 
-static inline unsigned int generic_hweight64(__u64 w)
+static inline unsigned long generic_hweight64(__u64 w)
 {
 #if BITS_PER_LONG < 64
 	return generic_hweight32((unsigned int)(w >> 32)) +
@@ -120,8 +120,7 @@
 	res = (res & 0x0F0F0F0F0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F0F0F0F0F);
 	res = (res & 0x00FF00FF00FF00FF) + ((res >> 8) & 0x00FF00FF00FF00FF);
 	res = (res & 0x0000FFFF0000FFFF) + ((res >> 16) & 0x0000FFFF0000FFFF);
-	res = (res & 0x00000000FFFFFFFF) + ((res >> 32) & 0x00000000FFFFFFFF);
-	return (unsigned int)res;
+	return (res & 0x00000000FFFFFFFF) + ((res >> 32) & 0x00000000FFFFFFFF);
 #endif
 }
#2 lore raw
Quoted 6 lines · On Tue, 17 Feb 2004 16:55:43 +0530 "Amit S. Kale" <[email protected]>…

Hi Pavel and kgdb gurus,

I inherited this change from x86_64 patch. Probably it was required on x86_64. I can't think of any reason why it is necessary.

Unless someone finds a problem with this patch, I am going to apply it.

You can just remove it. It's not needed. kgdb does not even use hweight*

I checked some time ago with Jim Houston (from which it originated) and he said it was a merging error leaking from some Concurrent internal tree.

-Andi