bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inet_ntop fix for mingw32


From: Simon Josefsson
Subject: Re: inet_ntop fix for mingw32
Date: Wed, 18 Jan 2006 15:15:23 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Bruno Haible <address@hidden> writes:

> Simon Josefsson wrote:
>> This fixes the socklen M4 test.  It more or less duplicate the
>> sys_socket module but I don't see any other way around it.
>
> Duplication of code always leads to maintenance problems. Not sometimes.
> Always. (I tried it often enough ;-))

Agreed.

> Already in this patch it is not clear why the replacement socket_.h
> includes <winsock2.h> but socklen.m4 doesn't.

It is because winsock2.h defines getpeername as:

windef.h:#define PASCAL _pascal
typedef unsigned int    u_int;
...
typedef u_int   SOCKET;
...
int PASCAL getpeername(SOCKET,struct sockaddr*,int*);

This doesn't match ANY of the attempted prototypes in socklen.m4, I
get:

/usr/lib/gcc/i586-mingw32msvc/3.4.4/../../../../i586-mingw32msvc/include/winsock2.h:520:
 error: previous declaration of 'getpeername' was here
conftest.c:64: error: conflicting types for 'getpeername'

For all combinations attempted.

But I suppose winsock2.h _should_ be included, so that the real
prototype is used to find the proper socklen_t.

> It is probably because on current mingw systems, <winsock2.h>
> doesn't define socklen_t.  They only need to reshuffle their include
> files a bit, to break our macro.

Right.  socklen_t is only defined in ws2tcpip.h.

> How about this? (Untested.)

If we can solve the above problem, there is also the problem of adding
the proper -I's to locate the socket_.h.  I had to hard-code the path
to be able to test your patch.

Further, if socket_.h is ever generated (i.e., contain @FOO@), this
may break too.  I have no such example yet, so we could try to get
this to work and re-do it if we ever need @FOO@ in socket_.h later.

Thanks!

>
> Bruno
>
>
> *** socklen.m4  2 Dec 2005 18:23:00 -0000       1.3
> --- socklen.m4  18 Jan 2006 13:08:44 -0000
> ***************
> *** 1,5 ****
> ! # socklen.m4 serial 2
> ! dnl Copyright (C) 2005 Free Software Foundation, Inc.
>   dnl This file is free software; the Free Software Foundation
>   dnl gives unlimited permission to copy and/or distribute it,
>   dnl with or without modifications, as long as this notice is preserved.
> --- 1,5 ----
> ! # socklen.m4 serial 3
> ! dnl Copyright (C) 2005-2006 Free Software Foundation, Inc.
>   dnl This file is free software; the Free Software Foundation
>   dnl gives unlimited permission to copy and/or distribute it,
>   dnl with or without modifications, as long as this notice is preserved.
> ***************
> *** 11,17 ****
>   dnl types for the argument to getsockopt, getpeername, etc.  So we
>   dnl have to test to find something that will work.
>   AC_DEFUN([gl_TYPE_SOCKLEN_T],
> !   [AC_CHECK_TYPE([socklen_t], ,
>        [AC_MSG_CHECKING([for socklen_t equivalent])
>         AC_CACHE_VAL([gl_cv_gl_cv_socklen_t_equiv],
>           [# Systems have either "struct sockaddr *" or
> --- 11,18 ----
>   dnl types for the argument to getsockopt, getpeername, etc.  So we
>   dnl have to test to find something that will work.
>   AC_DEFUN([gl_TYPE_SOCKLEN_T],
> !   [AC_REQUIRE([gl_HEADER_SYS_SOCKET])
> !    AC_CHECK_TYPE([socklen_t], ,
>        [AC_MSG_CHECKING([for socklen_t equivalent])
>         AC_CACHE_VAL([gl_cv_gl_cv_socklen_t_equiv],
>           [# Systems have either "struct sockaddr *" or
> ***************
> *** 21,28 ****
>            for t in int size_t "unsigned int" "long int" "unsigned long int"; 
> do
>              AC_TRY_COMPILE(
>                [#include <sys/types.h>
> !               #include <sys/socket.h>
> ! 
>                 int getpeername (int, $arg2 *, $t *);],
>                  [$t len;
>                 getpeername (0, 0, &len);],
> --- 22,32 ----
>            for t in int size_t "unsigned int" "long int" "unsigned long int"; 
> do
>              AC_TRY_COMPILE(
>                [#include <sys/types.h>
> !               #if HAVE_SYS_SOCKET_H
> !               # include <sys/socket.h>
> !               #else
> !               # include "socket_.h"
> !               #endif
>                 int getpeername (int, $arg2 *, $t *);],
>                  [$t len;
>                 getpeername (0, 0, &len);],




reply via email to

[Prev in Thread] Current Thread [Next in Thread]