Query regarding 2.6.21.7 Compilation Patch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux