[PATCH 2/3] ungetc: Guarantee single char pushback

Maciej W. Rozycki macro@redhat.com
Fri Nov 29 19:05:53 GMT 2024


On Fri, 29 Nov 2024, Siddhesh Poyarekar wrote:

> >   What's wrong with reusing flags2?  We have 25 contiguous bits left and at
> > the rate we've been consuming them here we'll need another 40 years before
> > we need the last 8.  Besides, we've released a couple already and isn't it
> > internal stuff anyway we can rearrange on a whim?
> 
> I need to stuff a whole char in there, for which we'll have to put flags2 and
> the buf into a union { int flags2; char shortbuf[sizeof (int)];} and then take
> care only to use the bottom char in that buffer. That seems like too much
> cruft to support legacy uses IMO.

 Couldn't we just redefine flags2 as short and have two extra char members 
for free?  Is there any ABI out there that packs an int differently from a 
short and a pair of char members provided the struct requires alignment of 
at least 4 bytes already and there's no padding for the int?

  Maciej



More information about the Libc-alpha mailing list