Re: RFA: Various Windows (mingw32) additions, mostly relating to select or serial ports

Daniel Jacobowitz
2006-02-06T23:17:30Z

On Tue, Feb 07, 2006 at 12:01:43AM +0100, Mark Kettenis wrote:
> > Date: Mon, 6 Feb 2006 16:02:38 -0500
> > From: Daniel Jacobowitz <drow@false.org>
> >
> > On Fri, Feb 03, 2006 at 05:05:29PM -0500, Daniel Jacobowitz wrote:
> > > Fixes, all for a mingw32-hosted GDB:
> >
> > Here is a revised version, in which the Windows select magic does not
> > live in event-loop.c, and including the NEWS entry. I haven't changed
> > the pipe polling code; thanks to Ian for his suggestions, but I'm
> > not sufficiently sure they're workable.
> >
> > Are there any bits of this patch that strike you as too ugly or in the
> > wrong place?
>
> Hmm, can't mingw_select() just be called select()? That'd remove much
> of the ugliness.

No, it can't. Two reasons. One is the same reason I mentioned for
strerror: with __attribute__((dllimport)) in the headers, GCC will
generate a load from the import table at call sites, and overriding the
function won't work. MinGW doesn't use this today, if compiling with
GCC, but from the bits in the header files, it looks like they either
did in the past or want to in the future. And I think they do use the
equivalent when compiling with MSVC. No, I haven't tried building
GDB with MSVC.

Another reason is that I don't want to intercept all calls to select.
First of all, because select() is a useful function on Windows (works
on sockets only, but does work there) and it would be a valid way
to implement mingw_select for sockets - I nearly did that. And second
because we call select, the socket version, explicitly from ser-tcp.c
before the connection and associated serial device are completely set
up.

If I could get around #1, I would look into handling #2, but it seems
likely to be more confusing than helpful, to me.

It wouldn't get rid of too much of the ugliness either, I'm afraid :-(
For instance you'd still need gdb_select.h; if you want fd_set on
Windows, you need <windows.h> or <winsock2.h>. No <sys/select.h> to be
found.

--
Daniel Jacobowitz
CodeSourcery