Mercurial > ecos-v3_0-branch
changeset 1716:71a39e52b020
* src/common/stream.cxx (read): fixed performance problem with
unbuffered reads. Long unbuffered i/o read requests would cause
one roundtrip to the underlying file system for each byte, instead
of a single trip as intended.
| author | jlarmour |
|---|---|
| date | Mon, 16 Aug 2004 14:37:03 +0000 |
| parents | 12255a59b6ef |
| children | fc3e63dcb859 |
| files | packages/language/c/libc/stdio/current/ChangeLog packages/language/c/libc/stdio/current/src/common/stream.cxx |
| diffstat | 2 files changed, 22 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/language/c/libc/stdio/current/ChangeLog +++ b/packages/language/c/libc/stdio/current/ChangeLog @@ -1,3 +1,10 @@ +2004-08-16 Oyvind Harboe <oyvind.harboe@zylin.com> + + * src/common/stream.cxx (read): fixed performance problem with + unbuffered reads. Long unbuffered i/o read requests would cause + one roundtrip to the underlying file system for each byte, instead + of a single trip as intended. + 2004-03-29 Kelvin Lawson <klawson@ad-holdings.co.uk> * src/common/fopen.cxx:
--- a/packages/language/c/libc/stdio/current/src/common/stream.cxx +++ b/packages/language/c/libc/stdio/current/src/common/stream.cxx @@ -324,6 +324,7 @@ Cyg_ErrNo Cyg_StdioStream::read( cyg_uint8 *user_buffer, cyg_ucount32 buffer_length, cyg_ucount32 *bytes_read ) { + Cyg_ErrNo read_err=ENOERR; CYG_ASSERTCLASS( this, "Stream object is not a valid stream!" ); *bytes_read = 0; @@ -387,9 +388,22 @@ Cyg_StdioStream::read( cyg_uint8 *user_b position += *bytes_read; + + // if we are unbuffered, we read as much as we can directly from the + // file system at this point. + // + // unless we do this, we could end up reading byte-by-byte from the filing system + // due to the readbuf_char scheme. + if ((*bytes_read<buffer_length) && !flags.buffering) { + cyg_uint32 len; + len=buffer_length-*bytes_read; + read_err = cyg_stdio_read(my_device, user_buffer + *bytes_read, &len); + *bytes_read+=len; + } + unlock_me(); - return ENOERR; + return read_err; } // read()
