time: prevent the loop in timespec_add_ns() from being optimised away
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>
This commit is contained in:
parent
e48af19f56
commit
38332cb987
1 changed files with 4 additions and 0 deletions
|
@ -174,6 +174,10 @@ static inline void timespec_add_ns(struct timespec *a, u64 ns)
|
||||||
{
|
{
|
||||||
ns += a->tv_nsec;
|
ns += a->tv_nsec;
|
||||||
while(unlikely(ns >= NSEC_PER_SEC)) {
|
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;
|
ns -= NSEC_PER_SEC;
|
||||||
a->tv_sec++;
|
a->tv_sec++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue