+2006-01-25 Simon Josefsson <jas@extundo.com>
+
+ * socket_.h: Set WINVER to 0x0501, to make sure getaddrinfo
+ prototype is visible on mingw32.
+
+ * getaddrinfo.h: Define EAI_ADDRFAMILY and EAI_SYSTEM if not set,
+ for mingw32.
+
+ * gai_strerror.c, getaddrinfo.h: Protect netdb.h #include (for
+ mingw32).
+
2006-01-26 Paul Eggert <eggert@cs.ucla.edu>
* fts.c (diropen): Open with O_NOCTTY | O_NONBLOCK too. Don't
-/* Copyright (C) 1997, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Philip Blundell <pjb27@cam.ac.uk>, 1997.
#endif
#include <stdio.h>
-#include <netdb.h>
+#ifdef HAVE_NETDB_H
+# include <netdb.h>
+#endif
#ifdef _LIBC
# include <libintl.h>
/* Get address information.
- Copyright (C) 1996-2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1996-2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Contributed by Simon Josefsson <simon@josefsson.org>.
This program is free software; you can redistribute it and/or modify
# include <sys/types.h>
/* Get all getaddrinfo related declarations, if available. */
# include <sys/socket.h>
+#ifdef HAVE_NETDB_H
# include <netdb.h>
+#endif
# ifndef HAVE_STRUCT_ADDRINFO
# 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
+# ifndef EAI_ADDRFAMILY
+/* Not defined on mingw32. XXX May be incorrect? Perhaps it is never
+ returned? */
+# define EAI_ADDRFAMILY -9 /* Address family for NAME not supported. */
+# endif
+# ifndef EAI_SYSTEM
+/* Not defined on mingw32. XXX May be incorrect? Perhaps it is never
+ returned? */
+# define EAI_SYSTEM -11 /* System error returned in `errno'. */
# endif
# ifdef __USE_GNU
we need. */
#if HAVE_WINSOCK2_H
+/* The following define makes sure we get all the prototypes from the
+ header files. getaddrinfo is only available if _WIN32_WINNT >=
+ 0x0501 (that symbol is set indiriectly through WINVER). This has
+ the following two (potential) problems:
+
+ 1) winsock2.h must not have been included before this symbol
+ is set (I think).
+
+ 2) There may be some _reason_ for all prototypes not being
+ available with the default settings. Such as if some APIs are
+ not available on older Windows hosts. However, getaddrinfo
+ (which need >= 0x0501) should be available on Windows 95 and
+ later, according to:
+ http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/getaddrinfo_2.asp
+*/
+#define WINVER 0x0501
# include <winsock2.h>
#endif
#if HAVE_WS2TCPIP_H
+2006-01-25 Simon Josefsson <jas@extundo.com>
+
+ * getaddrinfo.m4: Look for getaddrinfo inside ws2tcip.h and
+ -lws2_32. Protect sys/socket.h and netdb.h #include's. Include
+ ws2tcpip.h with WINVER=0x0501. All for mingw32.
+
2006-01-25 Paul Eggert <eggert@cs.ucla.edu>
* stdbool.m4 (AC_HEADER_STDBOOL): Check for xlc bug if __GCC__ too,
# getaddrinfo.m4 serial 7
-dnl Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+dnl Copyright (C) 2004, 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.
AC_DEFUN([gl_GETADDRINFO],
[
+ AC_MSG_NOTICE([checking how to do getaddrinfo])
+
AC_SEARCH_LIBS(getaddrinfo, [nsl socket])
- AC_SEARCH_LIBS(gethostbyname, [inet nsl])
- AC_SEARCH_LIBS(getservbyname, [inet nsl socket xnet])
- AC_REPLACE_FUNCS(getaddrinfo gai_strerror)
+ AC_CHECK_FUNCS(getaddrinfo,, [
+ AC_CACHE_CHECK(for getaddrinfo in ws2tcpip.h and -lws2_32,
+ gl_cv_w32_getaddrinfo, [
+ gl_cv_w32_getaddrinfo=no
+ am_save_LIBS="$LIBS"
+ LIBS="$LIBS -lws2_32"
+ AC_TRY_LINK([
+#define WINVER 0x0501
+#include <ws2tcpip.h>
+], [getaddrinfo(0, 0, 0, 0);], gl_cv_w32_getaddrinfo=yes)
+ LIBS="$am_save_LIBS"
+ if test "$gl_cv_w32_getaddrinfo" = "yes"; then
+ LIBS="$LIBS -lws2_32"
+ else
+ AC_LIBOBJ(getaddrinfo)
+ fi
+ ])])
+
+ AC_REPLACE_FUNCS(gai_strerror)
gl_PREREQ_GETADDRINFO
])
# Prerequisites of lib/getaddrinfo.h and lib/getaddrinfo.c.
AC_DEFUN([gl_PREREQ_GETADDRINFO], [
+ AC_SEARCH_LIBS(gethostbyname, [inet nsl])
+ AC_SEARCH_LIBS(getservbyname, [inet nsl socket xnet])
AC_REQUIRE([gl_C_RESTRICT])
AC_REQUIRE([gl_SOCKET_FAMILIES])
AC_REQUIRE([AC_C_INLINE])
AC_REQUIRE([AC_GNU_SOURCE])
- AC_CHECK_HEADERS_ONCE(netinet/in.h)
+ AC_CHECK_HEADERS_ONCE(netinet/in.h sys/socket.h netdb.h ws2tcpip.h)
AC_CHECK_DECLS([getaddrinfo, freeaddrinfo, gai_strerror],,,[
/* sys/types.h is not needed according to POSIX, but the
sys/socket.h in i386-unknown-freebsd4.10 and
powerpc-apple-darwin5.5 required it. */
#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETDB_H
#include <netdb.h>
+#endif
+#ifdef HAVE_WS2TCPIP_H
+#define WINVER 0x0501
+#include <ws2tcpip.h>
+#endif
])
AC_CHECK_TYPES([struct addrinfo],,,[
#include <sys/types.h>
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
+#ifdef HAVE_NETDB_H
#include <netdb.h>
+#endif
+#ifdef HAVE_WS2TCPIP_H
+#define WINVER 0x0501
+#include <ws2tcpip.h>
+#endif
])
])