http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57350
--- Comment #4 from David Krauss <potswa at mac dot com> ---
Hmm, I recall preparing to submit a patch but not being able to decide which
header to modify.
Here's the aforementioned MIT-licensed code. The MIT license only requires
attribution which is satisfied by the changelog; anyway I don't care. I am
already a GNU contributor with FSF waiver back in 2009.
This code should probably be reviewed. I wrote it a long time ago and seldom
used it. Cannot recall whether it was intended to be 100% compliant.
inline void *align( std::size_t alignment, std::size_t size, void *&ptr,
std::size_t &space ) {
auto pn = reinterpret_cast< std::size_t >( ptr );
auto aligned = ( pn + alignment - 1 ) & - alignment;
auto new_space = space - ( aligned - pn );
if ( new_space < size ) return nullptr;
space = new_space;
return ptr = reinterpret_cast< void * >( aligned );
}