On Thu, 5 Sep 2002, Bill Moseley wrote: > About all I understand of this problem is that our code allocates memory > on 4-byte boundaries, and that cased SIGBUS on this one machine. I > printed out the results of malloc() calls and noticed it was always on > 8-byte boundaries. Hard-coding to 8-byte fixed our code.
AFAIK on 32 bit SPARC, like you are using (and on other platforms, like MIPS, etc) you often need to align structures on 8 bytes for floating point members. doubles have to be aligned on their size generally. If your structures contains only things <= 32 bits then you can get away with a 4 byte alignment in general, but if you add a double or a long long then some arches will demand 8 bytes. The basic rule is that the member of a structure has to be aligned on it's size - so a 2 byte short needs to have an addresss congruent to 2, a 4 byte long needs to be congruent to 4, a double to 8. Generally an allocator of this nature should align to the largest intrinsic type used in the structures it is allocating for. If that's a double or a uint64_t then it has to be 8 bytes. Jason