[3/3] msvcrt: Implement 4k block flushing behavior.
Piotr Caban
piotr.caban at gmail.com
Sun Jun 1 04:38:40 CDT 2014
On 05/31/14 01:00, Grazvydas Ignotas wrote:
> + } else if(wrcnt >= MSVCRT_WRITE_BLOCK_SIZE) {
> + if(msvcrt_set_write_direction(file) != 0)
> + break;
> +
> + if(file->_bufsiz && file->_ptr != file->_base)
> + if(msvcrt_flush_buffer(file) == MSVCRT_EOF)
> + break;
> +
> + if(MSVCRT__write(file->_file, ptr, MSVCRT_WRITE_BLOCK_SIZE) <= 0) {
> + file->_flag |= MSVCRT__IOERR;
> + break;
> + }
> + written += MSVCRT_WRITE_BLOCK_SIZE;
> + wrcnt -= MSVCRT_WRITE_BLOCK_SIZE;
> + ptr = (const char*)ptr + MSVCRT_WRITE_BLOCK_SIZE;
This doesn't look right for me. It doesn't make sense to have some
special size blocks written in different way.
I think this is caused by 2 differences in native and wine's
implementation of fwrite:
- if you check file->_bufsiz value on windows it's set to 4096 (on
wine it's 512), this is probably causing the flash to be done when 4096
bytes are written
- probably there's some kind of optimization that writes integral
number of buffers directly to file
- I was not checking it but maybe native flushes the output when
buffer is full, wine will exit fwrite with full buffer in this case
I've also seen that _bufsiz is set to 0 on wine if buffer was not yet
allocated. On windows it's value is 4096 just after opening the file.
Cheers,
Piotr
More information about the wine-devel
mailing list