From ccf03fbcc5ef74542a4a088356470c1b0e4c191f Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Thu, 12 Jun 2008 10:47:58 +0200 Subject: [PATCH] --- yaml --- r: 98021 b: refs/heads/master c: d5e181f78ac753893eb930868a52a4488cd3de0a h: refs/heads/master i: 98019: 942cf3e5d95613bcfcac20e6e9fcab4175a8e919 v: v3 --- [refs] | 2 +- trunk/include/linux/math64.h | 19 +++++++++++++++++++ trunk/lib/div64.c | 15 +-------------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/[refs] b/[refs] index f817303a9d4f..30c5cfc190ca 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: f595ec964daf7f99668039d7303ddedd09a75142 +refs/heads/master: d5e181f78ac753893eb930868a52a4488cd3de0a diff --git a/trunk/include/linux/math64.h b/trunk/include/linux/math64.h index 177785e1e4a3..c87f1528703a 100644 --- a/trunk/include/linux/math64.h +++ b/trunk/include/linux/math64.h @@ -83,4 +83,23 @@ static inline s64 div_s64(s64 dividend, s32 divisor) 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 */ diff --git a/trunk/lib/div64.c b/trunk/lib/div64.c index 76c01542d3e1..a111eb8de9cf 100644 --- a/trunk/lib/div64.c +++ b/trunk/lib/div64.c @@ -105,19 +105,6 @@ EXPORT_SYMBOL(div64_u64); */ 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; + return __iter_div_u64_rem(dividend, divisor, remainder); } EXPORT_SYMBOL(iter_div_u64_rem);