title: Linux kernel compilation error: undefined reference to `__udivdi3' & `__umoddi3'
body: <p>Here is the error I've got:
  <a href="http://pastebin.com/VadUW6fy" rel="nofollow">http://pastebin.com/VadUW6fy</a></p>
  
  <pre><code>drivers/built-in.o: In function `gem_rxmac_reset':
  clkdev.c:(.text+0x212238): undefined reference to `__bad_udelay'
  drivers/built-in.o: In function `divide.part.4':
  clkdev.c:(.text.unlikely+0x7214): undefined reference to `__udivdi3'
  clkdev.c:(.text.unlikely+0x7244): undefined reference to `__umoddi3'
  </code></pre>
  
  <p>I googled and found this patch: <a href="https://lkml.org/lkml/2008/4/7/82" rel="nofollow">https://lkml.org/lkml/2008/4/7/82</a></p>
  
  <pre><code>--- 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-&gt;tv_nsec;
          while(unlikely(ns &gt;= 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-&gt;tv_sec++;
          }
  </code></pre>
  
  <p>but failed to apply (may be due to new version of the file).</p>
  
  <pre><code>     patching file linux/time.h
       Hunk #1 FAILED at 174.
       1 out of 1 hunk FAILED -- saving rejects to file linux/time.h.rej
  </code></pre>
  
  <p>surprisingly, the file <code>time.h.rej</code> is not present!</p>