1 /* SPDX-License-Identifier: GPL-2.0 */
5 #ifdef CONFIG_CPU_HAS_NO_MULDIV64
6 #include <asm-generic/div64.h>
9 #include <linux/types.h>
11 /* n = n / base; return rem; */
13 #define do_div(n, base) ({ \
15 unsigned long n32[2]; \
16 unsigned long long n64; \
18 unsigned long __rem, __upper; \
19 unsigned long __base = (base); \
22 if ((__upper = __n.n32[0])) { \
23 asm ("divul.l %2,%1:%0" \
24 : "=d" (__n.n32[0]), "=d" (__upper) \
25 : "d" (__base), "0" (__n.n32[0])); \
27 asm ("divu.l %2,%1:%0" \
28 : "=d" (__n.n32[1]), "=d" (__rem) \
29 : "d" (__base), "1" (__upper), "0" (__n.n32[1])); \
34 #endif /* CONFIG_CPU_HAS_NO_MULDIV64 */
36 #endif /* _M68K_DIV64_H */