title: Aligning both source and destination address in memcpy
body: <p>I want to write a memcpy code which does word by word copy instead of byte by byte to increase speed. (Though I need to do some byte by byte copy for the last or few bytes). So I want my source and destination address to be aligned properly. 
  I saw the implementation of memcpy in glibc 
  <a href="https://fossies.org/dox/glibc-2.22/string_2memcpy_8c_source.html" rel="nofollow">https://fossies.org/dox/glibc-2.22/string_2memcpy_8c_source.html</a>
  it does alignment only for destination address. But even if source address is not properly aligned it will result bus error (consider Alignment Checking is enabled in my cpu) I'm not sure how to make both source and destination to be aligned properly. Because if I try to align source by copying few bytes by byte by byte, it will also change the destination address, so at first the destination address which was aligned at first properly might not be aligned properly now.
  So is there any way to align both?. Please help me.</p>
  
  <pre><code>void  memcpy(void  *dst,  void  *src,int  size)
  {
     if(size &gt;= 8)
     {
       while(size/8) /* code will give sigbus error if src = 0x10003 and dst = 0x100000 */ 
       {
         *((double*)dst)++  =  *((double*)src)++; 
          size  =  size  -  8;
       }
     }
  
     while(size--)
     {
       *((char*)dst)++  =  *((char*)src)++;
     }
  }
  </code></pre>