rearrange to allow internal/private use of ares_writev to any system

that lacks the writev function.
This commit is contained in:
Yang Tse
2008-09-16 16:42:48 +00:00
parent ee5f13cb6b
commit aa41743ebd
12 changed files with 351 additions and 44 deletions

View File

@@ -112,6 +112,27 @@ curl_includes_string="\
])
dnl CURL_INCLUDES_SYS_UIO
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
dnl included when sys/uio.h is to be included.
AC_DEFUN([CURL_INCLUDES_SYS_UIO], [
curl_includes_sys_uio="\
/* includes start */
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_UIO_H
# include <sys/uio.h>
#endif
/* includes end */"
AC_CHECK_HEADERS(
sys/types.h sys/uio.h,
[], [], [$curl_includes_sys_uio])
])
dnl CURL_INCLUDES_TIME
dnl -------------------------------------------------
dnl Set up variable with list of headers that must be
@@ -1722,3 +1743,86 @@ AC_DEFUN([CURL_CHECK_FUNC_STRTOLL], [
])
dnl CURL_CHECK_FUNC_WRITEV
dnl -------------------------------------------------
dnl Verify if writev is available, prototyped, and
dnl can be compiled. If all of these are true, and
dnl usage has not been previously disallowed with
dnl shell variable curl_disallow_writev, then
dnl HAVE_WRITEV will be defined.
AC_DEFUN([CURL_CHECK_FUNC_WRITEV], [
AC_REQUIRE([CURL_INCLUDES_SYS_UIO])dnl
#
tst_links_writev="unknown"
tst_proto_writev="unknown"
tst_compi_writev="unknown"
tst_allow_writev="unknown"
#
AC_MSG_CHECKING([if writev can be linked])
AC_LINK_IFELSE([
AC_LANG_FUNC_LINK_TRY([writev])
],[
AC_MSG_RESULT([yes])
tst_links_writev="yes"
],[
AC_MSG_RESULT([no])
tst_links_writev="no"
])
#
if test "$tst_links_writev" = "yes"; then
AC_MSG_CHECKING([if writev is prototyped])
AC_EGREP_CPP([writev],[
$curl_includes_sys_uio
],[
AC_MSG_RESULT([yes])
tst_proto_writev="yes"
],[
AC_MSG_RESULT([no])
tst_proto_writev="no"
])
fi
#
if test "$tst_proto_writev" = "yes"; then
AC_MSG_CHECKING([if writev is compilable])
AC_COMPILE_IFELSE([
AC_LANG_PROGRAM([[
$curl_includes_sys_uio
]],[[
if(0 != writev(0, 0, 0))
return 1;
]])
],[
AC_MSG_RESULT([yes])
tst_compi_writev="yes"
],[
AC_MSG_RESULT([no])
tst_compi_writev="no"
])
fi
#
if test "$tst_compi_writev" = "yes"; then
AC_MSG_CHECKING([if writev usage allowed])
if test "x$curl_disallow_writev" != "xyes"; then
AC_MSG_RESULT([yes])
tst_allow_writev="yes"
else
AC_MSG_RESULT([no])
tst_allow_writev="no"
fi
fi
#
AC_MSG_CHECKING([if writev might be used])
if test "$tst_links_writev" = "yes" &&
test "$tst_proto_writev" = "yes" &&
test "$tst_compi_writev" = "yes" &&
test "$tst_allow_writev" = "yes"; then
AC_MSG_RESULT([yes])
AC_DEFINE_UNQUOTED(HAVE_WRITEV, 1,
[Define to 1 if you have the writev function.])
ac_cv_func_writev="yes"
else
AC_MSG_RESULT([no])
ac_cv_func_writev="no"
fi
])