Talk:cpp/io/basic streambuf/sputn
From cppreference.com
< Talk:cpp | io | basic streambuf
[edit] What are "some implementations"?
When certain conditions are met, the MSVC STL implementation of basic_filebuf::xsputn calls fwrite, and the libstdc++ implementation calls writev (via the __basic_file::xsputn_2 internal function) on some platforms. But write is called by the libstdc++ implementation even if these conditions are not met.
So is there any implementation actually performing "simply passes the pointer to the POSIX write() system call"? Or we should change the notes to reflect the MSVC/libstdc++ implementations? --Fruderica (talk) 04:59, 14 February 2021 (PST)
- the point is not which syscall is called, but whether buffering is short-circuited. With a 10k buffer, I see gcc calls writev(3, [{iov_base=NULL, iov_len=0}, {iov_base="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=10240}], but writing one char at a time gcc makes two write calls (8192 bytes and 2048 bytes). I guess it could be phrased better. --Cubbi (talk) 11:19, 15 February 2021 (PST)