* [PATCH 2/3] add an inlined version of iter_div_u64_rem
@ 2008-05-14 15:48 Jeremy Fitzhardinge
0 siblings, 0 replies; only message in thread
From: Jeremy Fitzhardinge @ 2008-05-14 15:48 UTC (permalink / raw)
To: Andrew Morton
Cc: Linux Kernel Mailing List, Ingo Molnar, Thomas Gleixner,
Andi Kleen
iter_div_u64_rem is used in the x86-64 vdso, which cannot call other
kernel code. For this case, provide the always_inlined version,
__iter_div_u64_rem.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
include/linux/math64.h | 19 +++++++++++++++++++
lib/div64.c | 15 +--------------
2 files changed, 20 insertions(+), 14 deletions(-)
===================================================================
--- a/include/linux/math64.h
+++ b/include/linux/math64.h
@@ -83,4 +83,23 @@
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 */
===================================================================
--- a/lib/div64.c
+++ b/lib/div64.c
@@ -105,19 +105,6 @@
*/
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);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-05-14 15:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-14 15:48 [PATCH 2/3] add an inlined version of iter_div_u64_rem Jeremy Fitzhardinge
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox