Commit e4388643 authored by Yang Tse's avatar Yang Tse
Browse files

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
parent bc420820
Loading
Loading
Loading
Loading
+115 −47
Original line number Diff line number Diff line
@@ -225,25 +225,91 @@ AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
])


dnl CURL_FUNC_GETNAMEINFO_ARGTYPES
dnl CURL_CHECK_FUNC_GETNAMEINFO
dnl -------------------------------------------------
dnl Check the type to be passed to five of the arguments
dnl of getnameinfo function, and define those types in  
dnl Test if the getnameinfo function is available, 
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_ARG46 and GETNAMEINFO_TYPE_ARG7.
dnl This function is experimental and its results shall
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_TYPE_SOCKLEN_T])dnl
  AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
  #
  AC_MSG_CHECKING([for getnameinfo])
  AC_LINK_IFELSE([
      AC_LANG_FUNC_LINK_TRY([getnameinfo])
    ],[
      AC_MSG_RESULT([yes])
      curl_cv_getnameinfo="yes"
    ],[
      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'; 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([
@@ -295,12 +361,10 @@ AC_DEFUN([CURL_FUNC_GETNAMEINFO_ARGTYPES], [
          done
        done
      done
  ])
    ]) # AC_CACHE_CHECK
    if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
      AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
    AC_MSG_WARN([Undefining HAVE_GETNAMEINFO])
#undef HAVE_GETNAMEINFO
    ac_cv_func_getnameinfo="no"
      AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
    else
      gni_prev_IFS=$IFS; IFS=','
      set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
@@ -314,8 +378,12 @@ AC_DEFUN([CURL_FUNC_GETNAMEINFO_ARGTYPES], [
        [Define to the type of args 4 and 6 for getnameinfo.])
      AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
        [Define to the type of arg 7 for getnameinfo.])
      AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
        [Define to 1 if you have the getnameinfo function.])
      ac_cv_func_getnameinfo="yes"
    fi
])
  fi
]) # AC_DEFUN


dnl CURL_CHECK_NONBLOCKING_SOCKET
+115 −47
Original line number Diff line number Diff line
@@ -204,25 +204,91 @@ AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
])


dnl CURL_FUNC_GETNAMEINFO_ARGTYPES
dnl CURL_CHECK_FUNC_GETNAMEINFO
dnl -------------------------------------------------
dnl Check the type to be passed to five of the arguments
dnl of getnameinfo function, and define those types in  
dnl Test if the getnameinfo function is available, 
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_ARG46 and GETNAMEINFO_TYPE_ARG7.
dnl This function is experimental and its results shall
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_TYPE_SOCKLEN_T])dnl
  AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
  #
  AC_MSG_CHECKING([for getnameinfo])
  AC_LINK_IFELSE([
      AC_LANG_FUNC_LINK_TRY([getnameinfo])
    ],[
      AC_MSG_RESULT([yes])
      curl_cv_getnameinfo="yes"
    ],[
      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'; 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([
@@ -274,12 +340,10 @@ AC_DEFUN([CURL_FUNC_GETNAMEINFO_ARGTYPES], [
          done
        done
      done
  ])
    ]) # AC_CACHE_CHECK
    if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
      AC_MSG_WARN([Cannot find proper types to use for getnameinfo args])
    AC_MSG_WARN([Undefining HAVE_GETNAMEINFO])
#undef HAVE_GETNAMEINFO
    ac_cv_func_getnameinfo="no"
      AC_MSG_WARN([HAVE_GETNAMEINFO will not be defined])
    else
      gni_prev_IFS=$IFS; IFS=','
      set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
@@ -293,8 +357,12 @@ AC_DEFUN([CURL_FUNC_GETNAMEINFO_ARGTYPES], [
        [Define to the type of args 4 and 6 for getnameinfo.])
      AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[4],
        [Define to the type of arg 7 for getnameinfo.])
      AC_DEFINE_UNQUOTED(HAVE_GETNAMEINFO, 1,
        [Define to 1 if you have the getnameinfo function.])
      ac_cv_func_getnameinfo="yes"
    fi
])
  fi
]) # AC_DEFUN


dnl CURL_CHECK_NONBLOCKING_SOCKET
+6 −50
Original line number Diff line number Diff line
@@ -322,8 +322,7 @@ AC_CHECK_MEMBER(struct addrinfo.ai_flags,
)


AC_CHECK_FUNCS( getnameinfo \
                bitncmp \
AC_CHECK_FUNCS( bitncmp \
                if_indextoname,
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
AC_CHECK_FUNCS(inet_pton)
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])
else
  if test "x$ac_cv_func_getnameinfo" = "xyes"; then
    CURL_FUNC_GETNAMEINFO_ARGTYPES
  fi
fi

dnl Check if the getnameinfo function is available
dnl and get the types of five of its arguments.
CURL_CHECK_FUNC_GETNAMEINFO


dnl God bless non-standardized functions! We need to see which getservbyport_r variant is available
CARES_CHECK_GETSERVBYPORT_R
+3 −48
Original line number Diff line number Diff line
@@ -1556,7 +1556,6 @@ AC_CHECK_FUNCS( strtoll \
                stricmp \
                strcmpi \
                gethostbyaddr \
                getnameinfo \
                gettimeofday \
                inet_addr \
                inet_ntoa \
@@ -1629,46 +1628,6 @@ if test "$ac_cv_func_select" = "no"; then
  ])
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 we make an extra check here!
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
  AC_MSG_ERROR([Checking availability of function getnameinfo must be done previously])
else
  if test "x$ac_cv_func_getnameinfo" = "xyes"; then
    CURL_FUNC_GETNAMEINFO_ARGTYPES
  fi
fi
dnl Check if the getnameinfo function is available
dnl and get the types of five of its arguments.
CURL_CHECK_FUNC_GETNAMEINFO

AC_MSG_CHECKING([if we are Mac OS X (to disable poll)])
disable_poll=no