Re: [PATCH]: fix poll module under win32.

2007-01-22 Thread Paolo Bonzini

Applied, thanks.

Paolo




[PATCH]: fix poll module under win32.

2007-01-18 Thread Yoann Vandoorselaere
Hi,

The poll module fail under Win32 because of the check for FD_SETSIZE.
Windows use a linear array of sockets (of size FD_SETSIZE). The
descriptor value is not used to address the array.

Attached is a patch that fixe this issue.

Regards,

-- 
Yoann Vandoorselaere | Responsable RD / CTO | PreludeIDS Technologies
Tel: +33 (0)8 70 70 21 58  Fax: +33(0)4 78 42 21 58
http://www.prelude-ids.com
Index: lib/poll.c
===
RCS file: /cvsroot/gnulib/gnulib/lib/poll.c,v
retrieving revision 1.6
diff -u -r1.6 poll.c
--- lib/poll.c	3 Jan 2007 10:51:19 -	1.6
+++ lib/poll.c	18 Jan 2007 09:30:59 -
@@ -133,11 +133,17 @@
 			   | POLLWRNORM | POLLWRBAND)))
 	{
 	  maxfd = pfd[i].fd;
+	  /*
+	   * Windows use a linear array of sockets (of size FD_SETSIZE). The
+	   * descriptor value is not used to address the array.
+	   */ 
+#if !((defined _WIN32 || defined __WIN32__)  !defined __CYGWIN__)
 	  if (maxfd  FD_SETSIZE)
 	{
 	  errno = EOVERFLOW;
 	  return -1;
 	}
+#endif
 	}
 }
 


[PATCH]: Fix poll module under Win32

2007-01-16 Thread Yoann Vandoorselaere
Hi,

Attached are two small patch fixing poll module compilation under MinGW:

- gnulib-poll-depend.diff:
Add a dependencies on the sys_select module, fixing inclusion error
under MinGW.

- gnulib-sys_socket-error.diff: 
Under MinGW, map error code required by the poll module (namely
ESHUTDOWN, ECONNRESET, ECONNABORTED, ENETRESET, ENOTCONN), plus some
other useful error code.


Regards,

-- 
Yoann Vandoorselaere | Responsable RD / CTO | PreludeIDS Technologies
Tel: +33 (0)8 70 70 21 58  Fax: +33(0)4 78 42 21 58
http://www.prelude-ids.com
Index: modules/poll
===
RCS file: /cvsroot/gnulib/gnulib/modules/poll,v
retrieving revision 1.13
diff -u -r1.13 poll
--- modules/poll	13 Oct 2006 12:40:23 -	1.13
+++ modules/poll	16 Jan 2007 10:06:42 -
@@ -7,6 +7,7 @@
 m4/poll.m4
 
 Depends-on:
+sys_select
 
 configure.ac:
 gl_FUNC_POLL
Index: lib/socket_.h
===
RCS file: /cvsroot/gnulib/gnulib/lib/socket_.h,v
retrieving revision 1.7
diff -u -r1.7 socket_.h
--- lib/socket_.h	21 Jun 2006 21:21:42 -	1.7
+++ lib/socket_.h	16 Jan 2007 10:07:09 -
@@ -57,4 +57,14 @@
 # define SHUT_RDWR SD_BOTH
 #endif
 
+#if defined _WIN32 || defined __WIN32__
+# define ENOTSOCKWSAENOTSOCK
+# define EADDRINUSE  WSAEADDRINUSE
+# define ENETRESET   WSAENETRESET
+# define ECONNABORTEDWSAECONNABORTED
+# define ECONNRESET  WSAECONNRESET
+# define ENOTCONNWSAENOTCONN
+# define ESHUTDOWN   WSAESHUTDOWN
+#endif
+
 #endif /* _SYS_SOCKET_H */


Re: [PATCH]: Fix poll module under Win32

2007-01-16 Thread Bruno Haible
Yoann Vandoorselaere wrote:
 - gnulib-poll-depend.diff:
 Add a dependencies on the sys_select module, fixing inclusion error
 under MinGW.

Looks OK.

 - gnulib-sys_socket-error.diff: 
 Under MinGW, map error code required by the poll module (namely
 ESHUTDOWN, ECONNRESET, ECONNABORTED, ENETRESET, ENOTCONN), plus some
 other useful error code.

The conditional should be
  #if (defined _WIN32 || defined __WIN32__)  !defined __CYGWIN__
rather than
  #if defined _WIN32 || defined __WIN32__
because the users of sys/socket.h use functions which, under Cygwin,
come from cygwin.dll, rather than from the native Woe32 DLLs.

Background: On Cygwin, a user can choose (through a gcc command line option)
to define _WIN32 in order to indicate that he wants to use native Woe32
APIs in addition to the cygwin.dll APIs that emulate POSIX. Therefore in
source code which uses Woe32 API functions, we use
  #if defined _WIN32 || defined __WIN32__
But to distinguish API that operates differently under Mingw than under
Unix (including Cygwin), we use
  #if (defined _WIN32 || defined __WIN32__)  !defined __CYGWIN__

Bruno





Re: [PATCH]: Fix poll module under Win32

2007-01-16 Thread Yoann Vandoorselaere
Le mardi 16 janvier 2007 à 12:44 +0100, Bruno Haible a écrit :
 Yoann Vandoorselaere wrote:
  - gnulib-sys_socket-error.diff: 
  Under MinGW, map error code required by the poll module (namely
  ESHUTDOWN, ECONNRESET, ECONNABORTED, ENETRESET, ENOTCONN), plus some
  other useful error code.
 
 The conditional should be
   #if (defined _WIN32 || defined __WIN32__)  !defined __CYGWIN__
 rather than
   #if defined _WIN32 || defined __WIN32__
 because the users of sys/socket.h use functions which, under Cygwin,
 come from cygwin.dll, rather than from the native Woe32 DLLs.

[...]

Thanks for letting me know, here is an updated patch.


-- 
Yoann Vandoorselaere | Responsable RD / CTO | PreludeIDS Technologies
Tel: +33 (0)8 70 70 21 58  Fax: +33(0)4 78 42 21 58
http://www.prelude-ids.com
Index: lib/socket_.h
===
RCS file: /cvsroot/gnulib/gnulib/lib/socket_.h,v
retrieving revision 1.7
diff -u -p -r1.7 socket_.h
--- lib/socket_.h	21 Jun 2006 21:21:42 -	1.7
+++ lib/socket_.h	16 Jan 2007 12:21:51 -
@@ -57,4 +57,14 @@
 # define SHUT_RDWR SD_BOTH
 #endif
 
+#if (defined _WIN32 || defined __WIN32__)  !defined __CYGWIN__
+# define ENOTSOCKWSAENOTSOCK
+# define EADDRINUSE  WSAEADDRINUSE
+# define ENETRESET   WSAENETRESET
+# define ECONNABORTEDWSAECONNABORTED
+# define ECONNRESET  WSAECONNRESET
+# define ENOTCONNWSAENOTCONN
+# define ESHUTDOWN   WSAESHUTDOWN
+#endif
+
 #endif /* _SYS_SOCKET_H */