On 10/11/2016 04:04 PM, John David Anglin wrote:
> On 2016-10-11 2:50 PM, Jason Merrill wrote:
>> /* Alignment, in bits, a C conformant malloc implementation has to
>> The HP-UX malloc implementation provides a default alignment of 8
>> This can be increased with mallopt. The glibc implementation also
>> 8-byte alignment. Note that this isn't enough for various POSIX
>> types such
>> as pthread_mutex_t. However, since we no longer need the 16-byte
>> for atomic operations, we ignore the nominal alignment specified
>> for these
>> types. The same is true for long double on 64-bit HP-UX. */
>> If PA malloc doesn't actually provide 16-byte alignment, this change
>> seems problematic; it will mean any type that wants 16-byte alignment
>> will silently get 8-byte alignment instead.
> I agree the situation is something of a mess. On linux, we could bump the
> of malloc to 16-bytes. However, Carlos argued that we don't need to and I
> think doing
> so would be detrimental to performance.
Correct, we do not need a 16-byte alignment at runtime.
> The 16-byte alignment was used originally because the ldcw instruction used
> for atomic
> operations in linux threads needs 16-byte alignment. However, the nptl
> implementation now uses a kernel helper for atomic operations. It only needs
> 4-byte alignment. The largest alignment actually needed is for long double
> (8 bytes).
> However, we can't change the 16-byte alignment without affecting the layout
> of various
Correct, the structure padding needs to continue to be there to match the
> The same is true for long double on HPUX. Originally, it was planned to
> implement it
> in hardware and that would have required 16-byte alignment. It was only
> in software with an 8-byte alignment requirement. Somehow, it ended up with
> 8 and
> 16-byte alignment in the HP 32 and 64-bit compilers, respectively. In both
> cases, malloc
> has 8-byte alignment. It is possible to increase the "grain" size of HP
> malloc to 16 bytes.
> Thus, I don't think the silent reduction to 8-byte alignment matters.
> Without the change,
> we are faced with spurious warnings from new.
I suggested disabling the warnings.
Which is what Jason suggests here:
Though Florian Weimer suggests just bumping malloc to return 16-byte aligned
raising max_align_t, since conceptually that's simple (but will impact
I think the case where a user specifically requests a larger aligment is still
bound to fail if they exceed malloc's aligment. So removing the warning just
hppa where it is today. No warning. Working with existing malloc alignment. But
to warn users of legitimate cases where this might matter?
I still suggest disabling the warning.