tech-net archive

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

Re: Patches fixing unaligned access in the networking code



Actually (probably obviously to most people) I hade the sense of
the plan here entirely backwards.... The intent needs to be to
emulate what the processor does with *(uint32_t *)p ... so it needs
to be endian dependent, and so

	uint8_t *cp = p;

#ifdef LITTLE_ENDIAN		/* or however that is expressed, in kernel */
	return (cp[3] << 24) | (cp[2] << 16) | (cp[1] << 8) | cp[0];
#else
	return (cp[0] << 24) | (cp[1] << 16) | (cp[2] << 8) | cp[3];
#endif

You'll see I also fixed the var name mishap in the earlier message.
(I had written it using 'p' as the internal pointer, then saw that
your version used that as the arg name, so I changed - one of the (then)
two lines...

kre



Home | Main Index | Thread Index | Old Index