This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC/patch] New iteration at fixing 9533

Danny Smith wrote:

+#include <poll.h>


+    // Cheap test.
+    struct pollfd __pfd[1];
+    __pfd[0].fd = this->fd();
+    __pfd[0].events = POLLIN;
+    if (poll(__pfd, 1, 0) <= 0)
+      return 0;

will break mingw32 (and possibly other targets) which doesn't have poll.h
or poll().

Ok, will add an autoconf test for it in the next iteration.

Following doesn't cause problems on mingw32 _unless_ we include winsock.h or

+#ifdef FIONREAD
+ // Pipes and sockets. + int __num = 0;
+ int __r = ioctl(this->fd(), FIONREAD, &__num);
+ if (!__r && __num >= 0)
+ return __num; +#endif

mingw does define FIONREAD (in winsock.h) but does not have ioctl.
It does have winsock versions: ioctlsocket (a barebones Berkeley ioctl)
and WSAIoctl which provides functionality similar to ioctl/fcntl.
To be functional these require a call to an initilizer function
WSAStartup, so we can't just #define ioctl ioctlsocket.
I could probably write a _glibcpp_ioctl() wrapper function and add it as a an extra module to libgcc2 for mingw target.

Therefore, it would be ok with you if I keep the ioctl() code which then will be actually enabled on mingw
only after you contribute the wrapper?

Consider that in the current library showmanyc() can only return zero in such cases for pipes, sockets and regular files.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]