diff mbox

[libstdc++] : PR/43738 - basic_file_stdio.cc uses ioctl on a fd, but not available on mingw32

Message ID AANLkTimj_+uGgVcDRBmbhzMYtpz=6rviqgUO5CyWvQBh@mail.gmail.com
State New
Headers show

Commit Message

Kai Tietz Dec. 2, 2010, 12:34 p.m. UTC
2010/12/2 Paolo Carlini <paolo.carlini@oracle.com>:
> On 12/02/2010 12:32 PM, Kai Tietz wrote:
>> Hello,
>>
>> This patch fixes the described issue (as discussed in the bug-report).
>>
>> ChangeLog
>>
>>         PR libstdc++/43738
>>         * config/io/basic_file_stdio.cc (showmanyc): Special case for
>> mingw targets.
>>
>> Tested for i686-w64-mingw32, x86_64-w64-mingw32, and regression tested for
>> i686-pc-cygwin. Ok for apply?
>>
> Please always CC libstdc++ too when submitting patches for the C++ runtime.
>
> I would suggest instead defining a macro in
> config/os/mingw32/os_defines.h, a _GLIBCXX_NO_IOCTL or something and
> checking that is not defined in showmanyc before checking FIONREAD etc.
> And add a comment in that os_defines.h about the issue, maybe somebody
> will want to work on something better for mingw32 and/or just add an
> autoconf test for ioctl and clean up a bit of this mess.
>
> Paolo.
>
>
>

Paolo,

Fine by me. Here is the updated version.

ChangeLog

        * config/io/basic_file_stdio.cc (showmanyc): Check _GLIBCXX_NO_IOCTL
        before use of ioctl.
        * config/os/mingw32/os_defines.h (_GLIBCXX_NO_IOCTL): New.

Retested. Ok for apply?
Kai

Comments

Paolo Carlini Dec. 2, 2010, 12:37 p.m. UTC | #1
On 12/02/2010 01:34 PM, Kai Tietz wrote:
> Retested. Ok for apply?
Ok, thanks.

Paolo.
Kai Tietz Dec. 2, 2010, 1:15 p.m. UTC | #2
2010/12/2 Paolo Carlini <paolo.carlini@oracle.com>:
> On 12/02/2010 01:34 PM, Kai Tietz wrote:
>> Retested. Ok for apply?
> Ok, thanks.
>
> Paolo.
>

Applied to trunk at revision 167369.

Thanks,
Kai
diff mbox

Patch

Index: gcc/libstdc++-v3/config/io/basic_file_stdio.cc
===================================================================
--- gcc.orig/libstdc++-v3/config/io/basic_file_stdio.cc	2010-02-22 11:48:20.000000000 +0100
+++ gcc/libstdc++-v3/config/io/basic_file_stdio.cc	2010-12-02 13:22:37.132157000 +0100
@@ -334,6 +334,7 @@  _GLIBCXX_BEGIN_NAMESPACE(std)
   streamsize
   __basic_file<char>::showmanyc()
   {
+#ifndef _GLIBCXX_NO_IOCTL
 #ifdef FIONREAD
     // Pipes and sockets.    
 #ifdef _GLIBCXX_FIONREAD_TAKES_OFF_T
@@ -344,7 +345,8 @@  _GLIBCXX_BEGIN_NAMESPACE(std)
     int __r = ioctl(this->fd(), FIONREAD, &__num);
     if (!__r && __num >= 0)
       return __num; 
-#endif    
+#endif
+#endif
 
 #ifdef _GLIBCXX_HAVE_POLL
     // Cheap test.
Index: gcc/libstdc++-v3/config/os/mingw32/os_defines.h
===================================================================
--- gcc.orig/libstdc++-v3/config/os/mingw32/os_defines.h	2009-12-11 14:57:34.000000000 +0100
+++ gcc/libstdc++-v3/config/os/mingw32/os_defines.h	2010-12-02 13:15:19.926233900 +0100
@@ -60,4 +60,9 @@ 
 // See  libstdc++/37522.
 #define _GLIBCXX_HAVE_BROKEN_VSWPRINTF 1
 
+// See libstdc++/43738
+// On native windows targets there is no ioctl function. And the existing
+// ioctlsocket function doesn't work for normal file-descriptors.
+#define _GLIBCXX_NO_IOCTL 1
+
 #endif