1 #ifndef _LINUX_MATH64_H
2 #define _LINUX_MATH64_H
4 #include <linux/types.h>
6 #if BITS_PER_LONG == 64
9 * div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder
11 * This is commonly provided by 32bit archs to provide an optimized 64bit
14 static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
16 *remainder = dividend % divisor;
17 return dividend / divisor;
21 * div_s64_rem - signed 64bit divide with 32bit divisor with remainder
23 static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
25 *remainder = dividend % divisor;
26 return dividend / divisor;
30 * div64_u64 - unsigned 64bit divide with 64bit divisor
32 static inline u64 div64_u64(u64 dividend, u64 divisor)
34 return dividend / divisor;
37 #elif BITS_PER_LONG == 32
40 static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
42 *remainder = do_div(dividend, divisor);
48 extern s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder);
52 extern u64 div64_u64(u64 dividend, u64 divisor);
55 #endif /* BITS_PER_LONG */
58 * div_u64 - unsigned 64bit divide with 32bit divisor
60 * This is the most common 64bit divide and should be used if possible,
61 * as many 32bit archs can optimize this variant better than a full 64bit
65 static inline u64 div_u64(u64 dividend, u32 divisor)
68 return div_u64_rem(dividend, divisor, &remainder);
73 * div_s64 - signed 64bit divide with 32bit divisor
76 static inline s64 div_s64(s64 dividend, s32 divisor)
79 return div_s64_rem(dividend, divisor, &remainder);
83 u32 iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder);
85 #endif /* _LINUX_MATH64_H */