diff options
author | Yang Tse <yangsita@gmail.com> | 2009-02-13 05:49:58 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2009-02-13 05:49:58 +0000 |
commit | debe0b561dd727a9838ca392b1b616f0c0bbe3ad (patch) | |
tree | b826fd28d299c5606df75efa9d2456920343d56d /m4 | |
parent | 9ddc7ad038b9e003596e61de1b1352798fb10dbd (diff) |
check for poll() as it is done for other functions
Diffstat (limited to 'm4')
-rw-r--r-- | m4/curl-functions.m4 | 152 |
1 files changed, 151 insertions, 1 deletions
diff --git a/m4/curl-functions.m4 b/m4/curl-functions.m4 index 4935879bc..b0489b8a4 100644 --- a/m4/curl-functions.m4 +++ b/m4/curl-functions.m4 @@ -22,7 +22,7 @@ #*************************************************************************** # File version for 'aclocal' use. Keep it a single number. -# serial 43 +# serial 45 dnl CURL_INCLUDES_ARPA_INET @@ -124,6 +124,30 @@ curl_includes_netdb="\ ]) +dnl CURL_INCLUDES_POLL +dnl ------------------------------------------------- +dnl Set up variable with list of headers that must be +dnl included when poll.h is to be included. + +AC_DEFUN([CURL_INCLUDES_POLL], [ +curl_includes_poll="\ +/* includes start */ +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_POLL_H +# include <poll.h> +#endif +#ifdef HAVE_SYS_POLL_H +# include <sys/poll.h> +#endif +/* includes end */" + AC_CHECK_HEADERS( + sys/types.h poll.h sys/poll.h, + [], [], [$curl_includes_poll]) +]) + + dnl CURL_INCLUDES_SETJMP dnl ------------------------------------------------- dnl Set up variable with list of headers that must be @@ -3108,6 +3132,132 @@ AC_DEFUN([CURL_CHECK_FUNC_LOCALTIME_R], [ ]) +dnl CURL_CHECK_FUNC_POLL +dnl ------------------------------------------------- +dnl Verify if poll is available, prototyped, can +dnl be compiled and seems to work. If all of these are +dnl true, and usage has not been previously disallowed +dnl with shell variable curl_disallow_poll, then +dnl HAVE_POLL will be defined. + +AC_DEFUN([CURL_CHECK_FUNC_POLL], [ + AC_REQUIRE([CURL_INCLUDES_STDLIB])dnl + AC_REQUIRE([CURL_INCLUDES_POLL])dnl + # + tst_links_poll="unknown" + tst_proto_poll="unknown" + tst_compi_poll="unknown" + tst_works_poll="unknown" + tst_allow_poll="unknown" + # + case $host_os in + darwin*) + dnl poll does not work on this platform + curl_disallow_poll="yes" + ;; + esac + # + AC_MSG_CHECKING([if poll can be linked]) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_poll + ]],[[ + if(0 != poll(0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_links_poll="yes" + ],[ + AC_MSG_RESULT([no]) + tst_links_poll="no" + ]) + # + if test "$tst_links_poll" = "yes"; then + AC_MSG_CHECKING([if poll is prototyped]) + AC_EGREP_CPP([poll],[ + $curl_includes_poll + ],[ + AC_MSG_RESULT([yes]) + tst_proto_poll="yes" + ],[ + AC_MSG_RESULT([no]) + tst_proto_poll="no" + ]) + fi + # + if test "$tst_proto_poll" = "yes"; then + AC_MSG_CHECKING([if poll is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_poll + ]],[[ + if(0 != poll(0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_poll="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_poll="no" + ]) + fi + # + dnl only do runtime verification when not cross-compiling + if test "x$cross_compiling" != "xyes" && + test "$tst_compi_poll" = "yes"; then + AC_MSG_CHECKING([if poll seems to work]) + AC_RUN_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_stdlib + $curl_includes_poll + ]],[[ + if(0 != poll(0, 0, 10)) + exit(1); /* fail */ + else + exit(0); + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_works_poll="yes" + ],[ + AC_MSG_RESULT([no]) + tst_works_poll="no" + ]) + fi + # + if test "$tst_compi_poll" = "yes" && + test "$tst_works_poll" != "no"; then + AC_MSG_CHECKING([if poll usage allowed]) + if test "x$curl_disallow_poll" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_poll="yes" + else + AC_MSG_RESULT([no]) + tst_allow_poll="no" + fi + fi + # + AC_MSG_CHECKING([if poll might be used]) + if test "$tst_links_poll" = "yes" && + test "$tst_proto_poll" = "yes" && + test "$tst_compi_poll" = "yes" && + test "$tst_allow_poll" = "yes" && + test "$tst_works_poll" != "no"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_POLL, 1, + [Define to 1 if you have a working poll function.]) + AC_DEFINE_UNQUOTED(HAVE_POLL_FINE, 1, + [If you have a fine poll]) + ac_cv_func_poll="yes" + else + AC_MSG_RESULT([no]) + ac_cv_func_poll="no" + fi +]) + + dnl CURL_CHECK_FUNC_SETSOCKOPT dnl ------------------------------------------------- dnl Verify if setsockopt is available, prototyped, and |