Fix SIGBUS crash when copying data

We have the following memory alignment-related issue, that seems
to be architecture/compiler/memcpy(3) specific.

Within struct tBTIF_CONTEXT_SWITCH_CBACK, the beginning of the
zero-length array "char p_param[]" is not aligned (because of the
struct internals).
However, this p_param pointer is casted within function
btif_gattc_deep_copy() to the struct pointer (btif_adv_data_t *).
By definition, the memory pointed to by such pointer is suppose
to be aligned:

    btif_adv_data_t *dst = (btif_adv_data_t*) p_dest;

It seems that on some architectures/compilers the executed memcpy()
instructions are optimized for such memory alignment.
If the memory was not aligned, we get SIGBUS.

Apparently, just using (void *) casting for the memcpy() destination,
avoids using the optimized memory aligned instructions:
  memcpy((void *)dst, src, ...);

The solutions are twofold:
 * Make sure that "char p_param[]" within struct
   tBTIF_CONTEXT_SWITCH_CBACK is aligned. Otherwise, the casting
   to "(btif_adv_data_t*)" can be problematic.
 * Add (void *) casting to all memcpy() calls which might be
   referring to such mis-aligned memory.
   This is done by using the new macro maybe_non_aligned_memcpy()
   in all places that such casting might be needed.

Either solution is sufficient to prevent the crash as identified in
this particular case. We need to apply both solutions, to reduce the
chance of running again into a similar issue.

Bug: 25601669
Change-Id: I6c49645c00f10c594a5d1e53a9fac202c506657c
7 files changed