memcpy() inlining and alignment

Jason Thorpe thorpej@netbsd.org
Fri Mar 3 17:22:00 GMT 2000


On Fri, 3 Mar 2000 16:25:35 -0800 
 "David S. Miller" <davem@redhat.com> wrote:

 > I believe the compiler is correctly assuming that the structure is
 > aligned to whatever alignment is required by the members of the
 > structure type for a particular processor's ABI.  In this case, most
 > likely the required alignment is 4 bytes on 32-bit systems.
 > 
 > If this is the case, you'll need to create your own
 > "memcpy_unaligned()" or similar interface for these specific
 > cases.

I'm not sure I buy that.  What you're effectively saying is:

	There is no standard function in C that allows unaligned
	data to be copied into an aligned buffer.

Personally, I have never encountered a libc implementation of memcpy()
that required data to be aligned in the way you're suggesting.

	-- Jason R. Thorpe <thorpej@netbsd.org>



More information about the Gcc-bugs mailing list