diff options
author | Roman Zippel <zippel@linux-m68k.org> | 2008-05-01 07:34:31 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-05-01 11:03:58 -0400 |
commit | f8bd2258e2d520dff28c855658bd24bdafb5102d (patch) | |
tree | d76db1dc858cb316bc7d5b8473f690a753fd2c93 /kernel/time.c | |
parent | 6f6d6a1a6a1336431a6cba60ace9e97c3a496a19 (diff) |
remove div_long_long_rem
x86 is the only arch right now, which provides an optimized for
div_long_long_rem and it has the downside that one has to be very careful that
the divide doesn't overflow.
The API is a little akward, as the arguments for the unsigned divide are
signed. The signed version also doesn't handle a negative divisor and
produces worse code on 64bit archs.
There is little incentive to keep this API alive, so this converts the few
users to the new API.
Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: john stultz <johnstul@us.ibm.com>
Cc: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/time.c')
-rw-r--r-- | kernel/time.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/kernel/time.c b/kernel/time.c index 343e2515375a..cbe0d5a222ff 100644 --- a/kernel/time.c +++ b/kernel/time.c | |||
@@ -392,13 +392,17 @@ EXPORT_SYMBOL(set_normalized_timespec); | |||
392 | struct timespec ns_to_timespec(const s64 nsec) | 392 | struct timespec ns_to_timespec(const s64 nsec) |
393 | { | 393 | { |
394 | struct timespec ts; | 394 | struct timespec ts; |
395 | s32 rem; | ||
395 | 396 | ||
396 | if (!nsec) | 397 | if (!nsec) |
397 | return (struct timespec) {0, 0}; | 398 | return (struct timespec) {0, 0}; |
398 | 399 | ||
399 | ts.tv_sec = div_long_long_rem_signed(nsec, NSEC_PER_SEC, &ts.tv_nsec); | 400 | ts.tv_sec = div_s64_rem(nsec, NSEC_PER_SEC, &rem); |
400 | if (unlikely(nsec < 0)) | 401 | if (unlikely(rem < 0)) { |
401 | set_normalized_timespec(&ts, ts.tv_sec, ts.tv_nsec); | 402 | ts.tv_sec--; |
403 | rem += NSEC_PER_SEC; | ||
404 | } | ||
405 | ts.tv_nsec = rem; | ||
402 | 406 | ||
403 | return ts; | 407 | return ts; |
404 | } | 408 | } |
@@ -528,8 +532,10 @@ jiffies_to_timespec(const unsigned long jiffies, struct timespec *value) | |||
528 | * Convert jiffies to nanoseconds and separate with | 532 | * Convert jiffies to nanoseconds and separate with |
529 | * one divide. | 533 | * one divide. |
530 | */ | 534 | */ |
531 | u64 nsec = (u64)jiffies * TICK_NSEC; | 535 | u32 rem; |
532 | value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &value->tv_nsec); | 536 | value->tv_sec = div_u64_rem((u64)jiffies * TICK_NSEC, |
537 | NSEC_PER_SEC, &rem); | ||
538 | value->tv_nsec = rem; | ||
533 | } | 539 | } |
534 | EXPORT_SYMBOL(jiffies_to_timespec); | 540 | EXPORT_SYMBOL(jiffies_to_timespec); |
535 | 541 | ||
@@ -567,12 +573,11 @@ void jiffies_to_timeval(const unsigned long jiffies, struct timeval *value) | |||
567 | * Convert jiffies to nanoseconds and separate with | 573 | * Convert jiffies to nanoseconds and separate with |
568 | * one divide. | 574 | * one divide. |
569 | */ | 575 | */ |
570 | u64 nsec = (u64)jiffies * TICK_NSEC; | 576 | u32 rem; |
571 | long tv_usec; | ||
572 | 577 | ||
573 | value->tv_sec = div_long_long_rem(nsec, NSEC_PER_SEC, &tv_usec); | 578 | value->tv_sec = div_u64_rem((u64)jiffies * TICK_NSEC, |
574 | tv_usec /= NSEC_PER_USEC; | 579 | NSEC_PER_SEC, &rem); |
575 | value->tv_usec = tv_usec; | 580 | value->tv_usec = rem / NSEC_PER_USEC; |
576 | } | 581 | } |
577 | EXPORT_SYMBOL(jiffies_to_timeval); | 582 | EXPORT_SYMBOL(jiffies_to_timeval); |
578 | 583 | ||