[PATCH 2/2] Use C11 _Alignas on scratch_buffer internal buffer

Paul Eggert eggert@cs.ucla.edu
Mon Sep 18 17:24:00 GMT 2017


Florian Weimer wrote:
>> Sorry, didn't know that. We could use 1056-byte buffers instead; would that be 
>> the same on all glibc platforms? I'm not sure how important it is that the 
>> byte count be the same everywhere.
> 
> I've chased ghosts due to such buffer size differences.  I'd like to reduce it 
> to the 32/64 difference if possible.

Then Andreas's suggestion is a good way to go. A member like this in struct 
scratch_buffer:

   union { max_align_t __a; char __c[1024]; } __space;

and then use __space.__c everywhere the code currently uses __space.  This will 
make the buffer size 1024 on all platforms where sizeof (max_align_t) <= 1024, 
which should be a safe assumption for all glibc platforms now.



More information about the Libc-alpha mailing list