This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH] libio: Add small optimization on fmemopen
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);
clen += _Alignof (fmemopen_cookie_t) - 1;