Checking for function getnameinfo and its arguments is finally

done in one single function CURL_CHECK_FUNC_GETNAMEINFO which
will only define HAVE_GETNAMEINFO if the function has been found
AND the type of its arguments has been properly been detected
This commit is contained in:
Yang Tse 2005-12-21 20:44:54 +00:00
parent bc4208201c
commit e4388643f1
4 changed files with 239 additions and 192 deletions

View File

@ -225,28 +225,94 @@ AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
]) ])
dnl CURL_FUNC_GETNAMEINFO_ARGTYPES dnl CURL_CHECK_FUNC_GETNAMEINFO
dnl ------------------------------------------------- dnl -------------------------------------------------
dnl Check the type to be passed to five of the arguments dnl Test if the getnameinfo function is available,
dnl of getnameinfo function, and define those types in dnl and check the types of five of its arguments.
dnl If the function succeeds HAVE_GETNAMEINFO will be
dnl defined, defining the types of the arguments in
dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2, dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7. dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7.
dnl This function is experimental and its results shall dnl This function is experimental and its results shall
dnl not be trusted while this notice is in place ------ dnl not be trusted while this notice is in place ------
AC_DEFUN([CURL_FUNC_GETNAMEINFO_ARGTYPES], [ AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h) AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
AC_CACHE_CHECK([types of arguments for getnameinfo], #
[curl_cv_func_getnameinfo_args], [ AC_MSG_CHECKING([for getnameinfo])
curl_cv_func_getnameinfo_args="unknown" AC_LINK_IFELSE([
for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do AC_LANG_FUNC_LINK_TRY([getnameinfo])
for gni_arg2 in 'socklen_t' 'size_t' 'int'; do ],[
for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do AC_MSG_RESULT([yes])
for gni_arg7 in 'int' 'unsigned int'; do curl_cv_getnameinfo="yes"
AC_COMPILE_IFELSE([ ],[
AC_LANG_PROGRAM([ AC_MSG_RESULT([no])
curl_cv_getnameinfo="no"
])
#
if test "$curl_cv_getnameinfo" != "yes"; then
AC_MSG_CHECKING([deeper for getnameinfo])
AC_TRY_LINK([
],[
getnameinfo();
],[
AC_MSG_RESULT([yes])
curl_cv_getnameinfo="yes"
],[
AC_MSG_RESULT([but still no])
curl_cv_getnameinfo="no"
])
fi
#
if test "$curl_cv_getnameinfo" != "yes"; then
AC_MSG_CHECKING([deeper and deeper for getnameinfo])
AC_TRY_LINK([
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
#endif
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
#endif
],[
getnameinfo(0, 0, 0, 0, 0, 0, 0);
],[
AC_MSG_RESULT([yes])
curl_cv_getnameinfo="yes"
],[
AC_MSG_RESULT([but still no])
curl_cv_getnameinfo="no"
])
fi
#
if test "$curl_cv_getnameinfo" = "yes"; then
AC_CACHE_CHECK([types of arguments for getnameinfo],
[curl_cv_func_getnameinfo_args], [
curl_cv_func_getnameinfo_args="unknown"
for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
for gni_arg7 in 'int' 'unsigned int'; do
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#undef inline #undef inline
#ifdef HAVE_WINDOWS_H #ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
@ -276,46 +342,48 @@ AC_DEFUN([CURL_FUNC_GETNAMEINFO_ARGTYPES], [
#endif #endif
#define GNICALLCONV #define GNICALLCONV
#endif #endif
extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2, extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
char *, $gni_arg46, char *, $gni_arg46,
char *, $gni_arg46, char *, $gni_arg46,
$gni_arg7); $gni_arg7);
],[
$gni_arg2 salen=0;
$gni_arg46 hostlen=0;
$gni_arg46 servlen=0;
$gni_arg7 flags=0;
int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
])
],[ ],[
$gni_arg2 salen=0; curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
$gni_arg46 hostlen=0; break 4
$gni_arg46 servlen=0;
$gni_arg7 flags=0;
int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
]) ])
],[ done
curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
break 4
])
done done
done done
done done
done ]) # AC_CACHE_CHECK
]) if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
if test "$curl_cv_func_getnameinfo_args" = "unknown"; then AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
AC_MSG_WARN([Cannot find proper types to use for getnameinfo args]) AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
AC_MSG_WARN([Undefining HAVE_GETNAMEINFO]) else
#undef HAVE_GETNAMEINFO gni_prev_IFS=$IFS; IFS=','
ac_cv_func_getnameinfo="no" set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
else IFS=$gni_prev_IFS
gni_prev_IFS=$IFS; IFS=',' shift
set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'` AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $[1],
IFS=$gni_prev_IFS [Define to the type of arg 1 for getnameinfo.])
shift AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $[1], [Define to the type of arg 2 for getnameinfo.])
[Define to the type of arg 1 for getnameinfo.]) AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2], [Define to the type of args 4 and 6 for getnameinfo.])
[Define to the type of arg 2 for getnameinfo.]) AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3], [Define to the type of arg 7 for getnameinfo.])
[Define to the type of args 4 and 6 for getnameinfo.]) AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4], [Define to 1 if you have the getnameinfo function.])
[Define to the type of arg 7 for getnameinfo.]) ac_cv_func_getnameinfo="yes"
fi
fi fi
]) ]) # AC_DEFUN
dnl CURL_CHECK_NONBLOCKING_SOCKET dnl CURL_CHECK_NONBLOCKING_SOCKET

View File

@ -204,28 +204,94 @@ AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
]) ])
dnl CURL_FUNC_GETNAMEINFO_ARGTYPES dnl CURL_CHECK_FUNC_GETNAMEINFO
dnl ------------------------------------------------- dnl -------------------------------------------------
dnl Check the type to be passed to five of the arguments dnl Test if the getnameinfo function is available,
dnl of getnameinfo function, and define those types in dnl and check the types of five of its arguments.
dnl If the function succeeds HAVE_GETNAMEINFO will be
dnl defined, defining the types of the arguments in
dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2, dnl GETNAMEINFO_TYPE_ARG1, GETNAMEINFO_TYPE_ARG2,
dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7. dnl GETNAMEINFO_TYPE_ARG46 and GETNAMEINFO_TYPE_ARG7.
dnl This function is experimental and its results shall dnl This function is experimental and its results shall
dnl not be trusted while this notice is in place ------ dnl not be trusted while this notice is in place ------
AC_DEFUN([CURL_FUNC_GETNAMEINFO_ARGTYPES], [ AC_DEFUN([CURL_CHECK_FUNC_GETNAMEINFO], [
AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl AC_REQUIRE([CURL_CHECK_TYPE_SOCKLEN_T])dnl
AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h) AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
AC_CACHE_CHECK([types of arguments for getnameinfo], #
[curl_cv_func_getnameinfo_args], [ AC_MSG_CHECKING([for getnameinfo])
curl_cv_func_getnameinfo_args="unknown" AC_LINK_IFELSE([
for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do AC_LANG_FUNC_LINK_TRY([getnameinfo])
for gni_arg2 in 'socklen_t' 'size_t' 'int'; do ],[
for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int'; do AC_MSG_RESULT([yes])
for gni_arg7 in 'int' 'unsigned int'; do curl_cv_getnameinfo="yes"
AC_COMPILE_IFELSE([ ],[
AC_LANG_PROGRAM([ AC_MSG_RESULT([no])
curl_cv_getnameinfo="no"
])
#
if test "$curl_cv_getnameinfo" != "yes"; then
AC_MSG_CHECKING([deeper for getnameinfo])
AC_TRY_LINK([
],[
getnameinfo();
],[
AC_MSG_RESULT([yes])
curl_cv_getnameinfo="yes"
],[
AC_MSG_RESULT([but still no])
curl_cv_getnameinfo="no"
])
fi
#
if test "$curl_cv_getnameinfo" != "yes"; then
AC_MSG_CHECKING([deeper and deeper for getnameinfo])
AC_TRY_LINK([
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
#endif
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
#endif
],[
getnameinfo(0, 0, 0, 0, 0, 0, 0);
],[
AC_MSG_RESULT([yes])
curl_cv_getnameinfo="yes"
],[
AC_MSG_RESULT([but still no])
curl_cv_getnameinfo="no"
])
fi
#
if test "$curl_cv_getnameinfo" = "yes"; then
AC_CACHE_CHECK([types of arguments for getnameinfo],
[curl_cv_func_getnameinfo_args], [
curl_cv_func_getnameinfo_args="unknown"
for gni_arg1 in 'struct sockaddr *' 'const struct sockaddr *' 'void *'; do
for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
for gni_arg46 in 'size_t' 'int' 'socklen_t' 'unsigned int' 'DWORD'; do
for gni_arg7 in 'int' 'unsigned int'; do
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#undef inline #undef inline
#ifdef HAVE_WINDOWS_H #ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
@ -255,46 +321,48 @@ AC_DEFUN([CURL_FUNC_GETNAMEINFO_ARGTYPES], [
#endif #endif
#define GNICALLCONV #define GNICALLCONV
#endif #endif
extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2, extern int GNICALLCONV getnameinfo($gni_arg1, $gni_arg2,
char *, $gni_arg46, char *, $gni_arg46,
char *, $gni_arg46, char *, $gni_arg46,
$gni_arg7); $gni_arg7);
],[
$gni_arg2 salen=0;
$gni_arg46 hostlen=0;
$gni_arg46 servlen=0;
$gni_arg7 flags=0;
int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
])
],[ ],[
$gni_arg2 salen=0; curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
$gni_arg46 hostlen=0; break 4
$gni_arg46 servlen=0;
$gni_arg7 flags=0;
int res = getnameinfo(0, salen, 0, hostlen, 0, servlen, flags);
]) ])
],[ done
curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
break 4
])
done done
done done
done done
done ]) # AC_CACHE_CHECK
]) if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
if test "$curl_cv_func_getnameinfo_args" = "unknown"; then AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
AC_MSG_WARN([Cannot find proper types to use for getnameinfo args]) AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
AC_MSG_WARN([Undefining HAVE_GETNAMEINFO]) else
#undef HAVE_GETNAMEINFO gni_prev_IFS=$IFS; IFS=','
ac_cv_func_getnameinfo="no" set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
else IFS=$gni_prev_IFS
gni_prev_IFS=$IFS; IFS=',' shift
set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'` AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $[1],
IFS=$gni_prev_IFS [Define to the type of arg 1 for getnameinfo.])
shift AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $[1], [Define to the type of arg 2 for getnameinfo.])
[Define to the type of arg 1 for getnameinfo.]) AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2], [Define to the type of args 4 and 6 for getnameinfo.])
[Define to the type of arg 2 for getnameinfo.]) AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3], [Define to the type of arg 7 for getnameinfo.])
[Define to the type of args 4 and 6 for getnameinfo.]) AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4], [Define to 1 if you have the getnameinfo function.])
[Define to the type of arg 7 for getnameinfo.]) ac_cv_func_getnameinfo="yes"
fi
fi fi
]) ]) # AC_DEFUN
dnl CURL_CHECK_NONBLOCKING_SOCKET dnl CURL_CHECK_NONBLOCKING_SOCKET

View File

@ -322,8 +322,7 @@ AC_CHECK_MEMBER(struct addrinfo.ai_flags,
) )
AC_CHECK_FUNCS( getnameinfo \ AC_CHECK_FUNCS( bitncmp \
bitncmp \
if_indextoname, if_indextoname,
dnl if found dnl if found
[], [],
@ -341,47 +340,6 @@ AC_TRY_LINK( [],
) )
dnl Msys/Mingw does not detect getnameinfo() in AC_CHECK_FUNCS.
dnl
if test "$ac_cv_func_getnameinfo" = "no"; then
AC_MSG_CHECKING([deeper and deeper for getnameinfo])
AC_TRY_LINK([
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
#endif
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
#endif
],[
getnameinfo(0, 0, 0, 0, 0, 0, 0);
],[
AC_MSG_RESULT([yes])
ac_cv_func_getnameinfo="yes"
AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
[Define to 1 if you have the getnameinfo function.])
],[
AC_MSG_RESULT([no])
])
fi
dnl check for inet_pton dnl check for inet_pton
AC_CHECK_FUNCS(inet_pton) AC_CHECK_FUNCS(inet_pton)
dnl Some systems have it, but not IPv6 dnl Some systems have it, but not IPv6
@ -530,13 +488,11 @@ AC_CHECK_SIZEOF(struct in_addr, ,
] ]
) )
if test "x$ac_cv_func_getnameinfo" = "x"; then
AC_MSG_ERROR([Checking availability of function getnameinfo must be done previously]) dnl Check if the getnameinfo function is available
else dnl and get the types of five of its arguments.
if test "x$ac_cv_func_getnameinfo" = "xyes"; then CURL_CHECK_FUNC_GETNAMEINFO
CURL_FUNC_GETNAMEINFO_ARGTYPES
fi
fi
dnl God bless non-standardized functions! We need to see which getservbyport_r variant is available dnl God bless non-standardized functions! We need to see which getservbyport_r variant is available
CARES_CHECK_GETSERVBYPORT_R CARES_CHECK_GETSERVBYPORT_R

View File

@ -1556,7 +1556,6 @@ AC_CHECK_FUNCS( strtoll \
stricmp \ stricmp \
strcmpi \ strcmpi \
gethostbyaddr \ gethostbyaddr \
getnameinfo \
gettimeofday \ gettimeofday \
inet_addr \ inet_addr \
inet_ntoa \ inet_ntoa \
@ -1629,46 +1628,6 @@ if test "$ac_cv_func_select" = "no"; then
]) ])
fi fi
dnl Msys/Mingw does not detect getnameinfo() in AC_CHECK_FUNCS.
dnl
if test "$ac_cv_func_getnameinfo" = "no"; then
AC_MSG_CHECKING([deeper and deeper for getnameinfo])
AC_TRY_LINK([
#undef inline
#ifdef HAVE_WINDOWS_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
#endif
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
#endif
],[
getnameinfo(0, 0, 0, 0, 0, 0, 0);
],[
AC_MSG_RESULT([yes])
ac_cv_func_getnameinfo="yes"
AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
[Define to 1 if you have the getnameinfo function.])
],[
AC_MSG_RESULT([no])
])
fi
dnl sigsetjmp() might be a macro and no function so if it isn't found already dnl sigsetjmp() might be a macro and no function so if it isn't found already
dnl we make an extra check here! dnl we make an extra check here!
if test "$ac_cv_func_sigsetjmp" != "yes"; then if test "$ac_cv_func_sigsetjmp" != "yes"; then
@ -1705,13 +1664,9 @@ AC_CHECK_DECL(inet_pton, ,
] ]
) )
if test "x$ac_cv_func_getnameinfo" = "x"; then dnl Check if the getnameinfo function is available
AC_MSG_ERROR([Checking availability of function getnameinfo must be done previously]) dnl and get the types of five of its arguments.
else CURL_CHECK_FUNC_GETNAMEINFO
if test "x$ac_cv_func_getnameinfo" = "xyes"; then
CURL_FUNC_GETNAMEINFO_ARGTYPES
fi
fi
AC_MSG_CHECKING([if we are Mac OS X (to disable poll)]) AC_MSG_CHECKING([if we are Mac OS X (to disable poll)])
disable_poll=no disable_poll=no