TYPE_SOCKLEN_T completely replaced by CURL_CHECK_TYPE_SOCKLEN_T.

CURL_FUNC_GETNAMEINFO_ARGTYPES now also checks first argument.
All related changes taken to cares configuration scripts.
This commit is contained in:
Yang Tse 2005-12-16 18:18:00 +00:00
parent 6dbfce1031
commit d6ffb4c177
4 changed files with 415 additions and 157 deletions

View File

@ -192,6 +192,91 @@ AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
])
dnl CURL_FUNC_GETNAMEINFO_ARGTYPES
dnl -------------------------------------------------
dnl Check the type to be passed to five of the arguments
dnl of getnameinfo function, and define those types 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_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_CACHE_CHECK([types of arguments for getnameinfo],
[curl_cv_func_getnameinfo_args], [
curl_cv_func_getnameinfo_args="unknown"
for gni_arg1 in 'struct sockaddr *' 'void *'; do
for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
for gni_arg46 in 'size_t' 'int' 'socklen_t'; do
for gni_arg7 in 'int' 'unsigned int'; do
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#undef inline
#ifdef HAVE_WINDOWS_H
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#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
extern int getnameinfo($gni_arg1, $gni_arg2,
char *, $gni_arg46,
char *, $gni_arg46,
$gni_arg7);
],[
$gni_arg1 sa=0;
$gni_arg2 salen=0;
char *host=0;
$gni_arg46 hostlen=0;
char *serv=0;
$gni_arg46 servlen=0;
$gni_arg7 flags=0;
getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
])
],[
curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
break 4
])
done
done
done
done
])
if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
AC_MSG_ERROR([Cannot find proper types to use for getnameinfo args])
else
gni_prev_IFS=$IFS; IFS=','
set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
IFS=$gni_prev_IFS
shift
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $[1],
[Define to the type of arg 1 for `getnameinfo'.])
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
[Define to the type of arg 2 for `getnameinfo'.])
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
[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'.])
fi
])
dnl Check for how to set a socket to non-blocking state. There seems to exist
dnl four known different ways, with the one used almost everywhere being POSIX
dnl and XPG3, while the other different ways for different systems (old BSD,
@ -343,50 +428,6 @@ AC_DEFUN([TYPE_SOCKADDR_STORAGE],
])
dnl Check for socklen_t: historically on BSD it is an int, and in
dnl POSIX 1g it is a type of its own, but some platforms use different
dnl types for the argument to getsockopt, getpeername, etc. So we
dnl have to test to find something that will work.
AC_DEFUN([TYPE_SOCKLEN_T],
[
AC_CHECK_TYPE([socklen_t], ,[
AC_MSG_CHECKING([for socklen_t equivalent])
AC_CACHE_VAL([curl_cv_socklen_t_equiv],
[
# Systems have either "struct sockaddr *" or
# "void *" as the second argument to getpeername
curl_cv_socklen_t_equiv=
for arg2 in "struct sockaddr" void; do
for t in int size_t unsigned long "unsigned long"; do
AC_TRY_COMPILE([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
int getpeername (int, $arg2 *, $t *);
],[
$t len;
getpeername(0,0,&len);
],[
curl_cv_socklen_t_equiv="$t"
break
])
done
done
if test "x$curl_cv_socklen_t_equiv" = x; then
AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
fi
])
AC_MSG_RESULT($curl_cv_socklen_t_equiv)
AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
[type to use in place of socklen_t if not defined])],
[#include <sys/types.h>
#include <sys/socket.h>])
])
dnl Check for in_addr_t: it is used to receive the return code of inet_addr()
dnl and a few other things.
@ -882,83 +923,6 @@ fi
])
dnl CURL_FUNC_GETNAMEINFO_ARGTYPES
dnl ------------------------------
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_REQUIRE([TYPE_SOCKLEN_T])dnl
AC_CHECK_HEADERS(sys/types.h sys/socket.h netdb.h)
AC_CACHE_CHECK([types of arguments for getnameinfo],
[curl_cv_func_getnameinfo_args], [
for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
for gni_arg46 in 'size_t' 'int' 'socklen_t'; do
for gni_arg7 in 'int' 'unsigned int'; do
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#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
extern int getnameinfo(const struct sockaddr *,
$gni_arg2,
char *,
$gni_arg46,
char *,
$gni_arg46,
$gni_arg7);
],[
int res;
struct sockaddr *sa=0;
$gni_arg2 salen=0;
char *host=0;
$gni_arg46 hostlen=0;
char *serv=0;
$gni_arg46 servlen=0;
$gni_arg7 flags=0;
res = getnameinfo(sa,
salen,
host,
hostlen,
serv,
servlen,
flags);
])
],[
curl_cv_func_getnameinfo_args="$gni_arg2,$gni_arg46,$gni_arg7"
break 3
])
done
done
done
# Provide widely used default values.
: ${curl_cv_func_getnameinfo_args='socklen_t,size_t,int'}
])
gni_prev_IFS=$IFS; IFS=','
set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
IFS=$gni_prev_IFS
shift
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[1],
[Define to the type of arg 2 for `getnameinfo'.])
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[2],
[Define to the type of args 4 and 6 for `getnameinfo'.])
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG7, $[3],
[Define to the type of arg 7 for `getnameinfo'.])
])
dnl We create a function for detecting which compiler we use and then set as
dnl pendantic compiler options as possible for that particular compiler. The
dnl options are only used for debug-builds.

View File

@ -1,3 +1,282 @@
dnl CURL_CHECK_HEADER_WINDOWS
dnl -------------------------------------------------
dnl Check for compilable and valid windows.h header
AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [
AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#undef inline
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
],[
int dummy=2*WINVER;
])
],[
ac_cv_header_windows_h="yes"
],[
ac_cv_header_windows_h="no"
])
])
if test "x$ac_cv_header_windows_h" = "xyes"; then
AC_DEFINE_UNQUOTED(HAVE_WINDOWS_H, 1,
[Define to 1 if you have the windows.h header file.])
AC_DEFINE_UNQUOTED(WIN32_LEAN_AND_MEAN, 1,
[Define to avoid automatic inclusion of winsock.h])
fi
])
dnl CURL_CHECK_HEADER_WINSOCK
dnl -------------------------------------------------
dnl Check for compilable and valid winsock.h header
AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#undef inline
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock.h>
],[
int dummy=WSACleanup();
])
],[
ac_cv_header_winsock_h="yes"
],[
ac_cv_header_winsock_h="no"
])
])
if test "x$ac_cv_header_winsock_h" = "xyes"; then
AC_DEFINE_UNQUOTED(HAVE_WINSOCK_H, 1,
[Define to 1 if you have the winsock.h header file.])
fi
])
dnl CURL_CHECK_HEADER_WINSOCK2
dnl -------------------------------------------------
dnl Check for compilable and valid winsock2.h header
AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [
AC_REQUIRE([CURL_CHECK_HEADER_WINDOWS])dnl
AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#undef inline
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
],[
int dummy=2*IPPROTO_ESP;
])
],[
ac_cv_header_winsock2_h="yes"
],[
ac_cv_header_winsock2_h="no"
])
])
if test "x$ac_cv_header_winsock2_h" = "xyes"; then
AC_DEFINE_UNQUOTED(HAVE_WINSOCK2_H, 1,
[Define to 1 if you have the winsock2.h header file.])
fi
])
dnl CURL_CHECK_HEADER_WS2TCPIP
dnl -------------------------------------------------
dnl Check for compilable and valid ws2tcpip.h header
AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [
AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#undef inline
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
],[
int dummy=2*IP_PKTINFO;
])
],[
ac_cv_header_ws2tcpip_h="yes"
],[
ac_cv_header_ws2tcpip_h="no"
])
])
if test "x$ac_cv_header_ws2tcpip_h" = "xyes"; then
AC_DEFINE_UNQUOTED(HAVE_WS2TCPIP_H, 1,
[Define to 1 if you have the ws2tcpip.h header file.])
fi
])
dnl CURL_CHECK_TYPE_SOCKLEN_T
dnl -------------------------------------------------
dnl Check for existing socklen_t type, and provide
dnl an equivalent type if socklen_t not available
AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [
AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl
AC_CHECK_TYPE([socklen_t], ,[
AC_CACHE_CHECK([for socklen_t equivalent],
[curl_cv_socklen_t_equiv], [
curl_cv_socklen_t_equiv="unknown"
for arg2 in "struct sockaddr" void; do
for t in int size_t unsigned long "unsigned long"; do
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#undef inline
#ifdef HAVE_WINDOWS_H
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#else
#ifdef HAVE_WINSOCK_H
#include <winsock.h>
#endif
#endif
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#endif
int getpeername (int, $arg2 *, $t *);
int getsockname (int, $arg2 *, $t *);
int bind (int, $arg2 *, $t);
int accept (int, $arg2 *, $t *);
],[
$t len=0;
getpeername(0,0,&len);
getsockname(0,0,&len);
bind(0,0,len);
accept(0,0,&len);
])
],[
curl_cv_socklen_t_equiv="$t"
break 2
])
done
done
])
if test "$curl_cv_socklen_t_equiv" = "unknown"; then
AC_MSG_ERROR([Cannot find a type to use in place of socklen_t])
else
AC_DEFINE_UNQUOTED(socklen_t, $curl_cv_socklen_t_equiv,
[type to use in place of socklen_t if not defined])
fi
],[
#ifdef HAVE_WINDOWS_H
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#endif
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#endif
])
])
dnl CURL_FUNC_GETNAMEINFO_ARGTYPES
dnl -------------------------------------------------
dnl Check the type to be passed to five of the arguments
dnl of getnameinfo function, and define those types 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_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_CACHE_CHECK([types of arguments for getnameinfo],
[curl_cv_func_getnameinfo_args], [
curl_cv_func_getnameinfo_args="unknown"
for gni_arg1 in 'struct sockaddr *' 'void *'; do
for gni_arg2 in 'socklen_t' 'size_t' 'int'; do
for gni_arg46 in 'size_t' 'int' 'socklen_t'; do
for gni_arg7 in 'int' 'unsigned int'; do
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([
#undef inline
#ifdef HAVE_WINDOWS_H
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
#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
extern int getnameinfo($gni_arg1, $gni_arg2,
char *, $gni_arg46,
char *, $gni_arg46,
$gni_arg7);
],[
$gni_arg1 sa=0;
$gni_arg2 salen=0;
char *host=0;
$gni_arg46 hostlen=0;
char *serv=0;
$gni_arg46 servlen=0;
$gni_arg7 flags=0;
getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
])
],[
curl_cv_func_getnameinfo_args="$gni_arg1,$gni_arg2,$gni_arg46,$gni_arg7"
break 4
])
done
done
done
done
])
if test "$curl_cv_func_getnameinfo_args" = "unknown"; then
AC_MSG_ERROR([Cannot find proper types to use for getnameinfo args])
else
gni_prev_IFS=$IFS; IFS=','
set dummy `echo "$curl_cv_func_getnameinfo_args" | sed 's/\*/\*/g'`
IFS=$gni_prev_IFS
shift
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG1, $[1],
[Define to the type of arg 1 for `getnameinfo'.])
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG2, $[2],
[Define to the type of arg 2 for `getnameinfo'.])
AC_DEFINE_UNQUOTED(GETNAMEINFO_TYPE_ARG46, $[3],
[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'.])
fi
])
dnl Check for how to set a socket to non-blocking state. There seems to exist
dnl four known different ways, with the one used almost everywhere being POSIX
dnl and XPG3, while the other different ways for different systems (old BSD,

View File

@ -59,6 +59,18 @@ AC_HELP_STRING([--disable-debug],[Disable debug options]),
AC_PROG_LIBTOOL
dnl **********************************************************************
dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
dnl and ws2tcpip.h take precedence over any other further checks which
dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
dnl this specific header files.
dnl **********************************************************************
CURL_CHECK_HEADER_WINDOWS
CURL_CHECK_HEADER_WINSOCK
CURL_CHECK_HEADER_WINSOCK2
CURL_CHECK_HEADER_WS2TCPIP
dnl check for a few basic system headers we need
AC_CHECK_HEADERS(
sys/types.h \
@ -67,8 +79,6 @@ AC_CHECK_HEADERS(
sys/socket.h \
sys/ioctl.h \
netdb.h \
winsock2.h \
ws2tcpip.h \
netinet/in.h \
net/if.h \
arpa/nameser.h \
@ -95,19 +105,8 @@ dnl *Sigh* these are needed in order for net/if.h to get properly detected.
]
)
AC_CHECK_TYPE(socklen_t, ,
AC_DEFINE(socklen_t, int, [the length of a socket address]),
[
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
])
# Check for socklen_t or equivalent
CURL_CHECK_TYPE_SOCKLEN_T
dnl check for AF_INET6
CARES_CHECK_CONSTANT(
@ -228,6 +227,26 @@ AC_CHECK_MEMBER(struct addrinfo.ai_flags,
]
)
AC_CHECK_FUNCS( getnameinfo \
bitncmp \
if_indextoname,
dnl if found
[],
dnl if not found, $ac_func is the name we check for
func="$ac_func"
AC_MSG_CHECKING([deeper for $func])
AC_TRY_LINK( [],
[ $func ();],
AC_MSG_RESULT(yes!)
eval "ac_cv_func_$func=yes"
def=`echo "HAVE_$func" | tr 'a-z' 'A-Z'`
AC_DEFINE_UNQUOTED($def, 1, [If you have $func]),
AC_MSG_RESULT(but still no)
)
)
dnl check for inet_pton
AC_CHECK_FUNCS(inet_pton)
dnl Some systems have it, but not IPv6
@ -362,7 +381,13 @@ AC_CHECK_SIZEOF(struct in_addr, ,
]
)
AC_CHECK_FUNCS([bitncmp if_indextoname])
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 God bless non-standardized functions! We need to see which getservbyport_r variant is available
CARES_CHECK_GETSERVBYPORT_R

View File

@ -1396,8 +1396,9 @@ AC_HEADER_STDC
dnl **********************************************************************
dnl Make sure that our checks for headers windows.h winsock.h winsock2.h
dnl and ws2tcpip.h take precedence over any other further check which
dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS.
dnl and ws2tcpip.h take precedence over any other further checks which
dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS for
dnl this specific header files.
dnl **********************************************************************
CURL_CHECK_HEADER_WINDOWS
@ -1432,8 +1433,6 @@ AC_CHECK_HEADERS(
fcntl.h \
dlfcn.h \
alloca.h \
winsock.h \
winsock2.h \
time.h \
io.h \
pwd.h \
@ -1503,11 +1502,9 @@ fi
AC_CHECK_TYPE(ssize_t, ,
AC_DEFINE(ssize_t, int, [the signed version of size_t]))
# Experimental check
# Check for socklen_t or equivalent
CURL_CHECK_TYPE_SOCKLEN_T
# TYPE_SOCKLEN_T
TYPE_IN_ADDR_T
TYPE_SOCKADDR_STORAGE
@ -1628,19 +1625,12 @@ AC_CHECK_DECL(inet_pton, ,
]
)
if test "$ac_cv_func_getnameinfo" = "yes"; then
AC_CHECK_DECL(getnameinfo, ,
AC_DEFINE(HAVE_NO_GETNAMEINFO_PROTO, 1,
[Defined if no getnameinfo() prototype available]),
[
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
])
CURL_FUNC_GETNAMEINFO_ARGTYPES
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
AC_MSG_CHECKING([if we are Mac OS X (to disable poll)])