|
From: Nicholas N. <nj...@ca...> - 2003-12-01 14:37:51
|
Hi, There was a thread about malloc() alignment on the users list not long ago. Should V's malloc() return 8-byte aligned blocks? The malloc() man page says: For calloc() and malloc(), the value returned is a pointer to the allocated memory, which is suitably aligned for any kind of variable, or NULL if the request fails. The C standard, section 7.20.3 (from wwwold.dkuug.dk/jtc1/sc22/open/n2794/n2794.txt) says: The pointer returned if the allocation succeeds is suitably aligned so that it may be assigned to a pointer to any type of object and then used to access such an object or an array of such objects in the space allocated (until the space is explicitly freed or reallocated). I'm not sure what this actually means. For x86, does "suitably aligned" have any meaning at all, since unaligned accesses are ok? In short, I'd like it if we had a good reason to change the default malloc() alignment to 8-bytes, because it's one less thing for users to trip over. But if there isn't a good reason, I guess we should keep things as they are. N |