diff options
author | Paolo Carlini <pcarlini@unitus.it> | 2003-07-14 20:23:12 +0200 |
---|---|---|
committer | Paolo Carlini <paolo@gcc.gnu.org> | 2003-07-14 18:23:12 +0000 |
commit | bda243ec50619e4b80e35a8c77a9ebc44647ca38 (patch) | |
tree | 11c82ea18a45d7f42a2a512635da67b8184d3c7a /libstdc++-v3/config | |
parent | 19948e32a8be1a439f58c2d34a7f0b03ec03b85c (diff) | |
download | gcc-bda243ec50619e4b80e35a8c77a9ebc44647ca38.zip gcc-bda243ec50619e4b80e35a8c77a9ebc44647ca38.tar.gz gcc-bda243ec50619e4b80e35a8c77a9ebc44647ca38.tar.bz2 |
Nathan C.
2003-07-14 Paolo Carlini <pcarlini@unitus.it>
Nathan C. Myers <ncm-nospam@cantrip.org>
PR libstdc++/11378
* include/std/std_fstream.h (xsputn): Declare only.
* include/bits/fstream.tcc (xsputn): Define, optimize for the
always_noconv() case: when __n is sufficiently large flush
the buffer and issue a direct write, if possible combining the
two with writev in __basic_file<>::xsputn_2.
* config/io/basic_file_stdio.h (__basic_file<>::xsputn_2):
New, declare.
* config/io/basic_file_stdio.cc (__basic_file<>::xsputn_2):
Define.
* acinclude.m4 (GLIBCXX_CHECK_WRITE): New macro, checking for
the availability of writev in <sys/uio.h>.
* configure.in: Call here.
* acconfig.h: Add undef for the corresponding symbol.
* aclocal.m4: Regenerate.
* configure: Regenerate.
* config.h.in: Regenerate.
* testsuite/27_io/basic_filebuf/setbuf/char/3.cc: Tweak.
* include/std/std_fstream.h (sync): Constify a variable.
Co-Authored-By: Nathan C. Myers <ncm-nospam@cantrip.org>
From-SVN: r69341
Diffstat (limited to 'libstdc++-v3/config')
-rw-r--r-- | libstdc++-v3/config/io/basic_file_stdio.cc | 38 | ||||
-rw-r--r-- | libstdc++-v3/config/io/basic_file_stdio.h | 4 |
2 files changed, 42 insertions, 0 deletions
diff --git a/libstdc++-v3/config/io/basic_file_stdio.cc b/libstdc++-v3/config/io/basic_file_stdio.cc index 2c099d3..5a3921c 100644 --- a/libstdc++-v3/config/io/basic_file_stdio.cc +++ b/libstdc++-v3/config/io/basic_file_stdio.cc @@ -50,6 +50,10 @@ #include <poll.h> #endif +#ifdef _GLIBCXX_HAVE_SYS_UIO_H +#include <sys/uio.h> +#endif + #if defined(_GLIBCXX_HAVE_S_ISREG) || defined(_GLIBCXX_HAVE_S_IFREG) # include <sys/stat.h> # ifdef _GLIBCXX_HAVE_S_ISREG @@ -225,6 +229,40 @@ namespace std return __ret; } + streamsize + __basic_file<char>::xsputn_2(const char* __s1, streamsize __n1, + const char* __s2, streamsize __n2) + { + streamsize __ret = 0; +#ifdef _GLIBCXX_HAVE_WRITEV + struct iovec __iov[2]; + __iov[0].iov_base = const_cast<char*>(__s1); + __iov[0].iov_len = __n1; + __iov[1].iov_base = const_cast<char*>(__s2); + __iov[1].iov_len = __n2; + + do + __ret = writev(this->fd(), __iov, 2); + while (__ret == -1L && errno == EINTR); +#else + if (__n1) + do + __ret = write(this->fd(), __s1, __n1); + while (__ret == -1L && errno == EINTR); + + if (__ret == __n1) + { + do + __ret = write(this->fd(), __s2, __n2); + while (__ret == -1L && errno == EINTR); + + if (__ret != -1L) + __ret += __n1; + } +#endif + return __ret; + } + streampos __basic_file<char>::seekoff(streamoff __off, ios_base::seekdir __way, ios_base::openmode /*__mode*/) diff --git a/libstdc++-v3/config/io/basic_file_stdio.h b/libstdc++-v3/config/io/basic_file_stdio.h index 7c0ffbf..90721bb 100644 --- a/libstdc++-v3/config/io/basic_file_stdio.h +++ b/libstdc++-v3/config/io/basic_file_stdio.h @@ -97,6 +97,10 @@ namespace std xsputn(const char* __s, streamsize __n); streamsize + xsputn_2(const char* __s1, streamsize __n1, + const char* __s2, streamsize __n2); + + streamsize xsgetn(char* __s, streamsize __n); streampos |