1 #ifndef __LUNAIX_MULDIV64_H
2 #define __LUNAIX_MULDIV64_H
4 #include <lunaix/spike.h>
5 #include <lunaix/types.h>
7 #ifdef CONFIG_ARCH_I386
8 #define do_udiv64(n, base) \
10 unsigned long __upper, __low, __high, __mod, __base; \
12 if (__builtin_constant_p(__base) && is_pot(__base)) { \
13 __mod = n & (__base - 1); \
14 n >>= ILOG2(__base); \
16 asm("" : "=a"(__low), "=d"(__high) : "A"(n)); \
19 __upper = __high % (__base); \
20 __high = __high / (__base); \
23 : "=a"(__low), "=d"(__mod) \
24 : "rm"(__base), "0"(__low), "1"(__upper)); \
25 asm("" : "=A"(n) : "a"(__low), "d"(__high)); \
30 #define do_udiv64(n, base) \
38 udiv64(u64_t n, unsigned int base)
45 static inline unsigned int
46 umod64(u64_t n, unsigned int base)
48 return do_udiv64(n, base);
51 #endif /* __LUNAIX_MULDIV64_H */