div64.h 819 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef _M68K_DIV64_H
  2. #define _M68K_DIV64_H
  3. #ifdef CONFIG_CPU_HAS_NO_MULDIV64
  4. #include <asm-generic/div64.h>
  5. #else
  6. #include <linux/types.h>
  7. /* n = n / base; return rem; */
  8. #define do_div(n, base) ({ \
  9. union { \
  10. unsigned long n32[2]; \
  11. unsigned long long n64; \
  12. } __n; \
  13. unsigned long __rem, __upper; \
  14. unsigned long __base = (base); \
  15. \
  16. __n.n64 = (n); \
  17. if ((__upper = __n.n32[0])) { \
  18. asm ("divul.l %2,%1:%0" \
  19. : "=d" (__n.n32[0]), "=d" (__upper) \
  20. : "d" (__base), "0" (__n.n32[0])); \
  21. } \
  22. asm ("divu.l %2,%1:%0" \
  23. : "=d" (__n.n32[1]), "=d" (__rem) \
  24. : "d" (__base), "1" (__upper), "0" (__n.n32[1])); \
  25. (n) = __n.n64; \
  26. __rem; \
  27. })
  28. #endif /* CONFIG_CPU_HAS_NO_MULDIV64 */
  29. #endif /* _M68K_DIV64_H */