[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Architectures where unaligned access is (not) OK?



On 23/11/14 22:54, Ben Hutchings wrote:
> in this function
> 
> 	void copy_foo(struct foo *dst, const struct foo *src)
> 	{
> 		memcpy(dst, src, sizeof(*dst));
> 	}
> 
> the compiler is still allowed to assume that src has the proper
> alignment for struct foo and to optimise the memcpy() accordingly.

I don't *think* lzo relies on that; the struct assignment I mentioned in
a previous mail is part of its fallback implementation of what is
basically 1-, 2-, 4- and 8-byte memcpy. The arguments seem to be
unsigned char * in practice.

liblzo2 seems to be one of these codebases that bases its idea of how C
works on portability folklore and the assumption that the compiler and
standard C library are the most naive implementation possible :-(

    S


Reply to: