|
From: Jeremy F. <je...@go...> - 2003-12-02 03:24:55
|
On Mon, 2003-12-01 at 06:37, Nicholas Nethercote wrote: > 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? Well, unaligned accesses are only OK by default. You can turn on alignment checking, and get faults on unaligned accesses. Also, SSE instructions have a 16-byte alignment requirement. I would say that we have to return malloc blocks at least 8-byte aligned (for doubles), and perhaps 16-byte aligned (for SSE). Returning 4-byte aligned blocks doesn't really help anyone, and breaks a lot of stuff. If someone really wants 4 byte alignment, they can always ask for it: --alignment=4. J |