diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-02-12 00:05:35 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-02-12 00:05:35 +0000 |
commit | 227f9e564c35d3f62088fac05102f83e709869dd (patch) | |
tree | ae25e5d86ff8f84df1b0806c734abe00d461a9ef /libstdc++-v3/config | |
parent | 51770c05b636885ee2959f48d43d02fd184686a6 (diff) | |
download | gcc-227f9e564c35d3f62088fac05102f83e709869dd.tar.gz |
2004-02-11 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/13731 (first part: write)
* config/io/basic_file_stdio.h (__basic_file<char>::xwrite):
New, declare.
* config/io/basic_file_stdio.cc (__basic_file<char>::xwrite):
Define it: a wrapper around write() handling partial write.
(__basic_file<char>::xsputn): Use it.
(__basic_file<char>::xsputn_2): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@77680 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/config')
-rw-r--r-- | libstdc++-v3/config/io/basic_file_stdio.cc | 41 | ||||
-rw-r--r-- | libstdc++-v3/config/io/basic_file_stdio.h | 3 |
2 files changed, 25 insertions, 19 deletions
diff --git a/libstdc++-v3/config/io/basic_file_stdio.cc b/libstdc++-v3/config/io/basic_file_stdio.cc index 8cba0db4817..1419fdedf4b 100644 --- a/libstdc++-v3/config/io/basic_file_stdio.cc +++ b/libstdc++-v3/config/io/basic_file_stdio.cc @@ -200,16 +200,28 @@ namespace std while (__ret == -1L && errno == EINTR); return __ret; } - - streamsize - __basic_file<char>::xsputn(const char* __s, streamsize __n) + + // Wrapper handling partial write. + streamsize + __basic_file<char>::xwrite(const char* __s, streamsize __n) { - streamsize __ret; - do - __ret = write(this->fd(), __s, __n); - while (__ret == -1L && errno == EINTR); - return __ret; + streamsize __nleft = __n; + while (__nleft > 0) + { + const streamsize __ret = write(this->fd(), __s, __nleft); + if (__ret == -1L && errno == EINTR) + continue; + else if (__ret == -1L) + break; + __nleft -= __ret; + __s += __ret; + } + return __n - __nleft; } + + streamsize + __basic_file<char>::xsputn(const char* __s, streamsize __n) + { return __basic_file<char>::xwrite(__s, __n); } streamsize __basic_file<char>::xsputn_2(const char* __s1, streamsize __n1, @@ -228,19 +240,10 @@ namespace std while (__ret == -1L && errno == EINTR); #else if (__n1) - do - __ret = write(this->fd(), __s1, __n1); - while (__ret == -1L && errno == EINTR); + __ret = __basic_file<char>::xwrite(__s1, __n1); if (__ret == __n1) - { - do - __ret = write(this->fd(), __s2, __n2); - while (__ret == -1L && errno == EINTR); - - if (__ret != -1L) - __ret += __n1; - } + __ret += __basic_file<char>::xwrite(__s2, __n2); #endif return __ret; } diff --git a/libstdc++-v3/config/io/basic_file_stdio.h b/libstdc++-v3/config/io/basic_file_stdio.h index 57ff4326e6b..9c0ccfd1bad 100644 --- a/libstdc++-v3/config/io/basic_file_stdio.h +++ b/libstdc++-v3/config/io/basic_file_stdio.h @@ -84,6 +84,9 @@ namespace std ~__basic_file(); streamsize + xwrite(const char* __s, streamsize __n); + + streamsize xsputn(const char* __s, streamsize __n); streamsize |