tomash.brechko at gmail.com
Mon Dec 3 19:55:29 UTC 2007
On Mon, Dec 03, 2007 at 11:19:59 -0800, Dustin Sallings wrote:
> >BTW, all this (uint64_t*), (int*) casts call for a BIG FAT WARNING
> >that we heavily depend on the fact that the address is properly
> >aligned for this type, i.e. dereferencing uint64_t* not aligned to 8
> >bytes would trap on some platforms.
> Where would this be an issue? Would the compiler generate a
> warning? Is it otherwise possible to test for correctness?
This would be an issue on Sun for sure, and probably on any other RISC
machine (as well as on modern x86 in Strict Alignment Mode, though I
don't know how to enable it :-/).
The compiler can't help you, because the exact address will be known
at run time only.
You can test it for correctness only by reading the code. As malloc
family returns the address aligned for any type, such address +
sizeof(base_type) * N is also aligned for this base_type.
For my reading current code is correct, and since it is dependent on
header size being 12 anyways, I think just adding the comment would be
More information about the memcached