title: how use a structure in a unaligned buffer
body: <p>In my network app, in the received buffer, I want to use an offset as a pointer to a known struct.
  Copying every field of the structure with memcpy() 2 times (rx/tx) is heavy.
  I know that my gcc 4.7.2 (option: -O3) on cortex-a8, do memcpy(&amp;a,&amp;buff,4) in 1 instruction unaligned.
  So, he can access to unaligned int.
  Assume that it could have lot of struct, or big struct.
  What's the best way to do it?</p>
  
  <pre><code>struct __attribute__ ((__packed__)) msg_struct {
    int a;  //0 offset
    char b; //4 offset
    int c;  //5 offset
    int d[100];  //9 offset
  }
  
  char buff[1000];// [0]:header_size [1-header_size]:header [header_size+1]msg_struct
  
  func() {
    struct msg_struct *msg;
    recv ((void *)buff, sizeof(buff));
    msg=buff+header_size; // so, it is unaligned.
    ...
      // some work like:
      int valueRcv=msg-&gt;c;
    //or modify buff before send 
    msg-&gt;c=12;
  
    send(buff,sizeof(buff));
  }
  </code></pre>