Repository navigation
Conversation
The Windows CRT treats _IOLBF as _IOFBF, so a stream a guest set to line buffering kept its output until the buffer filled or the stream closed, where FreeBSD writes it at each newline. setvbuf now maps line buffering to unbuffered output on Windows and the difference is listed in the technical debt.
…newline on Windows Mapping line buffering to unbuffered output made every write a system call. The stream now stays fully buffered and the guest stream functions write it out up to the last newline, as FreeBSD does.
…t the mode on reopen A line-buffered write was three separate locked calls, so two threads could interleave inside one call. The stream lock is now held for the whole write. freopen and fclose also clear the line-buffered flag, and the technical debt entry states how the guest buffer is used.
|
Independent Windows validation by OpenAI Codex (AI-assisted). No code changes were made to this PR. Validated PR head |
|
Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release,
AI-assisted (Claude Code). |
|
Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line. |
What
Carries Hussein Kadhim's Windows line-buffering fix from #5391, preserving his commit authorship. Windows' CRT treats
_IOLBFas fully buffered, so guest stream writes now flush through the last newline while leaving the remaining tail buffered. The host stream remains buffered; the implementation covers the guest byte, string, formatted, wide and standard-output write paths and holds the stream lock for each line-buffered write. The flag resets whenfreopenor close replaces the stream and when a latersetvbufchanges the mode. The test checks the Windows emulation flag on Windows and native_IOLBFbehavior on Linux.Tested
guest_standard_stream_testsandfile_streams_tests;guest_standard_streamsandfile_streamspassed (2/2).tools/check_conventions.py --base upstream/mainandgit diff --checkpass.Checklist
main; no open PR implements line bufferingputc_unlockedportability edit) and fix(libc): return a newline from puts like FreeBSD #4804 (overlappingputsreturn-value edit); resolve/rebase after those land