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


On Wed, Sep 21, 2016 at 11:43:23AM -0700, Paul Eggert wrote:
> On 09/21/2016 11:26 AM, Adhemerval Zanella wrote:
> >my idea to use this workaround is
> >to avoid possible issues with faulty compilers.
> 
> That's my thought as well. Although we can argue that the C
> standard, GCC, valgrind, etc. are all faulty, possibly the C
> standard etc. won't change (after all, there is a performance
> advantage to GCC's current behavior) and our code would continue to
> be over the edge.
> 
> We could document this more clearly by having a macro
> FLEXMEMBER_NEEDS_ALIGNMENT specifying whether flexible array member
> sizes require alignment. The default could be true to be safe for
> current platforms, and the macro could be false on (future?)
> platforms known to not require aligned allocation of flexible array
> members. Then we could say something like this:
> 
>   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?


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