In this thread, there was also the proposed patch to use 'socklen_t' instead of 'int' in the prototypes of getsockopt() and setsockopt(). <http://lists.gnu.org/archive/html/bug-gnulib/2008-12/msg00263.html> Paolo approved it, Simon did not object, I had tested it on mingw, and the type 'socklen_t' has the same size as 'int' on mingw. So I'm now applying this patch:
2009-03-01 Bruno Haible <br...@clisp.org> Use socklen_t in the native Windows replacements prototypes. * lib/sys_socket.in.h (rpl_getsockopt, rpl_setsockopt): Use socklen_t instead of 'int'. * lib/getsockopt.c (rpl_getsockopt): Likewise. * lib/setsockopt.c (rpl_setsockopt): Likewise. * modules/getsockopt (Depends-on): Add socklen. * modules/setsockopt (Depends-on): Add socklen. --- lib/getsockopt.c.orig 2009-03-01 20:41:19.000000000 +0100 +++ lib/getsockopt.c 2009-03-01 20:40:42.000000000 +0100 @@ -1,6 +1,6 @@ /* getsockopt.c --- wrappers for Windows getsockopt function - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -35,7 +35,7 @@ #undef getsockopt int -rpl_getsockopt (int fd, int level, int optname, void *optval, int *optlen) +rpl_getsockopt (int fd, int level, int optname, void *optval, socklen_t *optlen) { int r; SOCKET sock = FD_TO_SOCKET (fd); @@ -51,7 +51,7 @@ tv.tv_usec = (milliseconds - 1000 * tv.tv_sec) * 1000; n = sizeof (struct timeval); if (n > *optlen) - n = *optlen; + n = *optlen; memcpy (optval, &tv, n); *optlen = n; } --- lib/setsockopt.c.orig 2009-03-01 20:41:19.000000000 +0100 +++ lib/setsockopt.c 2009-03-01 20:40:46.000000000 +0100 @@ -1,6 +1,6 @@ /* setsockopt.c --- wrappers for Windows setsockopt function - Copyright (C) 2008 Free Software Foundation, Inc. + Copyright (C) 2008-2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -32,7 +32,7 @@ #undef setsockopt int -rpl_setsockopt (int fd, int level, int optname, const void *optval, int optlen) +rpl_setsockopt (int fd, int level, int optname, const void *optval, socklen_t optlen) { int r; SOCKET sock = FD_TO_SOCKET (fd); --- lib/sys_socket.in.h.orig 2009-03-01 20:41:19.000000000 +0100 +++ lib/sys_socket.in.h 2009-03-01 20:40:35.000000000 +0100 @@ -1,6 +1,6 @@ /* Provide a sys/socket header file for systems lacking it (read: MinGW) and for systems where it is incomplete. - Copyright (C) 2005-2008 Free Software Foundation, Inc. + Copyright (C) 2005-2009 Free Software Foundation, Inc. Written by Simon Josefsson. This program is free software; you can redistribute it and/or modify @@ -256,7 +256,7 @@ # if @HAVE_WINSOCK2_H@ # undef getsockopt # define getsockopt rpl_getsockopt -extern int rpl_getsockopt (int, int, int, void *, int *); +extern int rpl_getsockopt (int, int, int, void *, socklen_t *); # endif # elif @HAVE_WINSOCK2_H@ # undef getsockopt @@ -358,7 +358,7 @@ # if @HAVE_WINSOCK2_H@ # undef setsockopt # define setsockopt rpl_setsockopt -extern int rpl_setsockopt (int, int, int, const void *, int); +extern int rpl_setsockopt (int, int, int, const void *, socklen_t); # endif # elif @HAVE_WINSOCK2_H@ # undef setsockopt --- modules/getsockopt.orig 2009-03-01 20:41:19.000000000 +0100 +++ modules/getsockopt 2009-03-01 20:38:49.000000000 +0100 @@ -8,6 +8,7 @@ Depends-on: sys_socket sys_time +socklen errno configure.ac: --- modules/setsockopt.orig 2009-03-01 20:41:19.000000000 +0100 +++ modules/setsockopt 2009-03-01 20:38:49.000000000 +0100 @@ -8,6 +8,7 @@ Depends-on: sys_socket sys_time +socklen errno configure.ac: