This is the mail archive of the libc-alpha@sourceware.org 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: [PATCH] libio: Add small optimization on fmemopen


* Ondřej Bílka:

> On Fri, Sep 23, 2016 at 07:34:24AM +0200, Florian Weimer wrote:
>> On 09/23/2016 07:17 AM, Ondřej Bílka wrote:
>> >>  size_t clen = sizeof (fmemopen_cookie_t);
>> >>  if (FLEXMEMBER_NEEDS_ALIGNMENT)
>> >>    clen += _Alignof (fmemopen_cookie_t) - 1;
>> >
>> >Couldn't you just use __attribute__((aligned(16))) or is that also
>> >buggy?
>> 
>> Buggy in what sense?
>> 
>> malloc isn't guaranteed to provide 16-byte alignment on all glibc
>> architectures.
>> 
> Buggy in sense that some gcc version would ignore it. I picked 16 to
> have same alignment as malloc does as 16 is max granularity of malloc.

malloc granularity can be as low as 2 (on m68k) without impacting C
conformance, and an interposed malloc implementation might provide
just that.

On most 32-bit platforms, glibc's own malloc provides only 8-byte
alignment.


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