aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/linux/linux-2.6.23/em-x270/01-prevent_loop_timespec_add_ns.patch
blob: a2f6e1765e562dfb488c09d756edca5df3eb1600 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
---
 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 2091a19..d32ef0a 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++;
	}