aboutsummaryrefslogtreecommitdiffstats
path: root/lib/div64.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@linux-foundation.org>2007-03-22 15:10:18 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-04-26 01:27:18 -0400
commit22b9a0a3a49ab1a856e0853b3f3dd2abd156bd7c (patch)
treebacdd0f5ab3e94f5f137b03072b2319eeb767d2b /lib/div64.c
parentc454673da7c1d6533f40ec2f788023df9af56ebf (diff)
[LIB]: div64_64 optimization
Minor optimization of div64_64. do_div() already does optimization for the case of 32 by 32 divide, so no need to do it here. Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'lib/div64.c')
-rw-r--r--lib/div64.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/div64.c b/lib/div64.c
index c3d7655cdfb5..74f0c8cb4031 100644
--- a/lib/div64.c
+++ b/lib/div64.c
@@ -61,20 +61,18 @@ EXPORT_SYMBOL(__div64_32);
61/* 64bit divisor, dividend and result. dynamic precision */ 61/* 64bit divisor, dividend and result. dynamic precision */
62uint64_t div64_64(uint64_t dividend, uint64_t divisor) 62uint64_t div64_64(uint64_t dividend, uint64_t divisor)
63{ 63{
64 uint32_t d = divisor; 64 uint32_t high, d;
65 65
66 if (divisor > 0xffffffffULL) { 66 high = divisor >> 32;
67 unsigned int shift = fls(divisor >> 32); 67 if (high) {
68 unsigned int shift = fls(high);
68 69
69 d = divisor >> shift; 70 d = divisor >> shift;
70 dividend >>= shift; 71 dividend >>= shift;
71 } 72 } else
73 d = divisor;
72 74
73 /* avoid 64 bit division if possible */ 75 do_div(dividend, d);
74 if (dividend >> 32)
75 do_div(dividend, d);
76 else
77 dividend = (uint32_t) dividend / d;
78 76
79 return dividend; 77 return dividend;
80} 78}