title: How do I ensure buffer memory is aligned?
body: <p>I am using a hardware interface to send data that requires me to set up a <a href="http://en.wikipedia.org/wiki/Direct_memory_access" rel="nofollow noreferrer">DMA</a> buffer, which needs to be aligned on 64 bits boundaries.</p>
  <p>The DMA engine expects buffers to be aligned on at least 32 bits boundaries (4 bytes). For optimal performance the buffer should be aligned on 64 bits boundaries (8 bytes). The transfer size must be a multiple of 4 bytes.</p>
  <p>I create buffers using <code>posix_memalign</code>, as demonstrated in the snippet bellow.</p>
  <pre><code>  posix_memalign ((void**)&amp;pPattern, 0x1000, DmaBufferSizeinInt32s * sizeof(int))
  </code></pre>
  <p><code>pPattern</code> is a pointer to an int, and is the start of my buffer which is <code>DmaBufferSizeinInt32s </code> deep.</p>
  <p>Is my buffer aligned on 64bits?</p>