diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2013-03-27 09:38:39 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2013-03-27 09:38:39 +0000 |
commit | 409c27f83478e2962c446be23e104a97b3f5f2e0 (patch) | |
tree | 4548f42d093397fb049fdfae40f28968d59499ab /newlib/libc/stdio/fwrite.c | |
parent | 1ebc8da242a1e8dd7707f2bcc51c22d4e1e64990 (diff) | |
download | cygnal-409c27f83478e2962c446be23e104a97b3f5f2e0.tar.gz cygnal-409c27f83478e2962c446be23e104a97b3f5f2e0.tar.bz2 cygnal-409c27f83478e2962c446be23e104a97b3f5f2e0.zip |
* acconfig.h (_FVWRITE_IN_STREAMIO): Undefine.
* newlib.hin (_FVWRITE_IN_STREAMIO): Undefine.
* configure.in (--disable-newlib-fvwrite-in-streamio): New option.
* configure: Regenerated.
* libc/stdio/fputs.c (_fputs_r): Use _FVWRITE_IN_STREAMIO to
control __sfvwrite_r. Add alternative implementation.
* libc/stdio/fputws.c (_fputws_r): Ditto.
* libc/stdio/fwrite.c (_fwrite_r): Ditto.
* libc/stdio/puts.c (_puts_r): Ditto.
* libc/stdio/vfprintf.c (__ssputs_r, __sfputs_r): New function.
(_VFPRINTF_R): Use _FVWRITE_IN_STREAMIO to control vector buffer.
(__SPRINT): Use _FVWRITE_IN_STREAMIO to control macro definition.
* libc/stdio/vfwprintf.c (_VFWPRINTF_R): Use _FVWRITE_IN_STREAMIO
to control vector buffer.
Diffstat (limited to 'newlib/libc/stdio/fwrite.c')
-rw-r--r-- | newlib/libc/stdio/fwrite.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/newlib/libc/stdio/fwrite.c b/newlib/libc/stdio/fwrite.c index dc218050e..595e3ef84 100644 --- a/newlib/libc/stdio/fwrite.c +++ b/newlib/libc/stdio/fwrite.c @@ -103,6 +103,7 @@ _DEFUN(_fwrite_r, (ptr, buf, size, count, fp), FILE * fp) { size_t n; +#ifdef _FVWRITE_IN_STREAMIO struct __suio uio; struct __siov iov; @@ -128,6 +129,30 @@ _DEFUN(_fwrite_r, (ptr, buf, size, count, fp), } _newlib_flockfile_end (fp); return (n - uio.uio_resid) / size; +#else + size_t i = 0; + _CONST char *p = buf; + n = count * size; + CHECK_INIT (ptr, fp); + + _newlib_flockfile_start (fp); + ORIENT (fp, -1); + /* Make sure we can write. */ + if (cantwrite (ptr, fp)) + goto ret; + + while (i < n) + { + if (__sputc_r (ptr, p[i], fp) == EOF) + break; + + i++; + } + +ret: + _newlib_flockfile_end (fp); + return i / size; +#endif } #ifndef _REENT_ONLY |