Skip to contentSkip to conversation

include/linux/bitops.h "integer" constants too large for u64

PATCH New Mike Jones 1 participant 1 message Jun 5, 2003 Bitops API

lore
Share & tools
lore

Mike Jones

author
#0 lore raw

PATCH 1/1 include/linux/bitops.h "integer" constants too large for u64

Hi,

I'm using GCC 3.3 to compile 2.5.70-mm4, and am being bombarded by warnings regarding the use of integer constants in include/linux/bitops.h. The attached patch, which is trivial, should fix the problem.

Please CC me on any replies, as I am not subscribed to the linux-kernel mailing list.

Regards,

Mike Jones

An excerpt of the warnings displayed on almost every compiled file:

include/linux/bitops.h: In function `generic_hweight64':
include/linux/bitops.h:118: warning: integer constant is too large for "unsigned long" type
include/linux/bitops.h:118: warning: integer constant is too large for "unsigned long" type
include/linux/bitops.h:119: warning: integer constant is too large for "unsigned long" type
include/linux/bitops.h:119: warning: integer constant is too large for "unsigned long" type
include/linux/bitops.h:120: warning: integer constant is too large for "unsigned long" type
include/linux/bitops.h:120: warning: integer constant is too large for "unsigned long" type
include/linux/bitops.h:121: warning: integer constant is too large for "unsigned long" type
include/linux/bitops.h:121: warning: integer constant is too large for "unsigned long" type
include/linux/bitops.h:122: warning: integer constant is too large for "unsigned long" type
include/linux/bitops.h:122: warning: integer constant is too large for "unsigned long" type

include/linux/bitops.h renamed from bitops.h +6 -6
@@ -115,12 +115,12 @@
 		return generic_hweight32((unsigned int)(w >> 32)) +
 					generic_hweight32((unsigned int)w);
 
-	res = (w & 0x5555555555555555) + ((w >> 1) & 0x5555555555555555);
-	res = (res & 0x3333333333333333) + ((res >> 2) & 0x3333333333333333);
-	res = (res & 0x0F0F0F0F0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F0F0F0F0F);
-	res = (res & 0x00FF00FF00FF00FF) + ((res >> 8) & 0x00FF00FF00FF00FF);
-	res = (res & 0x0000FFFF0000FFFF) + ((res >> 16) & 0x0000FFFF0000FFFF);
-	return (res & 0x00000000FFFFFFFF) + ((res >> 32) & 0x00000000FFFFFFFF);
+	res = (w & 0x5555555555555555ULL) + ((w >> 1) & 0x5555555555555555ULL);
+	res = (res & 0x3333333333333333ULL) + ((res >> 2) & 0x3333333333333333ULL);
+	res = (res & 0x0F0F0F0F0F0F0F0FULL) + ((res >> 4) & 0x0F0F0F0F0F0F0F0FULL);
+	res = (res & 0x00FF00FF00FF00FFULL) + ((res >> 8) & 0x00FF00FF00FF00FFULL);
+	res = (res & 0x0000FFFF0000FFFFULL) + ((res >> 16) & 0x0000FFFF0000FFFFULL);
+	return (res & 0x00000000FFFFFFFFULL) + ((res >> 32) & 0x00000000FFFFFFFFULL);
 }
 
 static inline unsigned long hweight_long(unsigned long w)