bug-gnulib
[Top][All Lists]
Advanced

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

Re: coreutils-5.90 build feedback


From: Simon Josefsson
Subject: Re: coreutils-5.90 build feedback
Date: Sat, 01 Oct 2005 11:19:57 +0200
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

Jim Meyering <address@hidden> writes:

>> On Compaq Alpha OSF/1 5.1:
>>
>>      c89 -DHAVE_CONFIG_H 
>> -DLIBDIR=\"/uufs/inscc.utah.edu/common/home/mthnhb/alpha/local/lib\" -I. -I. 
>> -I..
>>       -I.. -I. -I/uufs/inscc.utah.edu/common/home/mthnhb/alpha/local/include 
>>  -ieee
>>      -I/uufs/inscc.utah.edu/common/home/mthnhb/alpha/local/include -c 
>> getaddrinfo.c
>>      ...
>>      cc: Error: getaddrinfo.h, line 31: In this declaration, the struct 
>> "addrinfo" is redefined.
>>      (redefstruct)
>>      struct addrinfo
>>      ^
>>      cc: Error: getaddrinfo.h, line 91: In this declaration, the type of 
>> "gai_strerror" is not compatible
>>      with the type of a previous declaration of "gai_strerror" at line 
>> number 293 in file
>>      /usr/include/netdb.h. (notcompat)
>>      extern const char *gai_strerror (int ecode);
>>
>> I'm doing a new build with cc on that system.
>
> This is happening because getaddrinfo.h defines struct addrinfo
> and declares gai_strerror merely because the system lacks the
> getaddrinfo function.  But this system already has those in netdb.h,
> and they conflict.
>
> Simon, I think the guards should be more precise.
> I.e., use HAVE_GETADDRINFO only for the getaddrinfo declaration.
> Then test for gai_strerror and guard its declaration with HAVE_GAI_STRERROR.
> Similarly for struct addrinfo.
>
> Do you feel like doing that?

Yes, I'll work on this.

How about this patch?  Not exactly like you suggested, but appears
good to me.  I have not tested this, but if it looks good for you,
I'll install it in my projects and rebuild them, then we can sort out
any remaining build problems later on.

Perhaps the AI_* and EAI* define's should be guarded on a per-flag
basis.

Last time I checked, I didn't have simple access to any system without
getaddrinfo, so I can only test this partially.  If anyone know about
any public build cluster without getaddrinfo, please let me know.

2005-10-01  Simon Josefsson  <address@hidden>

        * getaddrinfo.m4: Use AC_GNU_SOURCE, GNU only declare getaddrinfo
        as an (POSIX) extension.  Check for sys/types.h, sys/socket.h, and
        netdb.h too, needed by getaddrinfo.h.  Check if getaddrinfo,
        freeaddrinfo and gai_strerror are declared by the POSIX headers.
        Check if struct addrinfo is declared.

2005-10-01  Simon Josefsson  <address@hidden>

        * getaddrinfo.h: Protect #include's of sys/socket.h and netdb.h.
        Only define struct addrinfo if !HAVE_STRUCT_ADDRINFO.  Protect
        AI_* and EAI_* definitions.  Protect function declarations.

Index: lib/getaddrinfo.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/getaddrinfo.h,v
retrieving revision 1.5
diff -u -p -r1.5 getaddrinfo.h
--- lib/getaddrinfo.h   13 Sep 2005 04:15:15 -0000      1.5
+++ lib/getaddrinfo.h   1 Oct 2005 09:14:31 -0000
@@ -19,13 +19,21 @@
 #ifndef GETADDRINFO_H
 # define GETADDRINFO_H
 
-/* Get getaddrinfo declarations, if available.  Also get 'socklen_t',
-   and 'struct sockaddr' via sys/types.h which are used below. */
-# include <sys/types.h>
-# include <sys/socket.h>
-# include <netdb.h>
+/* Get all getaddrinfo related declarations, if available.  */
+# ifdef HAVE_SYS_SOCKET_H
+#  include <sys/socket.h>
+# endif
+# ifdef HAVE_NETDB_H
+#  include <netdb.h>
+# endif
+
+# ifndef HAVE_STRUCT_ADDRINFO
 
-# if !HAVE_GETADDRINFO
+/* Get 'socklen_t', and 'struct sockaddr' via sys/types.h which are
+   used below. */
+#  ifdef HAVE_SYS_TYPES_H
+#   include <sys/types.h>
+#  endif
 
 /* Structure to contain information about address of a service provider.  */
 struct addrinfo
@@ -39,38 +47,47 @@ struct addrinfo
   char *ai_canonname;          /* Canonical name for service location.  */
   struct addrinfo *ai_next;    /* Pointer to next in list.  */
 };
+# endif
 
 /* Possible values for `ai_flags' field in `addrinfo' structure.  */
-# define AI_PASSIVE    0x0001  /* Socket address is intended for `bind'.  */
-# define AI_CANONNAME  0x0002  /* Request for canonical name.  */
-# define AI_NUMERICHOST        0x0004  /* Don't use name resolution.  */
-# define AI_V4MAPPED   0x0008  /* IPv4 mapped addresses are acceptable.  */
-# define AI_ALL                0x0010  /* Return IPv4 mapped and IPv6 
addresses.  */
-# define AI_ADDRCONFIG 0x0020  /* Use configuration of this host to choose
+# ifndef AI_PASSIVE
+#  define AI_PASSIVE   0x0001  /* Socket address is intended for `bind'.  */
+#  define AI_CANONNAME 0x0002  /* Request for canonical name.  */
+#  define AI_NUMERICHOST 0x0004        /* Don't use name resolution.  */
+#  define AI_V4MAPPED  0x0008  /* IPv4 mapped addresses are acceptable.  */
+#  define AI_ALL       0x0010  /* Return IPv4 mapped and IPv6 addresses.  */
+#  define AI_ADDRCONFIG        0x0020  /* Use configuration of this host to 
choose
                                   returned address type..  */
+# endif
 
 /* Error values for `getaddrinfo' function.  */
-# define EAI_BADFLAGS    -1    /* Invalid value for `ai_flags' field.  */
-# define EAI_NONAME      -2    /* NAME or SERVICE is unknown.  */
-# define EAI_AGAIN       -3    /* Temporary failure in name resolution.  */
-# define EAI_FAIL        -4    /* Non-recoverable failure in name res.  */
-# define EAI_NODATA      -5    /* No address associated with NAME.  */
-# define EAI_FAMILY      -6    /* `ai_family' not supported.  */
-# define EAI_SOCKTYPE    -7    /* `ai_socktype' not supported.  */
-# define EAI_SERVICE     -8    /* SERVICE not supported for `ai_socktype'.  */
-# define EAI_ADDRFAMILY          -9    /* Address family for NAME not 
supported.  */
-# define EAI_MEMORY      -10   /* Memory allocation failure.  */
-# define EAI_SYSTEM      -11   /* System error returned in `errno'.  */
-# define EAI_OVERFLOW    -12   /* Argument buffer overflow.  */
+# ifndef EAI_BADFLAGS
+#  define EAI_BADFLAGS   -1    /* Invalid value for `ai_flags' field.  */
+#  define EAI_NONAME     -2    /* NAME or SERVICE is unknown.  */
+#  define EAI_AGAIN      -3    /* Temporary failure in name resolution.  */
+#  define EAI_FAIL       -4    /* Non-recoverable failure in name res.  */
+#  define EAI_NODATA     -5    /* No address associated with NAME.  */
+#  define EAI_FAMILY     -6    /* `ai_family' not supported.  */
+#  define EAI_SOCKTYPE   -7    /* `ai_socktype' not supported.  */
+#  define EAI_SERVICE    -8    /* SERVICE not supported for `ai_socktype'.  */
+#  define EAI_ADDRFAMILY  -9   /* Address family for NAME not supported.  */
+#  define EAI_MEMORY     -10   /* Memory allocation failure.  */
+#  define EAI_SYSTEM     -11   /* System error returned in `errno'.  */
+#  define EAI_OVERFLOW   -12   /* Argument buffer overflow.  */
+# endif
+
 # ifdef __USE_GNU
-#  define EAI_INPROGRESS  -100 /* Processing request in progress.  */
-#  define EAI_CANCELED   -101  /* Request canceled.  */
-#  define EAI_NOTCANCELED -102 /* Request not canceled.  */
-#  define EAI_ALLDONE    -103  /* All requests done.  */
-#  define EAI_INTR       -104  /* Interrupted by a signal.  */
-#  define EAI_IDN_ENCODE  -105 /* IDN encoding failed.  */
+#  ifndef EAI_INPROGRESS
+#   define EAI_INPROGRESS      -100    /* Processing request in progress.  */
+#   define EAI_CANCELED                -101    /* Request canceled.  */
+#   define EAI_NOTCANCELED     -102    /* Request not canceled.  */
+#   define EAI_ALLDONE         -103    /* All requests done.  */
+#   define EAI_INTR            -104    /* Interrupted by a signal.  */
+#   define EAI_IDN_ENCODE      -105    /* IDN encoding failed.  */
+#  endif
 # endif
 
+# ifndef HAVE_DECL_GETADDRINFO
 /* Translate name of a service location and/or a service name to set of
    socket addresses.
    For more details, see the POSIX:2001 specification
@@ -79,17 +96,20 @@ extern int getaddrinfo (const char *rest
                        const char *restrict servname,
                        const struct addrinfo *restrict hints,
                        struct addrinfo **restrict res);
+# endif
 
+# ifndef HAVE_DECL_FREEADDRINFO
 /* Free `addrinfo' structure AI including associated storage.
    For more details, see the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/getaddrinfo.html>.  */
 extern void freeaddrinfo (struct addrinfo *ai);
+# endif
 
+# ifndef HAVE_DECL_GAI_STRERROR
 /* Convert error return from getaddrinfo() to a string.
    For more details, see the POSIX:2001 specification
    <http://www.opengroup.org/susv3xsh/gai_strerror.html>.  */
 extern const char *gai_strerror (int ecode);
-
-# endif /* !HAVE_GETADDRINFO */
+# endif
 
 #endif /* GETADDRINFO_H */
Index: m4/getaddrinfo.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/getaddrinfo.m4,v
retrieving revision 1.7
diff -u -p -r1.7 getaddrinfo.m4
--- m4/getaddrinfo.m4   27 Sep 2005 08:39:44 -0000      1.7
+++ m4/getaddrinfo.m4   1 Oct 2005 09:14:31 -0000
@@ -17,5 +17,22 @@ AC_DEFUN([gl_PREREQ_GETADDRINFO], [
   AC_REQUIRE([gl_C_RESTRICT])
   AC_REQUIRE([gl_SOCKET_FAMILIES])
   AC_REQUIRE([AC_C_INLINE])
-  AC_CHECK_HEADERS_ONCE([netinet/in.h])
+  AC_REQUIRE([AC_GNU_SOURCE])
+  AC_CHECK_HEADERS_ONCE(sys/socket.h netdb.h sys/types.h netinet/in.h)
+  AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror],,,[
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#ifdef HAVE_NETDB_H
+# include <netdb.h>
+#endif
+])
+  AC_CHECK_TYPES([struct addrinfo],,,[
+#ifdef HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#ifdef HAVE_NETDB_H
+# include <netdb.h>
+#endif
+])
 ])




reply via email to

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