diff options
author | Brian Behlendorf <behlendorf1@llnl.gov> | 2010-10-26 17:23:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-26 19:52:19 -0400 |
commit | 658716d19f8f155c67d4677ba68034b8e492dfbe (patch) | |
tree | 8743b9a16606a63dc33f93c580367baf36692454 /include/linux/kernel.h | |
parent | 5d051decfc27cdf33fbbd2bfca958d0d2c903569 (diff) |
div64_u64(): improve precision on 32bit platforms
The current implementation of div64_u64 for 32bit systems returns an
approximately correct result when the divisor exceeds 32bits. Since doing
64bit division using 32bit hardware is a long since solved problem we just
use one of the existing proven methods.
Additionally, add a div64_s64 function to correctly handle doing signed
64bit division.
Addresses https://bugzilla.redhat.com/show_bug.cgi?id=616105
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Ben Woodard <bwoodard@llnl.gov>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>
Cc: Mark Grondona <mgrondona@llnl.gov>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 77b04ed037df..450092c1e35f 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -173,6 +173,11 @@ extern int _cond_resched(void); | |||
173 | (__x < 0) ? -__x : __x; \ | 173 | (__x < 0) ? -__x : __x; \ |
174 | }) | 174 | }) |
175 | 175 | ||
176 | #define abs64(x) ({ \ | ||
177 | s64 __x = (x); \ | ||
178 | (__x < 0) ? -__x : __x; \ | ||
179 | }) | ||
180 | |||
176 | #ifdef CONFIG_PROVE_LOCKING | 181 | #ifdef CONFIG_PROVE_LOCKING |
177 | void might_fault(void); | 182 | void might_fault(void); |
178 | #else | 183 | #else |