From: Vishwanath Pai <hidden> Date: 2016-09-27 07:42:03
Fix link error in 32bit arch because of 64bit division
Division of 64bit integers will cause linker error undefined reference
to `__udivdi3'. Fix this by replacing divisions with div64_64
Signed-off-by: Vishwanath Pai <redacted>
---
net/netfilter/xt_hashlimit.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
@@ -465,19 +465,20 @@ static u64 user2credits(u64 user, int revision){if(revision==1){/* If multiplying would overflow... */-if(user>0xFFFFFFFF/(HZ*CREDITS_PER_JIFFY_v1))+if(user>div64_u64(0xFFFFFFFF,(HZ*CREDITS_PER_JIFFY_v1)))
Here divisor and dividend are all 32-bit integer, so covert "/" to div64_u64
seems unnecessary.
0xFFFFFFFFFFFFFFFF and "HZ*CREDITS_PER_JIFFY" are both
constant, and GCC will do constant folding optimization, so I think
convert "/" to div64_u64 here is also unnecessary.
From: Eric Dumazet <hidden> Date: 2016-09-27 13:32:21
On Tue, 2016-09-27 at 03:42 -0400, Vishwanath Pai wrote:
quoted hunk
Fix link error in 32bit arch because of 64bit division
Division of 64bit integers will cause linker error undefined reference
to `__udivdi3'. Fix this by replacing divisions with div64_64
Signed-off-by: Vishwanath Pai <redacted>
---
net/netfilter/xt_hashlimit.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
@@ -465,19 +465,20 @@ static u64 user2credits(u64 user, int revision){if(revision==1){/* If multiplying would overflow... */-if(user>0xFFFFFFFF/(HZ*CREDITS_PER_JIFFY_v1))+if(user>div64_u64(0xFFFFFFFF,(HZ*CREDITS_PER_JIFFY_v1)))
How can this be needed ? 0xFFFFFFFF is 32bits, compiler knows how to
compute 0xFFFFFFFF / (HZ*CREDITS_PER_JIFFY_v1) itself, without using a
64 bit divide !
Please be selective.