[PATCH] libio: Add small optimization on fmemopen

Ondřej Bílka neleai@seznam.cz
Fri Sep 23 05:17:00 GMT 2016


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?



More information about the Libc-alpha mailing list