After reading the mail, it seems I should give the compilation error log to make the question crisp. So here it is:
> kernel/built-in.o: In function `getnstimeofday': > (.text+0x22bdc): undefined reference to `__umoddi3' > kernel/built-in.o: In function `getnstimeofday': > (.text+0x22bfc): undefined reference to `__udivdi3' > kernel/built-in.o: In function `do_gettimeofday': > (.text+0x22d0e): undefined reference to `__udivdi3' > kernel/built-in.o: In function `do_gettimeofday': > (.text+0x22d2c): undefined reference to `__umoddi3' > kernel/built-in.o: In function `timekeeping_resume': > timekeeping.c:(.text+0x22fd4): undefined reference to `__umoddi3' > timekeeping.c:(.text+0x22ff4): undefined reference to `__udivdi3' > kernel/built-in.o: In function `update_wall_time': > (.text+0x23306): undefined reference to `__umoddi3' > kernel/built-in.o: In function `update_wall_time': > (.text+0x23326): undefined reference to `__udivdi3' > kernel/built-in.o: In function `update_wall_time': > (.text+0x23796): undefined reference to `__umoddi3' > kernel/built-in.o: In function `update_wall_time': > (.text+0x237b6): undefined reference to `__udivdi3'
From: himanshu.chauhan2@xxxxxxxxxxxx To: kernelnewbies@xxxxxxxxxxxx Subject: Query regarding 2.6.21.7 Compilation Patch Date: Sun, 13 Dec 2009 09:11:01 +0000
2.6.21.7 is broken with latest GCC. The following patch fixes the issue. Its a build break because of compiler optimizing using modulo.
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 @@ -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++; }
---------- My Question:
What is "asm ("" : "+r"(ns))" doing here and how does this fix the issue?
Thanks & Regards Himanshu
http://windows.microsoft.com/shop Find the right PC for you.
Windows 7: Find the right PC for you. Learn more.
|