This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Do not break buffers in fvwrite for unbuffered files


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/21/2013 01:54 PM, Corinna Vinschen wrote:
> On Oct 21 10:36, Federico wrote:
>> -	  w = fp->_write (ptr, fp->_cookie, p, MIN (len, BUFSIZ)); +
>> w = fp->_write (ptr, fp->_cookie, p, len);
> 
> As noted in my other reply, len is size_t but the parameter to
> _write may be int, even after my _READ_WRITE_BUFSIZE_TYPE patch has
> been applied.
> 
> Therefore the type size difference still has to be accounted for. 
> Maybe something like this is sufficient:
> 
> w = fp->_write (ptr, fp->_cookie, p, MIN (len, MAX_INT));
> 
> ???
> 
> 
> Thanks, Corinna
> 

First of all I'm happy to know that my profiling work is useful to
other targets as well.
Thanks for the patch review, didn't notice the type problem as my
target still uses int for file offsets.
Your solution using MAX_INT is more than satisfactory, as it would
only split *really* large buffers in 2GByte chunks. In my target
(microcontrollers with limited RAM amount), this will simply never
happen, while on other targets the overhead of one syscall every
2GByte is probably of no concern.

I'm wondering if it makes sense to avoid splitting writes (and reads)
also for buffered files. glibc appears to do it, and outside of the
RAM constrained embedded world few programmers care about adding a
setbuf(f,NULL); if they are going to read/write in large chunks.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSZRu7AAoJECkLFtN5Xr9fW44IAIr84nkAnKyWtN3ks2Y3Hqk+
Qf9BnJFe9ki2HyZqliWaZgBJ/GWQiq05IvqjZ6dqtj/vcpr1So3QnmYfyjlCfY4C
G3dMLbdCl4h0Fs4+1xTCIBYcSVzCN6TgID4Wh6V7HXUS9SlpeyMvU7P0p7enrsl/
59b9psN2H3e4isnGyvrcx3zGXYT3DJyRvj0kF21iSIK5Js7iKraqJ1KbNtbU33pH
/W1esLihgc1j5e3Hpd77/iWGPGRwvAK6ILb9M0kdotiHN+kOgeH+fOS0m9mgLYlr
A1BhE8AyjJ1d+u5xMozVQzy1rMZOUXBU3z7OfSHcTW/5P5jPzMq0Ihi1uLbb6G4=
=C5yU
-----END PGP SIGNATURE-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]