This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PR libstdc++/6746 and non-POSIX stdio
- From: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- To: libstdc++-cvs at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 15 Nov 2002 14:22:45 +1100 (EST)
- Subject: PR libstdc++/6746 and non-POSIX stdio
The use of O_NONBLOCKING and fcntl in this patch breaks mingw32 builds, because
C stdio implementation doesn't know about non-blocking mode
2002-11-11 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/6746
* include/bits/fstream.tcc (filebuf::open): Set input pointers.
* config/io/basic_file_stdio.cc (__basic_file::_M_open_mode): Set
__p_mode as well.
(__basic_file::open): Set to non-block for input.
The following patch fixes on i386-pc-mingw32
In particular the tests in testsuite/27_io/istream_unformatted.cc still pass.
(The new tests also pass on mingw32 with libstdc++ built prior to Benjamin's
patch)
2002-11-15 Danny Smith <dannysmith@users.sourceforge.net>
* config/io/basic_file_stdio.cc (__basic_file::_M_open_mode):
Don't use O_NONBLOCKING if it is not defined.
(__basic_file::open): Don't use fcntl either.
Index: basic_file_stdio.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/config/io/basic_file_stdio.cc,v
retrieving revision 1.6
diff -c -3 -p -r1.6 basic_file_stdio.cc
*** basic_file_stdio.cc 11 Nov 2002 23:18:04 -0000 1.6
--- basic_file_stdio.cc 15 Nov 2002 03:08:16 -0000
*************** namespace std
*** 74,80 ****
--- 74,84 ----
if (__testi && !__testo && !__testt && !__testa)
{
strcpy(__c_mode, "r");
+ #if defined (O_NONBLOCK)
__p_mode |= O_RDONLY | O_NONBLOCK;
+ #else
+ __p_mode |= O_RDONLY;
+ #endif
}
if (__testi && __testo && !__testt && !__testa)
{
*************** namespace std
*** 151,159 ****
--- 155,165 ----
{
_M_cfile_created = true;
+ #if defined (F_SETFL) && defined (O_NONBLOCK)
// Set input to nonblocking for fifos.
if (__mode & ios_base::in)
fcntl(this->fd(), F_SETFL, O_NONBLOCK);
+ #endif
__ret = this;
}
http://careers.yahoo.com.au - Yahoo! Careers
- 1,000's of jobs waiting online for you!