[PATCH v6 02/11] stdio-common: Introduce buffers for implementing printf

Florian Weimer fweimer@redhat.com
Sat Dec 17 12:55:59 GMT 2022


* Noah Goldstein:

>> There are two buffers here: the staging buffer, and the (usually larger,
>> but optional) FILE * buffer.  If there is no FILE * buffer (yet), we
>> must use the staging buffer.  But we can instruct printf to write
>> directly to the FILE * buffer if it is there.  Once the buffer is full,
>> we need to use the staging buffer for a bit, but flushing that into the
>> FILE * buffer will most likely make the FILE * buffer available again.

> I guess my point is maybe better to use the staging buffer -> IO buffer
> if there is only minimal room left in the FILE * buffer.

But the libio machinery behind the _IO_sputn call still needs to split
the staging buffer when transfering it into the FILE * buffer, so it may
be more beneficial to write it directly there.

> But thinking more on it, it doesn't really make sense.

Right, I'll leave it as is for now.  If we can fix the input-less flush
case in libio, I think it's more clearly beneficial to write to the
FILE * buffer directly as long it exists.

Thanks,
Florian



More information about the Libc-alpha mailing list