diff options
author | Segher Boessenkool <segher@kernel.crashing.org> | 2008-03-04 14:59:54 -0800 |
---|---|---|
committer | Chris Wright <chrisw@sous-sol.org> | 2008-04-18 18:53:18 -0700 |
commit | 8512564b498417a1e6e9a4a228c20ffc667c3c0b (patch) | |
tree | 1f607480b1b36393c20620ee251a1a892612d1c9 /include | |
parent | 16c64cac7d9c6a503f49887219c4fe675e7d43d9 (diff) |
time: prevent the loop in timespec_add_ns() from being optimised away
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>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/time.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/include/linux/time.h b/include/linux/time.h index b04136d60a2..3e8fd9e57e3 100644 --- a/include/linux/time.h +++ b/include/linux/time.h @@ -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++; } |