inet_pton is preferrable, as it supports IPv6. I think the code should
read either:
#if PARROT_HAS_INET_PTON
... use inet_pton ...
#else
... use inet_aton ...
#endif
or
#if PARROT_HAS_INET_PTON
... use inet_pton ...
#elsif PARROT_HAS_INET_ATON
... use inet_aton ...
#else
#error
#endif
That is, inet_pton should trump inet_aton if both are available.
On Mac OS X, the preferred technique would be to weak link with
inet_pton and test for its availability at run-time. (inet_pton is not
available on 10.1, but is available on 10.3.) This would be another case
entirely.
--
Gordon Henriksen
IT Manager
ICLUBcentral Inc.
[EMAIL PROTECTED]
> -----Original Message-----
> From: Andrew Dougherty [mailto:[EMAIL PROTECTED]
> Sent: Friday February 27, 2004 11:52
> To: Perl6 Internals
> Subject: [PATCH] Configure test for inet_aton
>
>
> On Fri, 27 Feb 2004, Leopold Toetsch wrote:
>
> > Peter Sinnott wrote:
> >
> > > I have downloaded the snapshot dated 27-Feb-2004 00:01 from
> > > http://cvs.perl.org/snapshots/parrot/ and tested it on hpux.
> > >
> > > I order to get it to compile I have to revert to using inet_aton
> > > at line 623 of io_unix.c. inet_pton was causing
> unsatisfied symbols
> > > at link time.
> >
> > We need a config test here.
>
> Something like this ought to do the trick for now. Longer
> term, we need
> to build up some infrastructure for testing for functions on
> our own. We
> also need to centralize things more to avoid some of the
> duplication of
> code and information we're ending up with here.
>
>
> diff -r -u -N parrot-current/MANIFEST parrot-andy/MANIFEST
> --- parrot-current/MANIFEST 2004-02-27 03:00:34.000000000 -0500
> +++ parrot-andy/MANIFEST 2004-02-27 09:36:23.000000000 -0500
> @@ -78,6 +78,7 @@
> config/auto/format.pl []
> config/auto/funcptr.pl []
> config/auto/funcptr/test_c.in []
> +config/auto/functions.pl []
> config/auto/gc.pl []
> config/auto/gc/test_c.in []
> config/auto/gcc.pl []
> diff -r -u -N parrot-current/config/auto/functions.pl
> parrot-andy/config/auto/functions.pl
> --- parrot-current/config/auto/functions.pl 1969-12-31
> 19:00:00.000000000 -0500
> +++ parrot-andy/config/auto/functions.pl 2004-02-27
> 09:36:56.000000000 -0500
> @@ -0,0 +1,33 @@
> +#! perl -w
> +# Copyright: 20004 The Perl Foundation. All Rights Reserved.
> +# $Id:$
> +
> +=head1 NAME
> +
> +config/auto/functions.pl - Probe for Various Functions
> +
> +=head1 DESCRIPTION
> +
> +This command probes for the existence of various functions.
> +For the moment, it just pulls information from perl5's Configure;
> +in the future, it ought to go looking on its own.
> +
> +=cut
> +
> +package Configure::Step;
> +
> +use strict;
> +use vars qw($description @args);
> +
> +$description="Looking for various functions...";
> +
> [EMAIL PROTECTED]();
> +
> +sub runstep {
> + # Do we have inet_aton() ?
> + Configure::Data->set(
> + d_inet_aton => $Config{d_inetaton},
> + );
> +}
> +
> +1;
> diff -r -u -N
> parrot-current/config/gen/feature_h/feature_h.in
> parrot-andy/config/gen/feature_h/feature_h.in
> --- parrot-current/config/gen/feature_h/feature_h.in
> 2004-01-08 19:01:00.000000000 -0500
> +++ parrot-andy/config/gen/feature_h/feature_h.in
> 2004-02-27 09:36:23.000000000 -0500
> @@ -96,6 +96,21 @@
>
> print OUT <<EOP;
>
> +/* from config/auto/functions.pl */
> +EOP
> +if (${d_inet_aton}) {
> + print OUT <<EOP;
> +#define PARROT_HAS_INET_ATON 1
> +EOP
> +}
> +else {
> + print OUT <<EOP;
> +/* #undef PARROT_HAS_INET_ATON */
> +EOP
> +}
> +
> +print OUT <<EOP;
> +
> /* from config/auto/inline */
> EOP
> if (${inline} ne '') {
> diff -r -u -N parrot-current/io/io_unix.c parrot-andy/io/io_unix.c
> --- parrot-current/io/io_unix.c 2004-02-19
> 19:00:06.000000000 -0500
> +++ parrot-andy/io/io_unix.c 2004-02-27 11:09:48.000000000 -0500
> @@ -617,11 +617,16 @@
> {
> struct sockaddr_in sa;
> /* Hard coded to IPv4 for now */
> - int family = AF_INET;
> +#if !PARROT_HAS_INET_ATON
> + int family = AF_INET; /* for inet_pton() */
> +#endif
>
> char * s = string_to_cstring(interpreter, addr);
> - /*if(inet_aton(s, &sa.sin_addr) != 0) {*/
> +#if PARROT_HAS_INET_ATON
> + if(inet_aton(s, &sa.sin_addr) != 0) {
> +#else
> if(inet_pton(family, s, &sa.sin_addr) != 0) {
> +#endif
> /* Success converting numeric IP */
> }
> else {
> diff -r -u -N parrot-current/lib/Parrot/Configure/RunSteps.pm
> parrot-andy/lib/Parrot/Configure/RunSteps.pm
> --- parrot-current/lib/Parrot/Configure/RunSteps.pm
> 2003-11-27 19:00:50.000000000 -0500
> +++ parrot-andy/lib/Parrot/Configure/RunSteps.pm
> 2004-02-27 09:36:23.000000000 -0500
> @@ -4,6 +4,8 @@
> use vars qw(@steps);
>
> # EDIT HERE TO ADD NEW TESTS
> +# Also update the slightly different version of this list
> +# in Parrot::Configure::Docs:Section:Config.pm
> @steps=qw(
> init/manifest.pl
> init/data.pl
> @@ -23,6 +25,7 @@
> auto/byteorder.pl
> auto/pack.pl
> auto/format.pl
> + auto/functions.pl
> auto/gcc.pl
> auto/isreg.pl
> auto/jit.pl
> diff -r -u -N
> parrot-current/lib/Parrot/Docs/Section/Config.pm
> parrot-andy/lib/Parrot/Docs/Section/Config.pm
> --- parrot-current/lib/Parrot/Docs/Section/Config.pm
> 2004-02-26 03:00:28.000000000 -0500
> +++ parrot-andy/lib/Parrot/Docs/Section/Config.pm
> 2004-02-27 09:36:23.000000000 -0500
> @@ -66,6 +66,7 @@
> $self->new_item('', 'config/auto/byteorder.pl'),
> $self->new_item('', 'config/auto/pack.pl'),
> $self->new_item('', 'config/auto/format.pl'),
> + $self->new_item('', 'config/auto/functions.pl'),
> $self->new_item('', 'config/auto/gcc.pl'),
> $self->new_item('', 'config/auto/isreg.pl'),
> $self->new_item('', 'config/auto/jit.pl'),
> @@ -98,4 +99,4 @@
>
> =cut
>
> -1;
> \ No newline at end of file
> +1;
>
> --
> Andy Dougherty [EMAIL PROTECTED]
>