This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: improving malloc

On Sat, Jan 05, 2013 at 04:13:34PM +0000, Joseph S. Myers wrote:
> On Sat, 5 Jan 2013, Ond?Yej BÃlka wrote:
> > If we relax alignment guarante we can reduce memory consumption more
> > by returning 8byte requests aligned only to 8 bytes.
> All allocations are required by ISO C to be sufficiently aligned for any 
> standard type, including types larger than the size of the allocation (see 
> C90 DR#075).

Read the text of the response
( The
requirement is only that (void *)(T *)p == p for any p returned by
malloc. This is true even if the pointer is not aligned in the "value
of the pointer as an integer" sense of alignment; the only way it
could be false is on a system where different pointer types have
different representations, which glibc does not support. The C
standard does not provide any way to otherwise "inspect" the alignment
of a pointer, so there is no requirement that the low bits of the
pointer actually be zero, since a conforming application cannot
observe whether they are or not. In particular, since the value of
casts from pointers to integers are implementation-defined, there is
no requirement that (uintptr_t)p & (1<<MAX_ALIGN)-1 == 0, even though
a lower bound on MAX_ALIGN is observable with _Alignof or the
traditional macros to accomplish the same thing.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]