time: prevent the loop in timespec_add_ns() from being optimised away
authorSegher Boessenkool <segher@kernel.crashing.org>
Tue, 4 Mar 2008 22:59:54 +0000 (14:59 -0800)
committerChris Wright <chrisw@sous-sol.org>
Sat, 19 Apr 2008 01:53:18 +0000 (18:53 -0700)
upstream commit: 38332cb98772f5ea757e6486bed7ed0381cb5f98

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>
Cc: Sedat Dilek <sedat.dilek@googlemail.com>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
include/linux/time.h

index b04136d60a2f79c5293ddc641e664afa18820ee0..3e8fd9e57e3092d733105c88b04339bb2ee8ea54 100644 (file)
@@ -173,6 +173,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++;
        }