diff options
| author | Ingo Molnar <mingo@elte.hu> | 2008-07-10 08:17:14 +0200 |
|---|---|---|
| committer | Ingo Molnar <mingo@elte.hu> | 2008-07-10 08:17:14 +0200 |
| commit | 9e4144abf8a30ae221311368bbb10690ebdb4b76 (patch) | |
| tree | 032289d5b7d87976675c1a1a32d512a44d234fa2 /include/linux/math64.h | |
| parent | e17ba73b0ee6c0f24393c48b455e0d8db761782c (diff) | |
| parent | 6329d3021bcfa9038621e6e917d98929421d8ec8 (diff) | |
Merge branch 'linus' into core/printk
Conflicts:
kernel/printk.c
Signed-off-by: Ingo Molnar <mingo@elte.hu>
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 */ |
