summaryrefslogtreecommitdiff
path: root/include/linux/math64.h
diff options
context:
space:
mode:
authorIngo Molnar <mingo@elte.hu>2008-06-16 11:20:28 +0200
committerIngo Molnar <mingo@elte.hu>2008-06-16 11:20:28 +0200
commitfaeca31d068090285b77c39574d2bda14b079c50 (patch)
tree789841a7f0d336b24a74f2191542a2eb8177c8fa /include/linux/math64.h
parent499f8f84b8324ba27d756e03f373fa16eeed9ccc (diff)
parent066519068ad2fbe98c7f45552b1f592903a9c8c8 (diff)
Merge branch 'linus' into x86/pattip-x86-pat-2008-06-16_09.20_Mon
Diffstat (limited to 'include/linux/math64.h')
-rw-r--r--include/linux/math64.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/linux/math64.h b/include/linux/math64.h
index c1a5f81501ff..c87f1528703a 100644
--- a/include/linux/math64.h
+++ b/include/linux/math64.h
@@ -81,4 +81,25 @@ static inline s64 div_s64(s64 dividend, s32 divisor)
}
#endif
+u32 iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder);
+
+static __always_inline u32
+__iter_div_u64_rem(u64 dividend, u32 divisor, u64 *remainder)
+{
+ u32 ret = 0;
+
+ while (dividend >= divisor) {
+ /* The following asm() prevents the compiler from
+ optimising this loop into a modulo operation. */
+ asm("" : "+rm"(dividend));
+
+ dividend -= divisor;
+ ret++;
+ }
+
+ *remainder = dividend;
+
+ return ret;
+}
+
#endif /* _LINUX_MATH64_H */