Skip to content

Commit

Permalink
time: prevent the loop in timespec_add_ns() from being optimised away
Browse files Browse the repository at this point in the history
Since some architectures don't support __udivdi3().

Signed-off-by: Segher Boessenkool <segher@kernel.crashing.org>
Cc: john stultz <johnstul@us.ibm.com>
Cc: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information
Segher Boessenkool authored and Thomas Gleixner committed Mar 9, 2008
1 parent e48af19 commit 38332cb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/linux/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ static inline void timespec_add_ns(struct timespec *a, u64 ns)
{
ns += a->tv_nsec;
while(unlikely(ns >= NSEC_PER_SEC)) {
/* The following asm() prevents the compiler from
* optimising this loop into a modulo operation. */
asm("" : "+r"(ns));

ns -= NSEC_PER_SEC;
a->tv_sec++;
}
Expand Down

0 comments on commit 38332cb

Please sign in to comment.