pspp-dev
[Top][All Lists]
Advanced

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

Patch for gethostbyname


From: Michel Boaventura
Subject: Patch for gethostbyname
Date: Thu, 23 Oct 2008 15:59:35 -0200

Can you make a patch to fix the problem of gethostbyname Ben?

Thanks,

Michel

2008/10/23  <address@hidden>:
> Send pspp-dev mailing list submissions to
>        address@hidden
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        http://lists.gnu.org/mailman/listinfo/pspp-dev
> or, via email, send a message with subject or body 'help' to
>        address@hidden
>
> You can reach the person managing the list at
>        address@hidden
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of pspp-dev digest..."
>
> Today's Topics:
>
>   1. gethostname fix for mingw (was: Re: Problem with
>      gethostbyname) (Ben Pfaff)
>   2. Re: Annoying DOS box launching psppire (Ben Pfaff)
>   3. Re: syntax error near unexpected token `GTK,' (Ben Pfaff)
>   4. Re: gethostname fix for mingw (Simon Josefsson)
>   5. Re: gethostname fix for mingw (was: Re: Problem with
>      gethostbyname) (Bruno Haible)
>   6. new pspp snapshot (Ben Pfaff)
>
>
> ---------- Mensagem encaminhada ----------
> From: Ben Pfaff <address@hidden>
> To: address@hidden
> Date: Wed, 22 Oct 2008 21:56:56 -0700
> Subject: gethostname fix for mingw (was: Re: Problem with gethostbyname)
> Michel reported on pspp-dev that PSPP fails to compile on mingw
> due to the following error:
>
>> In file included from
>> C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/windows.h:98,
>>                  from lseek.c:26:
>> C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/winsock2.h:635:
>> error: conflicting types for 'gethostname'
>> ./unistd.h:313: error: previous declaration of 'gethostname' was here
>
> I can see what is going wrong:
>
>        - The gethostname module fails to find gethostname()
>          because it is in the ws2_32 library, which it doesn't
>          try to link against.  Thus, it tries to replace it.
>
>        - Thus, it adds a prototype for gethostname() to the
>          replacement unistd.h.  This prototype has a length
>          parameter of type size_t (per POSIX).
>
>        - The lseek module needs unistd.h and windows.h.  The
>          latter in turn includes winsock2.h, which contains the
>          Windows prototype for gethostname(), which has an
>          length parameter of type int (who knows why).
>
> I think that the following change will fix the problem.  Does it
> look like the right approach?  If so, I will generate a new
> snapshot for Michel to test before I commit it to gnulib.
>
> Thanks,
>
> Ben.
>
> commit ed8093c8eedcf44193b29155a9bbf49f83e0d3e7
> Author: Ben Pfaff <address@hidden>
> Date:   Wed Oct 22 21:54:23 2008 -0700
>
>    Fix gethostname on mingw.
>    * lib/unistd.in.h: Bypass bad winsock2 prototype for gethostname.
>    Prevent calling gethostname on mingw without using the gethostname
>    module.
>    * gethostname.m4: Invoke gl_PREREQ_SYS_H_WINSOCK2 if it is
>    available.
>    * doc/posix-functions/gethostname.texi: Update.
>
> diff --git a/ChangeLog b/ChangeLog
> index b6c2893..e47a922 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,12 @@
> +2008-10-22  Ben Pfaff  <address@hidden>
> +
> +       * lib/unistd.in.h: Bypass bad winsock2 prototype for gethostname.
> +       Prevent calling gethostname on mingw without using the gethostname
> +       module.
> +       * gethostname.m4: Invoke gl_PREREQ_SYS_H_WINSOCK2 if it is
> +       available.
> +       * doc/posix-functions/gethostname.texi: Update.
> +
>  2008-10-22  Simon Josefsson  <address@hidden>
>
>        * lib/sys_socket.in.h (FD_ISSET): Fix warnings under mingw.
> diff --git a/doc/posix-functions/gethostname.texi 
> b/doc/posix-functions/gethostname.texi
> index 9d32a8b..1ff45fd 100644
> --- a/doc/posix-functions/gethostname.texi
> +++ b/doc/posix-functions/gethostname.texi
> @@ -9,8 +9,8 @@ Gnulib module: gethostname
>  Portability problems fixed by Gnulib:
>  @itemize
>  @item
> -This function is missing on some platforms:
> -mingw.
> +On mingw, this function has a prototype that differs from that
> +specified by POSIX, and it is defined only in the ws2_32 library.
>  @end itemize
>
>  Portability problems not fixed by Gnulib:
> diff --git a/lib/unistd.in.h b/lib/unistd.in.h
> index bfa3d49..7a5db76 100644
> --- a/lib/unistd.in.h
> +++ b/lib/unistd.in.h
> @@ -281,8 +281,17 @@ extern int getdtablesize (void);
>    If the host name is longer than LEN, set errno = EINVAL and return -1.
>    Return 0 if successful, otherwise set errno and return -1.  */
>  # if address@hidden@
> +#  if HAVE_WINSOCK2_H
> +#   /* Bypass bad prototype for gethostname(). */
> +#   include <winsock2.h>
> +#   undef gethostname
> +#   define gethostname rpl_gethostname
> +#  endif
>  extern int gethostname(char *name, size_t len);
>  # endif
> +#elif @UNISTD_H_HAVE_WINSOCK2_H@
> +# undef gethostname
> +# define gethostname 
> gethostname_used_without_requesting_gnulib_module_gethostname
>  #elif defined GNULIB_POSIXCHECK
>  # undef gethostname
>  # define gethostname(n,l) \
> diff --git a/m4/gethostname.m4 b/m4/gethostname.m4
> index b8c4e2a..7095ac3 100644
> --- a/m4/gethostname.m4
> +++ b/m4/gethostname.m4
> @@ -6,6 +6,7 @@ dnl with or without modifications, as long as this notice is 
> preserved.
>
>  AC_DEFUN([gl_FUNC_GETHOSTNAME],
>  [
> +  m4_ifdef([gl_PREREQ_SYS_H_WINSOCK2], [gl_PREREQ_SYS_H_WINSOCK2])
>   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
>   AC_REPLACE_FUNCS(gethostname)
>   if test $ac_cv_func_gethostname = no; then
>
> --
> "Welcome to the Slippery Slope. Here is your handbasket.
>  Say, can you work 70 hours this week?"
> --Ron Mansolino
>
>
>
>
>
> ---------- Mensagem encaminhada ----------
> From: Ben Pfaff <address@hidden>
> To: "Michel Boaventura" <address@hidden>
> Date: Wed, 22 Oct 2008 21:58:00 -0700
> Subject: Re: Annoying DOS box launching psppire
> I've lost the context here.  If you will point out the patch in
> question, I'll apply it to one of my trees and generate a
> snapshot for you to try.
>
> "Michel Boaventura" <address@hidden> writes:
>
>> I've made a few new tests, and can't find the problem. Those error
>> only happens if I apply the patch and "pkg-config --version" tells me
>> that I have the latest version of it.
>>
>> 2008/10/22 John Darrington <address@hidden>:
>>> I posted a reply to the pspp-dev mailing list.
>>>
>>> In future, can you post questions like this there too.  This has two
>>> benefits:  You get a better chance of a useful reply, since more
>>> people can read your question.  Also, others can benefit from reading
>>> about the problem and its solution.
>>>
>>> Thanks,
>>>
>>> John
>>>
>>> On Wed, Oct 22, 2008 at 06:00:11PM -0200, Michel Boaventura wrote:
>>>     With this patch I got this error:
>>>
>>>     ./configure: line 17628: syntax error near unexpected token `GTK,'
>>>     ./configure: line 17628: `  PKG_CHECK_MODULES(GTK, gtk+-2.0 >=
>>>     $required_gtk_version,,'
>>>     make: *** [config.status] Error 2
>>>
>>>     I'm trying to compile using the snapshot version that Ben made from me
>>>     yesterday.
>>>
>>> --
>>> PGP Public key ID: 1024D/2DE827B3
>>> fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
>>> See http://pgp.mit.edu or any PGP keyserver for public key.
>>>
>>>
>>>
>>> -----BEGIN PGP SIGNATURE-----
>>> Version: GnuPG v1.4.6 (GNU/Linux)
>>>
>>> iD8DBQFI/77AimdxnC3oJ7MRApaBAJ0fyb5IB/XCaJFuIL9nNIRE0JNPuACeICSg
>>> X8qTiMLb4N5hh3Do2fMzOlk=
>>> =kAWk
>>> -----END PGP SIGNATURE-----
>>>
>>>
>>
>>
>> _______________________________________________
>> pspp-dev mailing list
>> address@hidden
>> http://lists.gnu.org/mailman/listinfo/pspp-dev
>
> --
> "Platonically Evil Monkey has been symbolically representing the darkest
>  fears of humanity since the dawn of literature and religion, and I think
>  I speak for everyone when I give it a sidelong glance of uneasy recognition
>  this evening." --Scrymarch
>
>
>
>
>
> ---------- Mensagem encaminhada ----------
> From: Ben Pfaff <address@hidden>
> To: "Michel Boaventura" <address@hidden>
> Date: Wed, 22 Oct 2008 22:05:30 -0700
> Subject: Re: syntax error near unexpected token `GTK,'
> The problem is probably that pkg.m4, which pkg-config installs,
> is not being found by aclocal.  One solution, in that case, is to
> find pkg.m4 and copy it to the directory used by aclocal (which
> latter you can find out by running "aclocal --print-ac-dir").
>
> Another solution is to point out the patch in question and I'll
> generate a snapshot with it applied.
>
> "Michel Boaventura" <address@hidden> writes:
>
>> I understand now. Well, I will try to recompile pkg-config and see if it 
>> works.
>>
>> On 10/23/08, Ben Pfaff <address@hidden> wrote:
>>> "Michel Boaventura" <address@hidden> writes:
>>>
>>>> Strange, because it only happens when I try to configure with the
>>>> patch, but anyway I will try to compile the newest version
>>>> of pkg-config on mingw.
>>>
>>> This makes sense: pkg-config is only required if you need to
>>> (re)run autoconf, which will only happen if you apply a patch
>>> that modifies certain files.
>>> --
>>> I love deadlines.
>>> I love the whooshing noise they make as they go by.
>>> --Douglas Adams
>>>
>>
>> --
>> Sent from Gmail for mobile | mobile.google.com
>>
>>
>
> --
> Ben Pfaff <address@hidden>
> Author and maintainer of Pintos
>
>
>
>
>
> ---------- Mensagem encaminhada ----------
> From: Simon Josefsson <address@hidden>
> To: address@hidden
> Date: Thu, 23 Oct 2008 08:31:29 +0200
> Subject: Re: gethostname fix for mingw
> Ben Pfaff <address@hidden> writes:
>
>> Michel reported on pspp-dev that PSPP fails to compile on mingw
>> due to the following error:
>>
>>> In file included from
>>> C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/windows.h:98,
>>>                  from lseek.c:26:
>>> C:/MinGW/bin/../lib/gcc/mingw32/3.4.5/../../../../include/winsock2.h:635:
>>> error: conflicting types for 'gethostname'
>>> ./unistd.h:313: error: previous declaration of 'gethostname' was here
>
> I've seen this as well recently.
>
>> I can see what is going wrong:
>>
>>         - The gethostname module fails to find gethostname()
>>           because it is in the ws2_32 library, which it doesn't
>>           try to link against.  Thus, it tries to replace it.
>>
>>         - Thus, it adds a prototype for gethostname() to the
>>           replacement unistd.h.  This prototype has a length
>>           parameter of type size_t (per POSIX).
>>
>>         - The lseek module needs unistd.h and windows.h.  The
>>           latter in turn includes winsock2.h, which contains the
>>           Windows prototype for gethostname(), which has an
>>           length parameter of type int (who knows why).
>>
>> I think that the following change will fix the problem.  Does it
>> look like the right approach?  If so, I will generate a new
>> snapshot for Michel to test before I commit it to gnulib.
>
> If it works, I'm for it.
>
> /Simon
>
>
>
>
>
> ---------- Mensagem encaminhada ----------
> From: Bruno Haible <address@hidden>
> To: address@hidden, address@hidden
> Date: Thu, 23 Oct 2008 13:49:24 +0200
> Subject: Re: gethostname fix for mingw (was: Re: Problem with gethostbyname)
> Ben Pfaff wrote:
>> --- a/lib/unistd.in.h
>> +++ b/lib/unistd.in.h
>> @@ -281,8 +281,17 @@ extern int getdtablesize (void);
>>     If the host name is longer than LEN, set errno = EINVAL and return -1.
>>     Return 0 if successful, otherwise set errno and return -1.  */
>>  # if address@hidden@
>> +#  if HAVE_WINSOCK2_H
>> +#   /* Bypass bad prototype for gethostname(). */
>> +#   include <winsock2.h>
>> +#   undef gethostname
>> +#   define gethostname rpl_gethostname
>> +#  endif
>>  extern int gethostname(char *name, size_t len);
>>  # endif
>> +#elif @UNISTD_H_HAVE_WINSOCK2_H@
>> +# undef gethostname
>> +# define gethostname 
>> gethostname_used_without_requesting_gnulib_module_gethostname
>>  #elif defined GNULIB_POSIXCHECK
>>  # undef gethostname
>>  # define gethostname(n,l) \
>
> Yes, this looks all right. Only use @UNISTD_H_HAVE_WINSOCK2_H@ instead
> of HAVE_WINSOCK2_H in line 284 above.
>
> Thanks!
>
> Bruno
>
>
>
>
>
>
> ---------- Mensagem encaminhada ----------
> From: Ben Pfaff <address@hidden>
> To: address@hidden, address@hidden
> Date: Tue, 21 Oct 2008 21:25:17 -0700
> Subject: new pspp snapshot
> Upon request, I've built a new PSPP development snapshot and made
> it available at:
>        http://footstool.stanford.edu/~blp/pspp-snapshot-2008-10-21.tar.gz
>
> --
> Ben Pfaff
> http://benpfaff.org
>
>
>
>
> _______________________________________________
> pspp-dev mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/pspp-dev
>
>




reply via email to

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