This is the mail archive of the
mailing list for the libstdc++ project.
Re: [RFC/patch] New iteration at fixing 9533
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Sun, 23 Mar 2003 09:41:35 +0100
- Subject: Re: [RFC/patch] New iteration at fixing 9533
- References: <firstname.lastname@example.org>
Danny Smith wrote:
+#include <poll.h>Ok, will add an autoconf test for it in the next iteration.
+ // Cheap test.
+ struct pollfd __pfd;
+ __pfd.fd = this->fd();
+ __pfd.events = POLLIN;
+ if (poll(__pfd, 1, 0) <= 0)
+ return 0;
will break mingw32 (and possibly other targets) which doesn't have poll.h
Therefore, it would be ok with you if I keep the ioctl() code which then
will be actually enabled on mingw
Following doesn't cause problems on mingw32 _unless_ we include winsock.h or
+ // Pipes and sockets.
+ int __num = 0;
+ int __r = ioctl(this->fd(), FIONREAD, &__num);
+ if (!__r && __num >= 0)
+ return __num;
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.
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.