mingw compat note

Marc Lehmann schmorp at schmorp.de
Mon Nov 17 04:31:27 CET 2008


On Thu, Nov 13, 2008 at 02:05:20PM -0700, Roger Pack <rogerpack2005 at gmail.com> wrote:
> Appears that for windows [at least currently] you don't need to
> specify  EV_SELECT_IS_WINSOCKET 1 since it's auto-set is that right?

Hrmm.. it is defaulted to some hopefully sane value - if you specify it,
that's what gets used.

Obviously, using a fixed config for when you know it is better than to
rely on libev's magic autodetection.

> #include <ruby.h>
> 
> #include <ev.h>
> #include "ev.c"
> 
> /* now do some ruby stuff that uses libev */
> 
> caused conflict as some #define macros in ruby.h overwrote vital
> components of libev [ex: select -> rb_w32_select] which was messing it
> up.

That might actually be the way to go - imagine that ruby does it's own file
descriptor stuff, and these file descriptors map into ruby's select
emulation, then it's fine, but you don't use winsocket seletc then, but a
normal "unix" one.

I have no clue whether ruby does that, but it is common - perl and python
very much to the same thing. The perl interface for libev does this, for
example:

   #define EV_SELECT_IS_WINSOCKET 0
   #ifdef _WIN32
   # define EV_SELECT_USE_FD_SET 0
   # define NFDBITS PERL_NFDBITS
   # define fd_mask Perl_fd_mask
   #endif

To make libev use perl's own select, and thus stay compatible to it's idea of
file descriptors.

Libev, by default, is compatible to the microsoft runtime. If programs change
that and do their own file descriptor thing, then you need to find out what
that is and configure libev accordingly.

The problem is that windows rather sucks in that area, so there are good
reasons to roll your own. But that also emans that libev cannot know when it
conflicts.

As it is, libev is very variable and should be able to support whatever
ruby itself is doing. But I have no clue what that is. You would need to find
out what ruby does first.

Or better yet, use a sane platform and avoid windows like the plague - it
is an unstable and low-performance platform, with no sign of ever changing
for the better.

> I think that separating the ev stuff and the ruby stuff to their own
> .o files might help it.

Or it might completely break it.

> re: FD_SETSIZE as a quick and easy fix for win32 more
> descriptors--true, I haven't had too much success with it using
> msvcrt6 though it should work.  I assume libev does nothing when you
> pass it more file descriptors than FD_SETSIZE?

It will probably start corrupting random memory locations. There is no
standard that says that FD_SETSIZE even exists, so we can't know the
maximum number of file descriptors supported.

-- 
                The choice of a       Deliantra, the free code+content MORPG
      -----==-     _GNU_              http://www.deliantra.net
      ----==-- _       generation
      ---==---(_)__  __ ____  __      Marc Lehmann
      --==---/ / _ \/ // /\ \/ /      pcg at goof.com
      -=====/_/_//_/\_,_/ /_/\_\



More information about the libev mailing list