summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Pitre <nicolas.pitre@linaro.org>2015-11-02 13:02:46 -0500
committerNicolas Pitre <nicolas.pitre@linaro.org>2015-11-16 14:42:12 -0500
commitdce1eb93b19b2a1a441708f51c97c4a554054d00 (patch)
tree584554913e7eae7f3ab7686862fac8c59eaf0394
parentf682b27c57aec2f0ca8927f9bb7c267c6165ad5a (diff)
__div64_32(): make it overridable at compile time
Some architectures may want to override the default implementation at compile time to do things inline. For example, ARM uses a non-standard calling convention for better efficiency in this case. Signed-off-by: Nicolas Pitre <nico@linaro.org>
-rw-r--r--include/asm-generic/div64.h2
-rw-r--r--lib/div64.c6
2 files changed, 6 insertions, 2 deletions
diff --git a/include/asm-generic/div64.h b/include/asm-generic/div64.h
index 408856a9aba1..163f77999ea4 100644
--- a/include/asm-generic/div64.h
+++ b/include/asm-generic/div64.h
@@ -194,7 +194,9 @@ static inline uint64_t __arch_xprod_64(const uint64_t m, uint64_t n, bool bias)
194} 194}
195#endif 195#endif
196 196
197#ifndef __div64_32
197extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor); 198extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
199#endif
198 200
199/* The unnecessary pointer compare is there 201/* The unnecessary pointer compare is there
200 * to check for type safety (n must be 64bit) 202 * to check for type safety (n must be 64bit)
diff --git a/lib/div64.c b/lib/div64.c
index 62a698a432bc..7f345259c32f 100644
--- a/lib/div64.c
+++ b/lib/div64.c
@@ -13,7 +13,8 @@
13 * 13 *
14 * Code generated for this function might be very inefficient 14 * Code generated for this function might be very inefficient
15 * for some CPUs. __div64_32() can be overridden by linking arch-specific 15 * for some CPUs. __div64_32() can be overridden by linking arch-specific
16 * assembly versions such as arch/ppc/lib/div64.S and arch/sh/lib/div64.S. 16 * assembly versions such as arch/ppc/lib/div64.S and arch/sh/lib/div64.S
17 * or by defining a preprocessor macro in arch/include/asm/div64.h.
17 */ 18 */
18 19
19#include <linux/export.h> 20#include <linux/export.h>
@@ -23,6 +24,7 @@
23/* Not needed on 64bit architectures */ 24/* Not needed on 64bit architectures */
24#if BITS_PER_LONG == 32 25#if BITS_PER_LONG == 32
25 26
27#ifndef __div64_32
26uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base) 28uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
27{ 29{
28 uint64_t rem = *n; 30 uint64_t rem = *n;
@@ -55,8 +57,8 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
55 *n = res; 57 *n = res;
56 return rem; 58 return rem;
57} 59}
58
59EXPORT_SYMBOL(__div64_32); 60EXPORT_SYMBOL(__div64_32);
61#endif
60 62
61#ifndef div_s64_rem 63#ifndef div_s64_rem
62s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder) 64s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)