On Wednesday 14 April 2010 13:14:07 Denys Vlasenko wrote: > Are you saying that here: > > # define move_from_unaligned16(v, u16p) (memcpy(&(v), (u16p), 2)) > > memcpy may be opportunistic and if u16p has type uin16_t, > memcpy will be optimized to assignment? If so, this > should be prevented from happening. We WANT to be damn sure > any address, however badly unaligned, will work in this macro.
this is correct behavior. gcc may assume the minalignment values based upon the pointer type. if the pointer is assigned an address that does not satsify the type's basic alignment requirements (e.g. uint16_t *p = 1), then that code is broken and needs fixing. most of the time, people start with void* with the unaligned pointer and then memcpy/memmove it to a pointer/struct with the correct alignment. -mike
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
