diff options
| author | 2008-07-21 00:55:14 -0400 | |
|---|---|---|
| committer | 2008-07-21 00:55:14 -0400 | |
| commit | 908cf4b925e419bc74f3297b2f0e51d6f8a81da2 (patch) | |
| tree | 6c2da79366d4695a9c2560ab18259eca8a2a25b4 /include/linux/math64.h | |
| parent | Input: add switch for dock events (diff) | |
| parent | Merge branch 'for-2.6.27' of git://linux-nfs.org/~bfields/linux (diff) | |
Merge master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6 into next
Diffstat (limited to 'include/linux/math64.h')
| -rw-r--r-- | include/linux/math64.h | 21 |
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 */ |
