[PATCH 2/3] ungetc: Guarantee single char pushback
Siddhesh Poyarekar
siddhesh@sourceware.org
Fri Nov 29 12:20:11 GMT 2024
On 2024-11-29 07:15, Maciej W. Rozycki wrote:
> On Fri, 29 Nov 2024, Florian Weimer wrote:
>
>>> The structure is fully packed and there's no padding in the legacy part
>>> I'm afraid, and I guess it's the case for the majority of 32-bit targets,
>>> which don't imply alignment beyond 4 bytes for pointers. Have I missed
>>> anything?
>>
>> No, you are right. So the extension area has to be used. I think we
>> should fail ungetc if the malloc call fails and the extension area is
>> unavailable, instead of resorting to heroic bit-stuffing.
>
> 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.
Sid
More information about the Libc-alpha
mailing list