diff options
Diffstat (limited to 'lib/div64.c')
-rw-r--r-- | lib/div64.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/div64.c b/lib/div64.c index 365719f84832..b71cf93c529a 100644 --- a/lib/div64.c +++ b/lib/div64.c | |||
@@ -23,7 +23,7 @@ | |||
23 | /* Not needed on 64bit architectures */ | 23 | /* Not needed on 64bit architectures */ |
24 | #if BITS_PER_LONG == 32 | 24 | #if BITS_PER_LONG == 32 |
25 | 25 | ||
26 | uint32_t __div64_32(uint64_t *n, uint32_t base) | 26 | uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base) |
27 | { | 27 | { |
28 | uint64_t rem = *n; | 28 | uint64_t rem = *n; |
29 | uint64_t b = base; | 29 | uint64_t b = base; |
@@ -58,4 +58,24 @@ uint32_t __div64_32(uint64_t *n, uint32_t base) | |||
58 | 58 | ||
59 | EXPORT_SYMBOL(__div64_32); | 59 | EXPORT_SYMBOL(__div64_32); |
60 | 60 | ||
61 | /* 64bit divisor, dividend and result. dynamic precision */ | ||
62 | uint64_t div64_64(uint64_t dividend, uint64_t divisor) | ||
63 | { | ||
64 | uint32_t high, d; | ||
65 | |||
66 | high = divisor >> 32; | ||
67 | if (high) { | ||
68 | unsigned int shift = fls(high); | ||
69 | |||
70 | d = divisor >> shift; | ||
71 | dividend >>= shift; | ||
72 | } else | ||
73 | d = divisor; | ||
74 | |||
75 | do_div(dividend, d); | ||
76 | |||
77 | return dividend; | ||
78 | } | ||
79 | EXPORT_SYMBOL(div64_64); | ||
80 | |||
61 | #endif /* BITS_PER_LONG == 32 */ | 81 | #endif /* BITS_PER_LONG == 32 */ |