diff options
| author | J. Bruce Fields <bfields@citi.umich.edu> | 2008-07-03 16:24:06 -0400 |
|---|---|---|
| committer | J. Bruce Fields <bfields@citi.umich.edu> | 2008-07-03 16:24:06 -0400 |
| commit | e86322f611eef95aafaf726fd3965e5b211f1985 (patch) | |
| tree | 28547e26df4fc6ae671dc8cc6912a53717e4db08 /include/linux/math64.h | |
| parent | b001a1b6aa960949a24c2cdc28257dfcc9428d74 (diff) | |
| parent | 8948896c9e098c6fd31a6a698a598a7cbd7fa40e (diff) | |
Merge branch 'for-bfields' of git://linux-nfs.org/~tomtucker/xprt-switch-2.6 into for-2.6.27
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 */ |
