* Carlos O'Donell: >> Yes, and for the warning to go away, GCC's MALLOC_ABI_ALIGNMENT needs >> to be increased as well, I think. > > This is not required.
Strictly speaking, that's true. > The __attribute__((__aligned__(16))); is not required for pthread locks > to work correctly, it is simply there to ensure structure padding and > layout matches the pre-NPTL ABI to ensure we don't break ABI. > > In the original Linuxthreads code there was indeed a singular lock word > that needed 16-byte alignment because the hppa 'load and clear word' > atomic operation needed that alignment. > > In NPTL the alignment restrictions are lifted and we use a light-weight > kernel helper (like ARM and m68k) which does compare-and-swap atomically > using kernel-side locks (synchronized with futex operations in the > kernel). > > So the alignment is only needed for structure layout. > > Malloc can return word aligned memory for a pthread_mutex_t and it would > work just fine. There is a slight risk that subsequent members will not sufficient alignment if such an alignment was requested explicitly by the programmer. > The broader question is: How do we get rid of the warning? We could add a “please align inside struct, but do not increase the top-most struct alignment” feature to GCC if it does not have one yet. But I don't think it's worth this effort to do this just for HPPA. We should bump MALLOC_ABI_ALIGNMENT and max_align_t and be done with it. I don't see anything else worth doing which also gets rid of the warning. It's also fairly simple conceptually and carries less risk of breaking in unexpected ways later.