summaryrefslogtreecommitdiff
path: root/m4/cares-functions.m4
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2011-07-29 18:25:34 +0200
committerYang Tse <yangsita@gmail.com>2011-07-29 18:25:34 +0200
commit5f2a3b0e48f26d24cb1fefea0dccb92d417dcbf7 (patch)
tree07bde733d60c8236f48a9abe8e74fb459e225c43 /m4/cares-functions.m4
parent08e721e0041db08eba05d90f23bc1bbc12662926 (diff)
downloadc-ares-5f2a3b0e48f26d24cb1fefea0dccb92d417dcbf7.tar.gz
c-ares-5f2a3b0e48f26d24cb1fefea0dccb92d417dcbf7.tar.bz2
c-ares-5f2a3b0e48f26d24cb1fefea0dccb92d417dcbf7.zip
configure: additional flag checks for fcntl() and socket()
Diffstat (limited to 'm4/cares-functions.m4')
-rw-r--r--m4/cares-functions.m4202
1 files changed, 201 insertions, 1 deletions
diff --git a/m4/cares-functions.m4 b/m4/cares-functions.m4
index bddd9b4..050a717 100644
--- a/m4/cares-functions.m4
+++ b/m4/cares-functions.m4
@@ -15,7 +15,7 @@
#***************************************************************************
# File version for 'aclocal' use. Keep it a single number.
-# serial 41
+# serial 42
dnl CARES_INCLUDES_ARPA_INET
@@ -699,6 +699,7 @@ AC_DEFUN([CARES_CHECK_FUNC_FCNTL], [
AC_DEFINE_UNQUOTED(HAVE_FCNTL, 1,
[Define to 1 if you have the fcntl function.])
ac_cv_func_fcntl="yes"
+ CARES_CHECK_FUNC_FCNTL_FD_CLOEXEC
CARES_CHECK_FUNC_FCNTL_O_NONBLOCK
else
AC_MSG_RESULT([no])
@@ -707,6 +708,69 @@ AC_DEFUN([CARES_CHECK_FUNC_FCNTL], [
])
+dnl CARES_CHECK_FUNC_FCNTL_FD_CLOEXEC
+dnl -------------------------------------------------
+dnl Verify if fcntl with status flag FD_CLOEXEC is
+dnl available, can be compiled, and seems to work. If
+dnl all of these are true, then HAVE_FCNTL_FD_CLOEXEC
+dnl will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_FCNTL_FD_CLOEXEC], [
+ #
+ tst_compi_fcntl_fd_cloexec="unknown"
+ tst_allow_fcntl_fd_cloexec="unknown"
+ #
+ case $host_os in
+ some_systems)
+ dnl FD_CLOEXEC does not work on these platforms
+ cares_disallow_fcntl_fd_cloexec="yes"
+ ;;
+ esac
+ #
+ if test "$ac_cv_func_fcntl" = "yes"; then
+ AC_MSG_CHECKING([if fcntl FD_CLOEXEC is compilable])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([[
+ $cares_includes_fcntl
+ ]],[[
+ int flags = 0;
+ if(0 != fcntl(0, F_SETFD, flags | FD_CLOEXEC))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_fcntl_fd_cloexec="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_fcntl_fd_cloexec="no"
+ ])
+ fi
+ #
+ if test "$tst_compi_fcntl_fd_cloexec" = "yes"; then
+ AC_MSG_CHECKING([if fcntl FD_CLOEXEC usage allowed])
+ if test "x$cares_disallow_fcntl_fd_cloexec" != "xyes"; then
+ AC_MSG_RESULT([yes])
+ tst_allow_fcntl_fd_cloexec="yes"
+ else
+ AC_MSG_RESULT([no])
+ tst_allow_fcntl_fd_cloexec="no"
+ fi
+ fi
+ #
+ AC_MSG_CHECKING([if fcntl FD_CLOEXEC might be used])
+ if test "$tst_compi_fcntl_fd_cloexec" = "yes" &&
+ test "$tst_allow_fcntl_fd_cloexec" = "yes"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE_UNQUOTED(HAVE_FCNTL_FD_CLOEXEC, 1,
+ [Define to 1 if you have a working fcntl FD_CLOEXEC function.])
+ ac_cv_func_fcntl_fd_cloexec="yes"
+ else
+ AC_MSG_RESULT([no])
+ ac_cv_func_fcntl_fd_cloexec="no"
+ fi
+])
+
+
dnl CARES_CHECK_FUNC_FCNTL_O_NONBLOCK
dnl -------------------------------------------------
dnl Verify if fcntl with status flag O_NONBLOCK is
@@ -2858,6 +2922,8 @@ AC_DEFUN([CARES_CHECK_FUNC_SOCKET], [
AC_DEFINE_UNQUOTED(HAVE_SOCKET, 1,
[Define to 1 if you have the socket function.])
ac_cv_func_socket="yes"
+ CARES_CHECK_FUNC_SOCKET_SOCK_CLOEXEC
+ CARES_CHECK_FUNC_SOCKET_SOCK_NONBLOCK
else
AC_MSG_RESULT([no])
ac_cv_func_socket="no"
@@ -2865,6 +2931,140 @@ AC_DEFUN([CARES_CHECK_FUNC_SOCKET], [
])
+dnl CARES_CHECK_FUNC_SOCKET_SOCK_CLOEXEC
+dnl -------------------------------------------------
+dnl Verify if socket with type flag SOCK_CLOEXEC is
+dnl available, can be compiled, and seems to work. If
+dnl all of these are true, then HAVE_SOCKET_SOCK_CLOEXEC
+dnl will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_SOCKET_SOCK_CLOEXEC], [
+ AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
+ AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
+ AC_REQUIRE([CARES_INCLUDES_SOCKET])dnl
+ #
+ tst_compi_socket_sock_cloexec="unknown"
+ tst_allow_socket_sock_cloexec="unknown"
+ #
+ case $host_os in
+ some_systems)
+ dnl socket SOCK_CLOEXEC does not work
+ cares_disallow_socket_sock_cloexec="yes"
+ ;;
+ esac
+ #
+ if test "$ac_cv_func_socket" = "yes"; then
+ AC_MSG_CHECKING([if socket SOCK_CLOEXEC is compilable])
+ AC_COMPILE_IFELSE([
+ $cares_includes_winsock2
+ $cares_includes_sys_socket
+ $cares_includes_socket
+ ]],[[
+ int flags = 0;
+ if(0 != socket(0, flags | SOCK_CLOEXEC, 0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_socket_sock_cloexec="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_socket_sock_cloexec="no"
+ ])
+ fi
+ #
+ if test "$tst_compi_socket_sock_cloexec" = "yes"; then
+ AC_MSG_CHECKING([if socket SOCK_CLOEXEC usage allowed])
+ if test "x$cares_disallow_socket_sock_cloexec" != "xyes"; then
+ AC_MSG_RESULT([yes])
+ tst_allow_socket_sock_cloexec="yes"
+ else
+ AC_MSG_RESULT([no])
+ tst_allow_socket_sock_cloexec="no"
+ fi
+ fi
+ #
+ AC_MSG_CHECKING([if socket SOCK_CLOEXEC might be used])
+ if test "$tst_compi_socket_sock_cloexec" = "yes" &&
+ test "$tst_allow_socket_sock_cloexec" = "yes"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE_UNQUOTED(HAVE_SOCKET_SOCK_CLOEXEC, 1,
+ [Define to 1 if you have a working socket SOCK_CLOEXEC function.])
+ ac_cv_func_socket_sock_cloexec="yes"
+ else
+ AC_MSG_RESULT([no])
+ ac_cv_func_socket_sock_cloexec="no"
+ fi
+])
+
+
+dnl CARES_CHECK_FUNC_SOCKET_SOCK_NONBLOCK
+dnl -------------------------------------------------
+dnl Verify if socket with type flag SOCK_NONBLOCK is
+dnl available, can be compiled, and seems to work. If
+dnl all of these are true, then HAVE_SOCKET_SOCK_NONBLOCK
+dnl will be defined.
+
+AC_DEFUN([CARES_CHECK_FUNC_SOCKET_SOCK_NONBLOCK], [
+ AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl
+ AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl
+ AC_REQUIRE([CARES_INCLUDES_SOCKET])dnl
+ #
+ tst_compi_socket_sock_nonblock="unknown"
+ tst_allow_socket_sock_nonblock="unknown"
+ #
+ case $host_os in
+ some_systems)
+ dnl socket SOCK_NONBLOCK does not work
+ cares_disallow_socket_sock_nonblock="yes"
+ ;;
+ esac
+ #
+ if test "$ac_cv_func_socket" = "yes"; then
+ AC_MSG_CHECKING([if socket SOCK_NONBLOCK is compilable])
+ AC_COMPILE_IFELSE([
+ $cares_includes_winsock2
+ $cares_includes_sys_socket
+ $cares_includes_socket
+ ]],[[
+ int flags = 0;
+ if(0 != socket(0, flags | SOCK_NONBLOCK, 0))
+ return 1;
+ ]])
+ ],[
+ AC_MSG_RESULT([yes])
+ tst_compi_socket_sock_nonblock="yes"
+ ],[
+ AC_MSG_RESULT([no])
+ tst_compi_socket_sock_nonblock="no"
+ ])
+ fi
+ #
+ if test "$tst_compi_socket_sock_nonblock" = "yes"; then
+ AC_MSG_CHECKING([if socket SOCK_NONBLOCK usage allowed])
+ if test "x$cares_disallow_socket_sock_nonblock" != "xyes"; then
+ AC_MSG_RESULT([yes])
+ tst_allow_socket_sock_nonblock="yes"
+ else
+ AC_MSG_RESULT([no])
+ tst_allow_socket_sock_nonblock="no"
+ fi
+ fi
+ #
+ AC_MSG_CHECKING([if socket SOCK_NONBLOCK might be used])
+ if test "$tst_compi_socket_sock_nonblock" = "yes" &&
+ test "$tst_allow_socket_sock_nonblock" = "yes"; then
+ AC_MSG_RESULT([yes])
+ AC_DEFINE_UNQUOTED(HAVE_SOCKET_SOCK_NONBLOCK, 1,
+ [Define to 1 if you have a working socket SOCK_NONBLOCK function.])
+ ac_cv_func_socket_sock_nonblock="yes"
+ else
+ AC_MSG_RESULT([no])
+ ac_cv_func_socket_sock_nonblock="no"
+ fi
+])
+
+
dnl CARES_CHECK_FUNC_STRCASECMP
dnl -------------------------------------------------
dnl Verify if strcasecmp is available, prototyped, and