diff options
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | acinclude.m4 | 148 | ||||
-rw-r--r-- | ares/Makefile.dj | 1 | ||||
-rw-r--r-- | ares/Makefile.netware | 3 | ||||
-rw-r--r-- | ares/acinclude.m4 | 148 | ||||
-rw-r--r-- | ares/ares_process.c | 53 | ||||
-rw-r--r-- | ares/config-win32.h | 5 | ||||
-rw-r--r-- | ares/configure.ac | 10 | ||||
-rw-r--r-- | ares/m4/cares-confopts.m4 | 74 | ||||
-rw-r--r-- | ares/m4/cares-functions.m4 | 786 | ||||
-rw-r--r-- | configure.ac | 33 | ||||
-rw-r--r-- | lib/Makefile.netware | 3 | ||||
-rw-r--r-- | lib/config-amigaos.h | 3 | ||||
-rw-r--r-- | lib/config-mac.h | 3 | ||||
-rw-r--r-- | lib/config-os400.h | 6 | ||||
-rw-r--r-- | lib/config-riscos.h | 6 | ||||
-rw-r--r-- | lib/config-symbian.h | 43 | ||||
-rw-r--r-- | lib/config-tpf.h | 44 | ||||
-rw-r--r-- | lib/config-win32.h | 5 | ||||
-rw-r--r-- | lib/config-win32ce.h | 5 | ||||
-rw-r--r-- | lib/config.dos | 4 | ||||
-rw-r--r-- | lib/connect.c | 55 | ||||
-rw-r--r-- | m4/curl-confopts.m4 | 73 | ||||
-rw-r--r-- | m4/curl-functions.m4 | 786 | ||||
-rw-r--r-- | packages/vms/config-vms.h | 8 | ||||
-rw-r--r-- | src/Makefile.netware | 3 | ||||
-rw-r--r-- | src/config-riscos.h | 5 | ||||
-rw-r--r-- | src/config-win32.h | 12 |
28 files changed, 1891 insertions, 438 deletions
@@ -6,6 +6,10 @@ Changelog +Yang Tse (13 Nov 2008) +- Refactored configure script detection of functions used to set sockets into + non-blocking mode, and decouple function detection from function capability. + Version 7.19.2 (13 November 2008) Michal Marek (13 Nov 2008) diff --git a/acinclude.m4 b/acinclude.m4 index 93b47c819..bfe5b1890 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1965,154 +1965,6 @@ AC_DEFUN([TYPE_SIG_ATOMIC_T], [ ]) -dnl CURL_CHECK_NONBLOCKING_SOCKET -dnl ------------------------------------------------- -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, -dnl Windows and Amiga). -dnl -dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the -dnl O_NONBLOCK define is found but does not work. This condition is attempted -dnl to get caught in this script by using an excessive number of #ifdefs... - -AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [ - AC_MSG_CHECKING([non-blocking sockets style]) - nonblock="unknown" - # - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ -/* headers for O_NONBLOCK test */ -#include <sys/types.h> -#include <unistd.h> -#include <fcntl.h> -/* */ -#if defined(sun) || defined(__sun__) || \ - defined(__SUNPRO_C) || defined(__SUNPRO_CC) -# if defined(__SVR4) || defined(__srv4__) -# define PLATFORM_SOLARIS -# else -# define PLATFORM_SUNOS4 -# endif -#endif -#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41) -# define PLATFORM_AIX_V3 -#endif -/* */ -#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__) -#error "O_NONBLOCK does not work on this platform" -#endif - ]],[[ - /* O_NONBLOCK source test */ - int socket; - int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK); - ]]) - ],[ - dnl the O_NONBLOCK test was fine - nonblock="O_NONBLOCK" - AC_DEFINE(HAVE_O_NONBLOCK, 1, - [use O_NONBLOCK for non-blocking sockets]) - ]) - # - if test "$nonblock" = "unknown"; then - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ -/* headers for FIONBIO test */ -#include <unistd.h> -#include <stropts.h> - ]],[[ - /* FIONBIO source test (old-style unix) */ - int socket; - int flags = ioctl(socket, FIONBIO, &flags); - ]]) - ],[ - dnl FIONBIO test was good - nonblock="FIONBIO" - AC_DEFINE(HAVE_FIONBIO, 1, - [use FIONBIO for non-blocking sockets]) - ]) - fi - # - if test "$nonblock" = "unknown"; then - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ -/* headers for ioctlsocket test (Windows) */ -#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> -#else -#ifdef HAVE_WINSOCK_H -#include <winsock.h> -#endif -#endif -#endif - ]],[[ - /* ioctlsocket source code (Windows) */ - SOCKET sd; - unsigned long flags = 0; - sd = socket(0, 0, 0); - ioctlsocket(sd, FIONBIO, &flags); - ]]) - ],[ - dnl ioctlsocket test was good - nonblock="ioctlsocket" - AC_DEFINE(HAVE_IOCTLSOCKET, 1, - [use ioctlsocket() for non-blocking sockets]) - ]) - fi - # - if test "$nonblock" = "unknown"; then - AC_LINK_IFELSE([ - AC_LANG_PROGRAM([[ -/* headers for IoctlSocket test (Amiga?) */ -#include <sys/ioctl.h> - ]],[[ - /* IoctlSocket source code (Amiga?) */ - int socket; - int flags = IoctlSocket(socket, FIONBIO, (long)1); - ]]) - ],[ - dnl Ioctlsocket test was good - nonblock="IoctlSocket" - AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, - [use Ioctlsocket() for non-blocking sockets]) - ]) - fi - # - if test "$nonblock" = "unknown"; then - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ -/* headers for SO_NONBLOCK test (BeOS) */ -#include <socket.h> - ]],[[ - /* SO_NONBLOCK source code (BeOS) */ - long b = 1; - int socket; - int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); - ]]) - ],[ - dnl the SO_NONBLOCK test was good - nonblock="SO_NONBLOCK" - AC_DEFINE(HAVE_SO_NONBLOCK, 1, - [use SO_NONBLOCK for non-blocking sockets]) - ]) - fi - # - AC_MSG_RESULT($nonblock) - # - if test "$nonblock" = "unknown"; then - AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, - [disabled non-blocking sockets]) - AC_MSG_WARN([non-block sockets disabled]) - fi -]) - - dnl TYPE_IN_ADDR_T dnl ------------------------------------------------- dnl Check for in_addr_t: it is used to receive the return code of inet_addr() diff --git a/ares/Makefile.dj b/ares/Makefile.dj index 7ee6e0447..26a32fbf1 100644 --- a/ares/Makefile.dj +++ b/ares/Makefile.dj @@ -11,6 +11,7 @@ include ../packages/DOS/common.dj include Makefile.inc CFLAGS += -DWATT32 -DHAVE_AF_INET6 -DHAVE_PF_INET6 -DHAVE_IOCTLSOCKET \ + -DHAVE_IOCTLSOCKET_FIONBIO \ -DHAVE_STRUCT_IN6_ADDR -DHAVE_SOCKADDR_IN6_SIN6_SCOPE_ID \ -DHAVE_SYS_TIME_H -DHAVE_STRUCT_SOCKADDR_IN6 -DHAVE_STRUCT_ADDRINFO \ -DHAVE_SIGNAL_H -DHAVE_SIG_ATOMIC_T -DRETSIGTYPE='void' \ diff --git a/ares/Makefile.netware b/ares/Makefile.netware index 9ed7ba0c9..0a908f055 100644 --- a/ares/Makefile.netware +++ b/ares/Makefile.netware @@ -350,12 +350,13 @@ endif @echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@ @echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@ @echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@ - @echo $(DL)#define HAVE_FIONBIO 1$(DL) >> $@ @echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@ @echo $(DL)#define HAVE_GETHOSTBYNAME 1$(DL) >> $@ @echo $(DL)#define HAVE_GETPROTOBYNAME 1$(DL) >> $@ @echo $(DL)#define HAVE_GMTIME_R 1$(DL) >> $@ @echo $(DL)#define HAVE_INET_ADDR 1$(DL) >> $@ + @echo $(DL)#define HAVE_IOCTL 1$(DL) >> $@ + @echo $(DL)#define HAVE_IOCTL_FIONBIO 1$(DL) >> $@ @echo $(DL)#define HAVE_LL 1$(DL) >> $@ @echo $(DL)#define HAVE_LOCALTIME_R 1$(DL) >> $@ @echo $(DL)#define HAVE_MALLOC_H 1$(DL) >> $@ diff --git a/ares/acinclude.m4 b/ares/acinclude.m4 index abe10d78f..879643dc4 100644 --- a/ares/acinclude.m4 +++ b/ares/acinclude.m4 @@ -1433,154 +1433,6 @@ AC_DEFUN([TYPE_SIG_ATOMIC_T], [ ]) -dnl CURL_CHECK_NONBLOCKING_SOCKET -dnl ------------------------------------------------- -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, -dnl Windows and Amiga). -dnl -dnl There are two known platforms (AIX 3.x and SunOS 4.1.x) where the -dnl O_NONBLOCK define is found but does not work. This condition is attempted -dnl to get caught in this script by using an excessive number of #ifdefs... - -AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [ - AC_MSG_CHECKING([non-blocking sockets style]) - nonblock="unknown" - # - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ -/* headers for O_NONBLOCK test */ -#include <sys/types.h> -#include <unistd.h> -#include <fcntl.h> -/* */ -#if defined(sun) || defined(__sun__) || \ - defined(__SUNPRO_C) || defined(__SUNPRO_CC) -# if defined(__SVR4) || defined(__srv4__) -# define PLATFORM_SOLARIS -# else -# define PLATFORM_SUNOS4 -# endif -#endif -#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41) -# define PLATFORM_AIX_V3 -#endif -/* */ -#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__) -#error "O_NONBLOCK does not work on this platform" -#endif - ]],[[ - /* O_NONBLOCK source test */ - int socket; - int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK); - ]]) - ],[ - dnl the O_NONBLOCK test was fine - nonblock="O_NONBLOCK" - AC_DEFINE(HAVE_O_NONBLOCK, 1, - [use O_NONBLOCK for non-blocking sockets]) - ]) - # - if test "$nonblock" = "unknown"; then - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ -/* headers for FIONBIO test */ -#include <unistd.h> -#include <stropts.h> - ]],[[ - /* FIONBIO source test (old-style unix) */ - int socket; - int flags = ioctl(socket, FIONBIO, &flags); - ]]) - ],[ - dnl FIONBIO test was good - nonblock="FIONBIO" - AC_DEFINE(HAVE_FIONBIO, 1, - [use FIONBIO for non-blocking sockets]) - ]) - fi - # - if test "$nonblock" = "unknown"; then - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ -/* headers for ioctlsocket test (Windows) */ -#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> -#else -#ifdef HAVE_WINSOCK_H -#include <winsock.h> -#endif -#endif -#endif - ]],[[ - /* ioctlsocket source code (Windows) */ - SOCKET sd; - unsigned long flags = 0; - sd = socket(0, 0, 0); - ioctlsocket(sd, FIONBIO, &flags); - ]]) - ],[ - dnl ioctlsocket test was good - nonblock="ioctlsocket" - AC_DEFINE(HAVE_IOCTLSOCKET, 1, - [use ioctlsocket() for non-blocking sockets]) - ]) - fi - # - if test "$nonblock" = "unknown"; then - AC_LINK_IFELSE([ - AC_LANG_PROGRAM([[ -/* headers for IoctlSocket test (Amiga?) */ -#include <sys/ioctl.h> - ]],[[ - /* IoctlSocket source code (Amiga?) */ - int socket; - int flags = IoctlSocket(socket, FIONBIO, (long)1); - ]]) - ],[ - dnl Ioctlsocket test was good - nonblock="IoctlSocket" - AC_DEFINE(HAVE_IOCTLSOCKET_CASE, 1, - [use Ioctlsocket() for non-blocking sockets]) - ]) - fi - # - if test "$nonblock" = "unknown"; then - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ -/* headers for SO_NONBLOCK test (BeOS) */ -#include <socket.h> - ]],[[ - /* SO_NONBLOCK source code (BeOS) */ - long b = 1; - int socket; - int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); - ]]) - ],[ - dnl the SO_NONBLOCK test was good - nonblock="SO_NONBLOCK" - AC_DEFINE(HAVE_SO_NONBLOCK, 1, - [use SO_NONBLOCK for non-blocking sockets]) - ]) - fi - # - AC_MSG_RESULT($nonblock) - # - if test "$nonblock" = "unknown"; then - AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, - [disabled non-blocking sockets]) - AC_MSG_WARN([non-block sockets disabled]) - fi -]) - - dnl TYPE_IN_ADDR_T dnl ------------------------------------------------- dnl Check for in_addr_t: it is used to receive the return code of inet_addr() diff --git a/ares/ares_process.c b/ares/ares_process.c index b7f375e19..05341aa64 100644 --- a/ares/ares_process.c +++ b/ares/ares_process.c @@ -805,68 +805,51 @@ void ares__send_query(ares_channel channel, struct query *query, static int setsocknonblock(ares_socket_t sockfd, /* operate on this */ int nonblock /* TRUE or FALSE */) { -#undef SETBLOCK -#define SETBLOCK 0 -#ifdef HAVE_O_NONBLOCK +#if defined(USE_BLOCKING_SOCKETS) + + return 0; /* returns success */ + +#elif defined(HAVE_FCNTL_O_NONBLOCK) + /* most recent unix versions */ int flags; - flags = fcntl(sockfd, F_GETFL, 0); if (FALSE != nonblock) return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); else return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK)); -#undef SETBLOCK -#define SETBLOCK 1 -#endif -#if defined(HAVE_FIONBIO) && (SETBLOCK == 0) +#elif defined(HAVE_IOCTL_FIONBIO) + /* older unix versions */ int flags; - flags = nonblock; return ioctl(sockfd, FIONBIO, &flags); -#undef SETBLOCK -#define SETBLOCK 2 -#endif -#if defined(HAVE_IOCTLSOCKET) && (SETBLOCK == 0) +#elif defined(HAVE_IOCTLSOCKET_FIONBIO) + #ifdef WATT32 char flags; #else - /* Windows? */ + /* Windows */ unsigned long flags; #endif flags = nonblock; - return ioctlsocket(sockfd, FIONBIO, &flags); -#undef SETBLOCK -#define SETBLOCK 3 -#endif -#if defined(HAVE_IOCTLSOCKET_CASE) && (SETBLOCK == 0) - /* presumably for Amiga */ +#elif defined(HAVE_IOCTLSOCKET_CAMEL_FIONBIO) + + /* Amiga */ return IoctlSocket(sockfd, FIONBIO, (long)nonblock); -#undef SETBLOCK -#define SETBLOCK 4 -#endif -#if defined(HAVE_SO_NONBLOCK) && (SETBLOCK == 0) +#elif defined(HAVE_SETSOCKOPT_SO_NONBLOCK) + /* BeOS */ long b = nonblock ? 1 : 0; return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); -#undef SETBLOCK -#define SETBLOCK 5 -#endif -#ifdef HAVE_DISABLED_NONBLOCKING - return 0; /* returns success */ -#undef SETBLOCK -#define SETBLOCK 6 -#endif - -#if (SETBLOCK == 0) -#error "no non-blocking method was found/used/set" +#else +# error "no non-blocking method was found/used/set" #endif } diff --git a/ares/config-win32.h b/ares/config-win32.h index 9e8f10c55..2245b0386 100644 --- a/ares/config-win32.h +++ b/ares/config-win32.h @@ -76,9 +76,12 @@ /* FUNCTIONS */ /* ---------------------------------------------------------------- */ -/* Define if you have the ioctlsocket function. */ +/* Define if you have the ioctlsocket function. */ #define HAVE_IOCTLSOCKET 1 +/* Define if you have a working ioctlsocket FIONBIO function. */ +#define HAVE_IOCTLSOCKET_FIONBIO 1 + /* Define if you have the strcasecmp function. */ /* #define HAVE_STRCASECMP 1 */ diff --git a/ares/configure.ac b/ares/configure.ac index 641a83e3e..1b1b20d59 100644 --- a/ares/configure.ac +++ b/ares/configure.ac @@ -553,12 +553,17 @@ CURL_CHECK_FUNC_RECVFROM CURL_CHECK_FUNC_SEND CURL_CHECK_MSG_NOSIGNAL +CARES_CHECK_FUNC_FCNTL CARES_CHECK_FUNC_FREEADDRINFO CARES_CHECK_FUNC_GETADDRINFO CARES_CHECK_FUNC_GETHOSTNAME CARES_CHECK_FUNC_GETSERVBYPORT_R CARES_CHECK_FUNC_INET_NTOP CARES_CHECK_FUNC_INET_PTON +CARES_CHECK_FUNC_IOCTL +CARES_CHECK_FUNC_IOCTLSOCKET +CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL +CARES_CHECK_FUNC_SETSOCKOPT CARES_CHECK_FUNC_STRCASECMP CARES_CHECK_FUNC_STRCMPI CARES_CHECK_FUNC_STRDUP @@ -851,8 +856,6 @@ dnl and get the types of five of its arguments. CURL_CHECK_FUNC_GETNAMEINFO -CURL_CHECK_NONBLOCKING_SOCKET - AC_C_BIGENDIAN( [AC_DEFINE(ARES_BIG_ENDIAN, 1, [define this if ares is built for a big endian system])], @@ -883,6 +886,9 @@ if test -n "$RANDOM_FILE" && test X"$RANDOM_FILE" != Xno ; then [a suitable file/device to read random data from]) fi +CARES_CHECK_OPTION_NONBLOCKING +CARES_CHECK_NONBLOCKING_SOCKET + CARES_PRIVATE_LIBS="$LIBS" AC_SUBST(CARES_PRIVATE_LIBS) diff --git a/ares/m4/cares-confopts.m4 b/ares/m4/cares-confopts.m4 index 17a6875f3..c34197a48 100644 --- a/ares/m4/cares-confopts.m4 +++ b/ares/m4/cares-confopts.m4 @@ -16,7 +16,7 @@ #*************************************************************************** # File version for 'aclocal' use. Keep it a single number. -# serial 2 +# serial 3 dnl CARES_CHECK_OPTION_DEBUG @@ -52,6 +52,38 @@ AC_HELP_STRING([--disable-debug],[Disable debug build options]), ]) +dnl CARES_CHECK_OPTION_NONBLOCKING +dnl ------------------------------------------------- +dnl Verify if configure has been invoked with option +dnl --enable-nonblocking or --disable-nonblocking, and +dnl set shell variable want_nonblocking as appropriate. + +AC_DEFUN([CARES_CHECK_OPTION_NONBLOCKING], [ + AC_BEFORE([$0],[CARES_CHECK_NONBLOCKING_SOCKET])dnl + AC_MSG_CHECKING([whether to enable non-blocking communications]) + OPT_NONBLOCKING="default" + AC_ARG_ENABLE(nonblocking, +AC_HELP_STRING([--enable-nonblocking],[Enable non-blocking communications]) +AC_HELP_STRING([--disable-nonblocking],[Disable non-blocking communications]), + OPT_NONBLOCKING=$enableval) + case "$OPT_NONBLOCKING" in + no) + dnl --disable-nonblocking option used + want_nonblocking="no" + ;; + default) + dnl configure option not specified + want_nonblocking="yes" + ;; + *) + dnl --enable-nonblocking option used + want_nonblocking="yes" + ;; + esac + AC_MSG_RESULT([$want_nonblocking]) +]) + + dnl CARES_CHECK_OPTION_OPTIMIZE dnl ------------------------------------------------- dnl Verify if configure has been invoked with option @@ -140,3 +172,43 @@ AC_HELP_STRING([--disable-warnings],[Disable strict compiler warnings]), esac AC_MSG_RESULT([$want_warnings]) ]) + + +dnl CARES_CHECK_NONBLOCKING_SOCKET +dnl ------------------------------------------------- +dnl Check for how to set a socket into non-blocking state. + +AC_DEFUN([CARES_CHECK_NONBLOCKING_SOCKET], [ + AC_REQUIRE([CARES_CHECK_OPTION_NONBLOCKING])dnl + AC_REQUIRE([CARES_CHECK_FUNC_FCNTL])dnl + AC_REQUIRE([CARES_CHECK_FUNC_IOCTL])dnl + AC_REQUIRE([CARES_CHECK_FUNC_IOCTLSOCKET])dnl + AC_REQUIRE([CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL])dnl + AC_REQUIRE([CARES_CHECK_FUNC_SETSOCKOPT])dnl + # + tst_method="unknown" + if test "$want_nonblocking" = "yes"; then + AC_MSG_CHECKING([how to set a socket into non-blocking mode]) + if test "x$ac_cv_func_fcntl_o_nonblock" = "xyes"; then + tst_method="fcntl O_NONBLOCK" + elif test "x$ac_cv_func_ioctl_fionbio" = "xyes"; then + tst_method="ioctl FIONBIO" + elif test "x$ac_cv_func_ioctlsocket_fionbio" = "xyes"; then + tst_method="ioctlsocket FIONBIO" + elif test "x$ac_cv_func_ioctlsocket_camel_fionbio" = "xyes"; then + tst_method="IoctlSocket FIONBIO" + elif test "x$ac_cv_func_setsockopt_so_nonblock" = "xyes"; then + tst_method="setsockopt SO_NONBLOCK" + fi + AC_MSG_RESULT([$tst_method]) + if test "$tst_method" = "unknown"; then + AC_MSG_WARN([cannot determine non-blocking socket method.]) + fi + fi + if test "$tst_method" = "unknown"; then + AC_DEFINE_UNQUOTED(USE_BLOCKING_SOCKETS, 1, + [Define to disable non-blocking sockets.]) + AC_MSG_WARN([non-blocking sockets disabled.]) + fi +]) + diff --git a/ares/m4/cares-functions.m4 b/ares/m4/cares-functions.m4 index 98bd070f0..66bf9cae6 100644 --- a/ares/m4/cares-functions.m4 +++ b/ares/m4/cares-functions.m4 @@ -16,7 +16,7 @@ #*************************************************************************** # File version for 'aclocal' use. Keep it a single number. -# serial 18 +# serial 19 dnl CARES_INCLUDES_ARPA_INET @@ -46,6 +46,30 @@ cares_includes_arpa_inet="\ ]) +dnl CARES_INCLUDES_FCNTL +dnl ------------------------------------------------- +dnl Set up variable with list of headers that must be +dnl included when fcntl.h is to be included. + +AC_DEFUN([CARES_INCLUDES_FCNTL], [ +cares_includes_fcntl="\ +/* includes start */ +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif +#ifdef HAVE_STROPTS_H +# include <fcntl.h> +#endif +/* includes end */" + AC_CHECK_HEADERS( + sys/types.h unistd.h fcntl.h, + [], [], [$cares_includes_fcntl]) +]) + + dnl CARES_INCLUDES_NETDB dnl ------------------------------------------------- dnl Set up variable with list of headers that must be @@ -112,6 +136,36 @@ cares_includes_string="\ ]) +dnl CARES_INCLUDES_STROPTS +dnl ------------------------------------------------- +dnl Set up variable with list of headers that must be +dnl included when stropts.h is to be included. + +AC_DEFUN([CARES_INCLUDES_STROPTS], [ +cares_includes_stropts="\ +/* includes start */ +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif +#ifdef HAVE_SYS_SOCKET_H +# include <sys/socket.h> +#endif +#ifdef HAVE_SYS_IOCTL_H +# include <sys/ioctl.h> +#endif +#ifdef HAVE_STROPTS_H +# include <stropts.h> +#endif +/* includes end */" + AC_CHECK_HEADERS( + sys/types.h unistd.h sys/socket.h sys/ioctl.h stropts.h, + [], [], [$cares_includes_stropts]) +]) + + dnl CARES_INCLUDES_SYS_SOCKET dnl ------------------------------------------------- dnl Set up variable with list of headers that must be @@ -230,6 +284,155 @@ cares_includes_ws2tcpip="\ ]) +dnl CARES_CHECK_FUNC_FCNTL +dnl ------------------------------------------------- +dnl Verify if fcntl 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 cares_disallow_fcntl, then +dnl HAVE_FCNTL will be defined. + +AC_DEFUN([CARES_CHECK_FUNC_FCNTL], [ + AC_REQUIRE([CARES_INCLUDES_FCNTL])dnl + # + tst_links_fcntl="unknown" + tst_proto_fcntl="unknown" + tst_compi_fcntl="unknown" + tst_allow_fcntl="unknown" + # + AC_MSG_CHECKING([if fcntl can be linked]) + AC_LINK_IFELSE([ + AC_LANG_FUNC_LINK_TRY([fcntl]) + ],[ + AC_MSG_RESULT([yes]) + tst_links_fcntl="yes" + ],[ + AC_MSG_RESULT([no]) + tst_links_fcntl="no" + ]) + # + if test "$tst_links_fcntl" = "yes"; then + AC_MSG_CHECKING([if fcntl is prototyped]) + AC_EGREP_CPP([fcntl],[ + $cares_includes_fcntl + ],[ + AC_MSG_RESULT([yes]) + tst_proto_fcntl="yes" + ],[ + AC_MSG_RESULT([no]) + tst_proto_fcntl="no" + ]) + fi + # + if test "$tst_proto_fcntl" = "yes"; then + AC_MSG_CHECKING([if fcntl is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $cares_includes_fcntl + ]],[[ + if(0 != fcntl(0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_fcntl="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_fcntl="no" + ]) + fi + # + if test "$tst_compi_fcntl" = "yes"; then + AC_MSG_CHECKING([if fcntl usage allowed]) + if test "x$cares_disallow_fcntl" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_fcntl="yes" + else + AC_MSG_RESULT([no]) + tst_allow_fcntl="no" + fi + fi + # + AC_MSG_CHECKING([if fcntl might be used]) + if test "$tst_links_fcntl" = "yes" && + test "$tst_proto_fcntl" = "yes" && + test "$tst_compi_fcntl" = "yes" && + test "$tst_allow_fcntl" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_FCNTL, 1, + [Define to 1 if you have the fcntl function.]) + ac_cv_func_fcntl="yes" + CARES_CHECK_FUNC_FCNTL_O_NONBLOCK + else + AC_MSG_RESULT([no]) + ac_cv_func_fcntl="no" + fi +]) + + +dnl CARES_CHECK_FUNC_FCNTL_O_NONBLOCK +dnl ------------------------------------------------- +dnl Verify if fcntl with status flag O_NONBLOCK is +dnl available, can be compiled, and seems to work. If +dnl all of these are true, then HAVE_FCNTL_O_NONBLOCK +dnl will be defined. + +AC_DEFUN([CARES_CHECK_FUNC_FCNTL_O_NONBLOCK], [ + # + tst_compi_fcntl_o_nonblock="unknown" + tst_allow_fcntl_o_nonblock="unknown" + # + case $host_os in + sunos4* | aix3* | beos*) + dnl O_NONBLOCK does not work on these platforms + cares_disallow_fcntl_o_nonblock="yes" + ;; + esac + # + if test "$ac_cv_func_fcntl" = "yes"; then + AC_MSG_CHECKING([if fcntl O_NONBLOCK is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $cares_includes_fcntl + ]],[[ + int flags = 0; + if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_fcntl_o_nonblock="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_fcntl_o_nonblock="no" + ]) + fi + # + if test "$tst_compi_fcntl_o_nonblock" = "yes"; then + AC_MSG_CHECKING([if fcntl O_NONBLOCK usage allowed]) + if test "x$cares_disallow_fcntl_o_nonblock" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_fcntl_o_nonblock="yes" + else + AC_MSG_RESULT([no]) + tst_allow_fcntl_o_nonblock="no" + fi + fi + # + AC_MSG_CHECKING([if fcntl O_NONBLOCK might be used]) + if test "$tst_compi_fcntl_o_nonblock" = "yes" && + test "$tst_allow_fcntl_o_nonblock" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_FCNTL_O_NONBLOCK, 1, + [Define to 1 if you have a working fcntl O_NONBLOCK function.]) + ac_cv_func_fcntl_o_nonblock="yes" + else + AC_MSG_RESULT([no]) + ac_cv_func_fcntl_o_nonblock="no" + fi +]) + + dnl CARES_CHECK_FUNC_FREEADDRINFO dnl ------------------------------------------------- dnl Verify if freeaddrinfo is available, prototyped, @@ -1018,6 +1221,587 @@ AC_DEFUN([CARES_CHECK_FUNC_INET_PTON], [ ]) +dnl CARES_CHECK_FUNC_IOCTL +dnl ------------------------------------------------- +dnl Verify if ioctl 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 cares_disallow_ioctl, then +dnl HAVE_IOCTL will be defined. + +AC_DEFUN([CARES_CHECK_FUNC_IOCTL], [ + AC_REQUIRE([CARES_INCLUDES_STROPTS])dnl + # + tst_links_ioctl="unknown" + tst_proto_ioctl="unknown" + tst_compi_ioctl="unknown" + tst_allow_ioctl="unknown" + # + AC_MSG_CHECKING([if ioctl can be linked]) + AC_LINK_IFELSE([ + AC_LANG_FUNC_LINK_TRY([ioctl]) + ],[ + AC_MSG_RESULT([yes]) + tst_links_ioctl="yes" + ],[ + AC_MSG_RESULT([no]) + tst_links_ioctl="no" + ]) + # + if test "$tst_links_ioctl" = "yes"; then + AC_MSG_CHECKING([if ioctl is prototyped]) + AC_EGREP_CPP([ioctl],[ + $cares_includes_stropts + ],[ + AC_MSG_RESULT([yes]) + tst_proto_ioctl="yes" + ],[ + AC_MSG_RESULT([no]) + tst_proto_ioctl="no" + ]) + fi + # + if test "$tst_proto_ioctl" = "yes"; then + AC_MSG_CHECKING([if ioctl is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $cares_includes_stropts + ]],[[ + if(0 != ioctl(0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_ioctl="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_ioctl="no" + ]) + fi + # + if test "$tst_compi_ioctl" = "yes"; then + AC_MSG_CHECKING([if ioctl usage allowed]) + if test "x$cares_disallow_ioctl" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_ioctl="yes" + else + AC_MSG_RESULT([no]) + tst_allow_ioctl="no" + fi + fi + # + AC_MSG_CHECKING([if ioctl might be used]) + if test "$tst_links_ioctl" = "yes" && + test "$tst_proto_ioctl" = "yes" && + test "$tst_compi_ioctl" = "yes" && + test "$tst_allow_ioctl" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_IOCTL, 1, + [Define to 1 if you have the ioctl function.]) + ac_cv_func_ioctl="yes" + CARES_CHECK_FUNC_IOCTL_FIONBIO + else + AC_MSG_RESULT([no]) + ac_cv_func_ioctl="no" + fi +]) + + +dnl CARES_CHECK_FUNC_IOCTL_FIONBIO +dnl ------------------------------------------------- +dnl Verify if ioctl with the FIONBIO command is +dnl available, can be compiled, and seems to work. If +dnl all of these are true, then HAVE_IOCTL_FIONBIO +dnl will be defined. + +AC_DEFUN([CARES_CHECK_FUNC_IOCTL_FIONBIO], [ + # + tst_compi_ioctl_fionbio="unknown" + tst_allow_ioctl_fionbio="unknown" + # + if test "$ac_cv_func_ioctl" = "yes"; then + AC_MSG_CHECKING([if ioctl FIONBIO is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $cares_includes_stropts + ]],[[ + int flags = 0; + if(0 != ioctl(0, FIONBIO, &flags)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_ioctl_fionbio="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_ioctl_fionbio="no" + ]) + fi + # + if test "$tst_compi_ioctl_fionbio" = "yes"; then + AC_MSG_CHECKING([if ioctl FIONBIO usage allowed]) + if test "x$cares_disallow_ioctl_fionbio" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_ioctl_fionbio="yes" + else + AC_MSG_RESULT([no]) + tst_allow_ioctl_fionbio="no" + fi + fi + # + AC_MSG_CHECKING([if ioctl FIONBIO might be used]) + if test "$tst_compi_ioctl_fionbio" = "yes" && + test "$tst_allow_ioctl_fionbio" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_IOCTL_FIONBIO, 1, + [Define to 1 if you have a working ioctl FIONBIO function.]) + ac_cv_func_ioctl_fionbio="yes" + else + AC_MSG_RESULT([no]) + ac_cv_func_ioctl_fionbio="no" + fi +]) + + +dnl CARES_CHECK_FUNC_IOCTLSOCKET +dnl ------------------------------------------------- +dnl Verify if ioctlsocket 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 cares_disallow_ioctlsocket, then +dnl HAVE_IOCTLSOCKET will be defined. + +AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET], [ + AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl + # + tst_links_ioctlsocket="unknown" + tst_proto_ioctlsocket="unknown" + tst_compi_ioctlsocket="unknown" + tst_allow_ioctlsocket="unknown" + # + AC_MSG_CHECKING([if ioctlsocket can be linked]) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[ + $cares_includes_winsock2 + ]],[[ + if(0 != ioctlsocket(0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_links_ioctlsocket="yes" + ],[ + AC_MSG_RESULT([no]) + tst_links_ioctlsocket="no" + ]) + # + if test "$tst_links_ioctlsocket" = "yes"; then + AC_MSG_CHECKING([if ioctlsocket is prototyped]) + AC_EGREP_CPP([ioctlsocket],[ + $cares_includes_winsock2 + ],[ + AC_MSG_RESULT([yes]) + tst_proto_ioctlsocket="yes" + ],[ + AC_MSG_RESULT([no]) + tst_proto_ioctlsocket="no" + ]) + fi + # + if test "$tst_proto_ioctlsocket" = "yes"; then + AC_MSG_CHECKING([if ioctlsocket is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $cares_includes_winsock2 + ]],[[ + if(0 != ioctlsocket(0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_ioctlsocket="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_ioctlsocket="no" + ]) + fi + # + if test "$tst_compi_ioctlsocket" = "yes"; then + AC_MSG_CHECKING([if ioctlsocket usage allowed]) + if test "x$cares_disallow_ioctlsocket" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_ioctlsocket="yes" + else + AC_MSG_RESULT([no]) + tst_allow_ioctlsocket="no" + fi + fi + # + AC_MSG_CHECKING([if ioctlsocket might be used]) + if test "$tst_links_ioctlsocket" = "yes" && + test "$tst_proto_ioctlsocket" = "yes" && + test "$tst_compi_ioctlsocket" = "yes" && + test "$tst_allow_ioctlsocket" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET, 1, + [Define to 1 if you have the ioctlsocket function.]) + ac_cv_func_ioctlsocket="yes" + CARES_CHECK_FUNC_IOCTLSOCKET_FIONBIO + else + AC_MSG_RESULT([no]) + ac_cv_func_ioctlsocket="no" + fi +]) + + +dnl CARES_CHECK_FUNC_IOCTLSOCKET_FIONBIO +dnl ------------------------------------------------- +dnl Verify if ioctlsocket with the FIONBIO command is +dnl available, can be compiled, and seems to work. If +dnl all of these are true, then HAVE_IOCTLSOCKET_FIONBIO +dnl will be defined. + +AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET_FIONBIO], [ + # + tst_compi_ioctlsocket_fionbio="unknown" + tst_allow_ioctlsocket_fionbio="unknown" + # + if test "$ac_cv_func_ioctlsocket" = "yes"; then + AC_MSG_CHECKING([if ioctlsocket FIONBIO is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $cares_includes_winsock2 + ]],[[ + int flags = 0; + if(0 != ioctlsocket(0, FIONBIO, &flags)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_ioctlsocket_fionbio="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_ioctlsocket_fionbio="no" + ]) + fi + # + if test "$tst_compi_ioctlsocket_fionbio" = "yes"; then + AC_MSG_CHECKING([if ioctlsocket FIONBIO usage allowed]) + if test "x$cares_disallow_ioctlsocket_fionbio" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_ioctlsocket_fionbio="yes" + else + AC_MSG_RESULT([no]) + tst_allow_ioctlsocket_fionbio="no" + fi + fi + # + AC_MSG_CHECKING([if ioctlsocket FIONBIO might be used]) + if test "$tst_compi_ioctlsocket_fionbio" = "yes" && + test "$tst_allow_ioctlsocket_fionbio" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_FIONBIO, 1, + [Define to 1 if you have a working ioctlsocket FIONBIO function.]) + ac_cv_func_ioctlsocket_fionbio="yes" + else + AC_MSG_RESULT([no]) + ac_cv_func_ioctlsocket_fionbio="no" + fi +]) + + +dnl CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL +dnl ------------------------------------------------- +dnl Verify if IoctlSocket 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 cares_disallow_ioctlsocket_camel, +dnl then HAVE_IOCTLSOCKET_CAMEL will be defined. + +AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL], [ + AC_REQUIRE([CARES_INCLUDES_STROPTS])dnl + # + tst_links_ioctlsocket_camel="unknown" + tst_proto_ioctlsocket_camel="unknown" + tst_compi_ioctlsocket_camel="unknown" + tst_allow_ioctlsocket_camel="unknown" + # + AC_MSG_CHECKING([if IoctlSocket can be linked]) + AC_LINK_IFELSE([ + AC_LANG_FUNC_LINK_TRY([IoctlSocket]) + ],[ + AC_MSG_RESULT([yes]) + tst_links_ioctlsocket_camel="yes" + ],[ + AC_MSG_RESULT([no]) + tst_links_ioctlsocket_camel="no" + ]) + # + if test "$tst_links_ioctlsocket_camel" = "yes"; then + AC_MSG_CHECKING([if IoctlSocket is prototyped]) + AC_EGREP_CPP([IoctlSocket],[ + $cares_includes_stropts + ],[ + AC_MSG_RESULT([yes]) + tst_proto_ioctlsocket_camel="yes" + ],[ + AC_MSG_RESULT([no]) + tst_proto_ioctlsocket_camel="no" + ]) + fi + # + if test "$tst_proto_ioctlsocket_camel" = "yes"; then + AC_MSG_CHECKING([if IoctlSocket is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $cares_includes_stropts + ]],[[ + if(0 != IoctlSocket(0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_ioctlsocket_camel="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_ioctlsocket_camel="no" + ]) + fi + # + if test "$tst_compi_ioctlsocket_camel" = "yes"; then + AC_MSG_CHECKING([if IoctlSocket usage allowed]) + if test "x$cares_disallow_ioctlsocket_camel" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_ioctlsocket_camel="yes" + else + AC_MSG_RESULT([no]) + tst_allow_ioctlsocket_camel="no" + fi + fi + # + AC_MSG_CHECKING([if IoctlSocket might be used]) + if test "$tst_links_ioctlsocket_camel" = "yes" && + test "$tst_proto_ioctlsocket_camel" = "yes" && + test "$tst_compi_ioctlsocket_camel" = "yes" && + test "$tst_allow_ioctlsocket_camel" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL, 1, + [Define to 1 if you have the IoctlSocket camel case function.]) + ac_cv_func_ioctlsocket_camel="yes" + CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO + else + AC_MSG_RESULT([no]) + ac_cv_func_ioctlsocket_camel="no" + fi +]) + + +dnl CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO +dnl ------------------------------------------------- +dnl Verify if IoctlSocket with FIONBIO command is available, +dnl can be compiled, and seems to work. If all of these are +dnl true, then HAVE_IOCTLSOCKET_CAMEL_FIONBIO will be defined. + +AC_DEFUN([CARES_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO], [ + # + tst_compi_ioctlsocket_camel_fionbio="unknown" + tst_allow_ioctlsocket_camel_fionbio="unknown" + # + if test "$ac_cv_func_ioctlsocket_camel" = "yes"; then + AC_MSG_CHECKING([if IoctlSocket FIONBIO is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $cares_includes_stropts + ]],[[ + long flags = 0; + if(0 != ioctlsocket(0, FIONBIO, &flags)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_ioctlsocket_camel_fionbio="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_ioctlsocket_camel_fionbio="no" + ]) + fi + # + if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes"; then + AC_MSG_CHECKING([if IoctlSocket FIONBIO usage allowed]) + if test "x$cares_disallow_ioctlsocket_camel_fionbio" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_ioctlsocket_camel_fionbio="yes" + else + AC_MSG_RESULT([no]) + tst_allow_ioctlsocket_camel_fionbio="no" + fi + fi + # + AC_MSG_CHECKING([if IoctlSocket FIONBIO might be used]) + if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes" && + test "$tst_allow_ioctlsocket_camel_fionbio" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL_FIONBIO, 1, + [Define to 1 if you have a working IoctlSocket camel case FIONBIO function.]) + ac_cv_func_ioctlsocket_camel_fionbio="yes" + else + AC_MSG_RESULT([no]) + ac_cv_func_ioctlsocket_camel_fionbio="no" + fi +]) + + +dnl CARES_CHECK_FUNC_SETSOCKOPT +dnl ------------------------------------------------- +dnl Verify if setsockopt 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 cares_disallow_setsockopt, then +dnl HAVE_SETSOCKOPT will be defined. + +AC_DEFUN([CARES_CHECK_FUNC_SETSOCKOPT], [ + AC_REQUIRE([CARES_INCLUDES_WINSOCK2])dnl + AC_REQUIRE([CARES_INCLUDES_SYS_SOCKET])dnl + # + tst_links_setsockopt="unknown" + tst_proto_setsockopt="unknown" + tst_compi_setsockopt="unknown" + tst_allow_setsockopt="unknown" + # + AC_MSG_CHECKING([if setsockopt can be linked]) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[ + $cares_includes_winsock2 + $cares_includes_sys_socket + ]],[[ + if(0 != setsockopt(0, 0, 0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_links_setsockopt="yes" + ],[ + AC_MSG_RESULT([no]) + tst_links_setsockopt="no" + ]) + # + if test "$tst_links_setsockopt" = "yes"; then + AC_MSG_CHECKING([if setsockopt is prototyped]) + AC_EGREP_CPP([setsockopt],[ + $cares_includes_winsock2 + $cares_includes_sys_socket + ],[ + AC_MSG_RESULT([yes]) + tst_proto_setsockopt="yes" + ],[ + AC_MSG_RESULT([no]) + tst_proto_setsockopt="no" + ]) + fi + # + if test "$tst_proto_setsockopt" = "yes"; then + AC_MSG_CHECKING([if setsockopt is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $cares_includes_winsock2 + $cares_includes_sys_socket + ]],[[ + if(0 != setsockopt(0, 0, 0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_setsockopt="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_setsockopt="no" + ]) + fi + # + if test "$tst_compi_setsockopt" = "yes"; then + AC_MSG_CHECKING([if setsockopt usage allowed]) + if test "x$cares_disallow_setsockopt" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_setsockopt="yes" + else + AC_MSG_RESULT([no]) + tst_allow_setsockopt="no" + fi + fi + # + AC_MSG_CHECKING([if setsockopt might be used]) + if test "$tst_links_setsockopt" = "yes" && + test "$tst_proto_setsockopt" = "yes" && + test "$tst_compi_setsockopt" = "yes" && + test "$tst_allow_setsockopt" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT, 1, + [Define to 1 if you have the setsockopt function.]) + ac_cv_func_setsockopt="yes" + CARES_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK + else + AC_MSG_RESULT([no]) + ac_cv_func_setsockopt="no" + fi +]) + + +dnl CARES_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK +dnl ------------------------------------------------- +dnl Verify if setsockopt with the SO_NONBLOCK command is +dnl available, can be compiled, and seems to work. If +dnl all of these are true, then HAVE_SETSOCKOPT_SO_NONBLOCK +dnl will be defined. + +AC_DEFUN([CARES_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK], [ + # + tst_compi_setsockopt_so_nonblock="unknown" + tst_allow_setsockopt_so_nonblock="unknown" + # + if test "$ac_cv_func_setsockopt" = "yes"; then + AC_MSG_CHECKING([if setsockopt SO_NONBLOCK is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $cares_includes_winsock2 + $cares_includes_sys_socket + ]],[[ + if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_setsockopt_so_nonblock="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_setsockopt_so_nonblock="no" + ]) + fi + # + if test "$tst_compi_setsockopt_so_nonblock" = "yes"; then + AC_MSG_CHECKING([if setsockopt SO_NONBLOCK usage allowed]) + if test "x$cares_disallow_setsockopt_so_nonblock" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_setsockopt_so_nonblock="yes" + else + AC_MSG_RESULT([no]) + tst_allow_setsockopt_so_nonblock="no" + fi + fi + # + AC_MSG_CHECKING([if setsockopt SO_NONBLOCK might be used]) + if test "$tst_compi_setsockopt_so_nonblock" = "yes" && + test "$tst_allow_setsockopt_so_nonblock" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT_SO_NONBLOCK, 1, + [Define to 1 if you have a working setsockopt SO_NONBLOCK function.]) + ac_cv_func_setsockopt_so_nonblock="yes" + else + AC_MSG_RESULT([no]) + ac_cv_func_setsockopt_so_nonblock="no" + fi +]) + + dnl CARES_CHECK_FUNC_STRCASECMP dnl ------------------------------------------------- dnl Verify if strcasecmp is available, prototyped, and diff --git a/configure.ac b/configure.ac index 67a4c3a64..ada25fc1c 100644 --- a/configure.ac +++ b/configure.ac @@ -833,25 +833,6 @@ if test "$ipv6" = "yes"; then fi dnl ********************************************************************** -dnl Check how non-blocking sockets are set -dnl ********************************************************************** -AC_ARG_ENABLE(nonblocking, -AC_HELP_STRING([--enable-nonblocking],[Enable detecting how to do it]) -AC_HELP_STRING([--disable-nonblocking],[Disable non-blocking socket detection]), -[ - if test "$enableval" = "no" ; then - AC_MSG_WARN([non-blocking sockets disabled]) - AC_DEFINE(HAVE_DISABLED_NONBLOCKING, 1, - [to disable NON-BLOCKING connections]) - else - CURL_CHECK_NONBLOCKING_SOCKET - fi -], -[ - CURL_CHECK_NONBLOCKING_SOCKET -]) - -dnl ********************************************************************** dnl Check if the operating system allows programs to write to their own argv[] dnl ********************************************************************** @@ -2014,6 +1995,7 @@ CURL_CHECK_FUNC_SEND CURL_CHECK_MSG_NOSIGNAL CURL_CHECK_FUNC_ALARM +CURL_CHECK_FUNC_FCNTL CURL_CHECK_FUNC_FDOPEN CURL_CHECK_FUNC_FREEADDRINFO CURL_CHECK_FUNC_FREEIFADDRS @@ -2028,7 +2010,11 @@ CURL_CHECK_FUNC_GMTIME_R CURL_CHECK_FUNC_INET_NTOA_R CURL_CHECK_FUNC_INET_NTOP CURL_CHECK_FUNC_INET_PTON +CURL_CHECK_FUNC_IOCTL +CURL_CHECK_FUNC_IOCTLSOCKET +CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL CURL_CHECK_FUNC_LOCALTIME_R +CURL_CHECK_FUNC_SETSOCKOPT CURL_CHECK_FUNC_SIGACTION CURL_CHECK_FUNC_SIGINTERRUPT CURL_CHECK_FUNC_SIGNAL @@ -2170,6 +2156,15 @@ if test "$disable_poll" = "no"; then fi dnl poll() was found fi dnl poll()-check is not disabled +dnl ************************************************************ +dnl enable non-blocking communications +dnl +CURL_CHECK_OPTION_NONBLOCKING +CURL_CHECK_NONBLOCKING_SOCKET + +dnl ************************************************************ +dnl nroff tool stuff +dnl AC_PATH_PROG( PERL, perl, , $PATH:/usr/local/bin/perl:/usr/bin/:/usr/local/bin ) diff --git a/lib/Makefile.netware b/lib/Makefile.netware index 80476ef0c..a5e0345c9 100644 --- a/lib/Makefile.netware +++ b/lib/Makefile.netware @@ -461,12 +461,13 @@ endif @echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@ @echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@ @echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@ - @echo $(DL)#define HAVE_FIONBIO 1$(DL) >> $@ @echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@ @echo $(DL)#define HAVE_GETHOSTBYNAME 1$(DL) >> $@ @echo $(DL)#define HAVE_GETPROTOBYNAME 1$(DL) >> $@ @echo $(DL)#define HAVE_GMTIME_R 1$(DL) >> $@ @echo $(DL)#define HAVE_INET_ADDR 1$(DL) >> $@ + @echo $(DL)#define HAVE_IOCTL 1$(DL) >> $@ + @echo $(DL)#define HAVE_IOCTL_FIONBIO 1$(DL) >> $@ @echo $(DL)#define HAVE_LL 1$(DL) >> $@ @echo $(DL)#define HAVE_LOCALE_H 1$(DL) >> $@ @echo $(DL)#define HAVE_LOCALTIME_R 1$(DL) >> $@ diff --git a/lib/config-amigaos.h b/lib/config-amigaos.h index f8dc3a374..6a871d047 100644 --- a/lib/config-amigaos.h +++ b/lib/config-amigaos.h @@ -29,7 +29,8 @@ #define HAVE_GETHOSTBYADDR 1 #define HAVE_INET_ADDR 1 #define HAVE_INTTYPES_H 1 -#define HAVE_IOCTLSOCKET_CASE 1 +#define HAVE_IOCTLSOCKET_CAMEL 1 +#define HAVE_IOCTLSOCKET_CAMEL_FIONBIO 1 #define HAVE_LIBCRYPTO 1 #define HAVE_LIBSSL 1 #define HAVE_LIBZ 1 diff --git a/lib/config-mac.h b/lib/config-mac.h index 2f4c2fb02..0547aeaa8 100644 --- a/lib/config-mac.h +++ b/lib/config-mac.h @@ -54,7 +54,8 @@ #define HAVE_RAND_STATUS 1 #define HAVE_RAND_EGD 1 -#define HAVE_FIONBIO 1 +#define HAVE_IOCTL 1 +#define HAVE_IOCTL_FIONBIO 1 #define RETSIGTYPE void diff --git a/lib/config-os400.h b/lib/config-os400.h index 647893d99..e562b3c0b 100644 --- a/lib/config-os400.h +++ b/lib/config-os400.h @@ -394,7 +394,11 @@ #define IOCTL_3_ARGS -#define HAVE_FIONBIO +/* Define if you have the ioctl function. */ +#define HAVE_IOCTL + +/* Define if you have a working ioctl FIONBIO function. */ +#define HAVE_IOCTL_FIONBIO /* to disable LDAP */ #undef CURL_DISABLE_LDAP diff --git a/lib/config-riscos.h b/lib/config-riscos.h index f863f634e..fb1bb521e 100644 --- a/lib/config-riscos.h +++ b/lib/config-riscos.h @@ -383,7 +383,11 @@ #define IOCTL_3_ARGS -#define HAVE_FIONBIO +/* Define if you have the ioctl function. */ +#define HAVE_IOCTL + +/* Define if you have a working ioctl FIONBIO function. */ +#define HAVE_IOCTL_FIONBIO /* to disable LDAP */ #define CURL_DISABLE_LDAP diff --git a/lib/config-symbian.h b/lib/config-symbian.h index 70c2a5803..fb5dd23aa 100644 --- a/lib/config-symbian.h +++ b/lib/config-symbian.h @@ -111,9 +111,6 @@ /* Define to 1 if you have the <des.h> header file. */ /* #undef HAVE_DES_H */ -/* disabled non-blocking sockets */ -/* #undef HAVE_DISABLED_NONBLOCKING */ - /* Define to 1 if you have the <dlfcn.h> header file. */ #define HAVE_DLFCN_H 1 @@ -129,8 +126,11 @@ /* Define to 1 if you have the <fcntl.h> header file. */ #define HAVE_FCNTL_H 1 -/* use FIONBIO for non-blocking sockets */ -#define HAVE_FIONBIO 1 +/* Define to 1 if you have the fcntl function. */ +#define HAVE_FCNTL 1 + +/* Define to 1 if you have a working fcntl O_NONBLOCK function. */ +#define HAVE_FCNTL_O_NONBLOCK 1 /* Define to 1 if you have the `fork' function. */ /*#define HAVE_FORK 1*/ @@ -231,11 +231,23 @@ /* Define to 1 if you have the <inttypes.h> header file. */ #define HAVE_INTTYPES_H 1 -/* use ioctlsocket() for non-blocking sockets */ +/* Define to 1 if you have the ioctl function. */ +#define HAVE_IOCTL 1 + +/* Define to 1 if you have a working ioctl FIONBIO function. */ +#define HAVE_IOCTL_FIONBIO 1 + +/* Define to 1 if you have the ioctlsocket function. */ /* #undef HAVE_IOCTLSOCKET */ -/* use Ioctlsocket() for non-blocking sockets */ -/* #undef HAVE_IOCTLSOCKET_CASE */ +/* Define to 1 if you have a working ioctlsocket FIONBIO function. */ +/* #undef HAVE_IOCTLSOCKET_FIONBIO */ + +/* Define to 1 if you have the IoctlSocket camel case function. */ +/* #undef HAVE_IOCTLSOCKET_CAMEL */ + +/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function. */ +/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */ /* Define to 1 if you have the <io.h> header file. */ /* #undef HAVE_IO_H */ @@ -361,9 +373,6 @@ /* Define to 1 if you have the <openssl/x509.h> header file. */ /*#define HAVE_OPENSSL_X509_H 1*/ -/* use O_NONBLOCK for non-blocking sockets */ -#define HAVE_O_NONBLOCK 1 - /* Define to 1 if you have the <pem.h> header file. */ /* #undef HAVE_PEM_H */ @@ -427,6 +436,12 @@ /* Define to 1 if you have the `setrlimit' function. */ /*#define HAVE_SETRLIMIT 1*/ +/* Define to 1 if you have the setsockopt function. */ +/* #undef HAVE_SETSOCKOPT */ + +/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */ +/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */ + /* Define to 1 if you have the <sgtty.h> header file. */ /*#define HAVE_SGTTY_H 1*/ @@ -454,9 +469,6 @@ /* Define to 1 if you have the `socket' function. */ #define HAVE_SOCKET 1 -/* use SO_NONBLOCK for non-blocking sockets */ -/* #undef HAVE_SO_NONBLOCK */ - /* Define this if you have the SPNEGO library fbopenssl */ /* #undef HAVE_SPNEGO */ @@ -715,6 +727,9 @@ /* Define if you want to enable c-ares support */ /* #undef USE_ARES */ +/* Define to disable non-blocking sockets */ +/* #undef USE_BLOCKING_SOCKETS */ + /* if GnuTLS is enabled */ /* #undef USE_GNUTLS */ diff --git a/lib/config-tpf.h b/lib/config-tpf.h index 35c44ed70..67f9cbfef 100644 --- a/lib/config-tpf.h +++ b/lib/config-tpf.h @@ -104,9 +104,6 @@ /* #undef HAVE_DES_H */ #define HAVE_DES_H 1 -/* disabled non-blocking sockets */ -/* #undef HAVE_DISABLED_NONBLOCKING */ - /* Define to 1 if you have the `ENGINE_load_builtin_engines' function. */ /* #undef HAVE_ENGINE_LOAD_BUILTIN_ENGINES */ #define HAVE_ENGINE_LOAD_BUILTIN_ENGINES 1 @@ -121,9 +118,11 @@ /* Define to 1 if you have the <fcntl.h> header file. */ #define HAVE_FCNTL_H 1 -/* use FIONBIO for non-blocking sockets */ -/* #undef HAVE_FIONBIO */ -#define HAVE_FIONBIO 1 +/* Define to 1 if you have the fcntl function. */ +#define HAVE_FCNTL 1 + +/* Define to 1 if you have a working fcntl O_NONBLOCK function. */ +#define HAVE_FCNTL_O_NONBLOCK 1 /* Define to 1 if you have the `fork' function. */ /* #undef HAVE_FORK */ @@ -217,11 +216,23 @@ /* Define to 1 if you have the <inttypes.h> header file. */ #define HAVE_INTTYPES_H 1 -/* use ioctlsocket() for non-blocking sockets */ +/* Define to 1 if you have the ioctl function. */ +#define HAVE_IOCTL 1 + +/* Define to 1 if you have a working ioctl FIONBIO function. */ +#define HAVE_IOCTL_FIONBIO 1 + +/* Define to 1 if you have the ioctlsocket function. */ /* #undef HAVE_IOCTLSOCKET */ -/* use Ioctlsocket() for non-blocking sockets */ -/* #undef HAVE_IOCTLSOCKET_CASE */ +/* Define to 1 if you have a working ioctlsocket FIONBIO function. */ +/* #undef HAVE_IOCTLSOCKET_FIONBIO */ + +/* Define to 1 if you have the IoctlSocket camel case function. */ +/* #undef HAVE_IOCTLSOCKET_CAMEL */ + +/* Define to 1 if you have a working IoctlSocket camel case FIONBIO function. */ +/* #undef HAVE_IOCTLSOCKET_CAMEL_FIONBIO */ /* Define to 1 if you have the <io.h> header file. */ /* #undef HAVE_IO_H */ @@ -328,9 +339,6 @@ /* #undef HAVE_OPENSSL_X509_H */ #define HAVE_OPENSSL_X509_H 1 -/* use O_NONBLOCK for non-blocking sockets */ -/* #undef HAVE_O_NONBLOCK 1 */ - /* Define to 1 if you have the <pem.h> header file. */ /* #undef HAVE_PEM_H */ #define HAVE_PEM_H 1 @@ -380,6 +388,12 @@ /* Define to 1 if you have the `setrlimit' function. */ #define HAVE_SETRLIMIT 1 +/* Define to 1 if you have the setsockopt function. */ +/* #undef HAVE_SETSOCKOPT */ + +/* Define to 1 if you have a working setsockopt SO_NONBLOCK function. */ +/* #undef HAVE_SETSOCKOPT_SO_NONBLOCK */ + /* Define to 1 if you have the <sgtty.h> header file. */ /* #undef HAVE_SGTTY_H 1 */ @@ -407,9 +421,6 @@ /* Define to 1 if you have the `socket' function. */ #define HAVE_SOCKET 1 -/* use SO_NONBLOCK for non-blocking sockets */ -/* #undef HAVE_SO_NONBLOCK */ - /* Define this if you have the SPNEGO library fbopenssl */ /* #undef HAVE_SPNEGO */ @@ -602,6 +613,9 @@ /* Define if you want to enable ares support */ /* #undef USE_ARES */ +/* Define to disable non-blocking sockets */ +/* #undef USE_BLOCKING_SOCKETS */ + /* if GnuTLS is enabled */ /* #undef USE_GNUTLS */ diff --git a/lib/config-win32.h b/lib/config-win32.h index 88d011849..dc359d6a3 100644 --- a/lib/config-win32.h +++ b/lib/config-win32.h @@ -157,9 +157,12 @@ /* Define if you have the inet_addr function. */ #define HAVE_INET_ADDR 1 -/* Define if you have the ioctlsocket function. */ +/* Define if you have the ioctlsocket function. */ #define HAVE_IOCTLSOCKET 1 +/* Define if you have a working ioctlsocket FIONBIO function. */ +#define HAVE_IOCTLSOCKET_FIONBIO 1 + /* Define if you have the perror function. */ #define HAVE_PERROR 1 diff --git a/lib/config-win32ce.h b/lib/config-win32ce.h index b770a4472..cd793d6cc 100644 --- a/lib/config-win32ce.h +++ b/lib/config-win32ce.h @@ -145,9 +145,12 @@ /* Define if you have the inet_addr function. */ #define HAVE_INET_ADDR 1 -/* Define if you have the ioctlsocket function. */ +/* Define if you have the ioctlsocket function. */ #define HAVE_IOCTLSOCKET 1 +/* Define if you have a working ioctlsocket FIONBIO function. */ +#define HAVE_IOCTLSOCKET_FIONBIO 1 + /* Define if you have the perror function. */ #define HAVE_PERROR 1 diff --git a/lib/config.dos b/lib/config.dos index 16ed9d6a0..361daba2c 100644 --- a/lib/config.dos +++ b/lib/config.dos @@ -19,13 +19,15 @@ #define HAVE_ARPA_INET_H 1 #define HAVE_FCNTL_H 1 -#define HAVE_FIONBIO 1 #define HAVE_GETADDRINFO 1 #define HAVE_GETNAMEINFO 1 #define HAVE_GETPROTOBYNAME 1 #define HAVE_GETTIMEOFDAY 1 #define HAVE_IO_H 1 +#define HAVE_IOCTL 1 +#define HAVE_IOCTL_FIONBIO 1 #define HAVE_IOCTLSOCKET 1 +#define HAVE_IOCTLSOCKET_FIONBIO 1 #define HAVE_LOCALE_H 1 #define HAVE_LONGLONG 1 #define HAVE_MEMORY_H 1 diff --git a/lib/connect.c b/lib/connect.c index 65e9be4f4..f2b15da82 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -59,7 +59,7 @@ #include <stdlib.h> /* required for free() prototype, without it, this crashes */ #endif /* on macos 68K */ -#if (defined(HAVE_FIONBIO) && defined(NETWARE)) +#if (defined(HAVE_IOCTL_FIONBIO) && defined(NETWARE)) #include <sys/filio.h> #endif #ifdef NETWARE @@ -189,64 +189,47 @@ long Curl_timeleft(struct connectdata *conn, int Curl_nonblock(curl_socket_t sockfd, /* operate on this */ int nonblock /* TRUE or FALSE */) { -#undef SETBLOCK -#define SETBLOCK 0 -#ifdef HAVE_O_NONBLOCK +#if defined(USE_BLOCKING_SOCKETS) + + return 0; /* returns success */ + +#elif defined(HAVE_FCNTL_O_NONBLOCK) + /* most recent unix versions */ int flags; - flags = fcntl(sockfd, F_GETFL, 0); if(FALSE != nonblock) return fcntl(sockfd, F_SETFL, flags | O_NONBLOCK); else return fcntl(sockfd, F_SETFL, flags & (~O_NONBLOCK)); -#undef SETBLOCK -#define SETBLOCK 1 -#endif -#if defined(HAVE_FIONBIO) && (SETBLOCK == 0) +#elif defined(HAVE_IOCTL_FIONBIO) + /* older unix versions */ int flags; - flags = nonblock; return ioctl(sockfd, FIONBIO, &flags); -#undef SETBLOCK -#define SETBLOCK 2 -#endif -#if defined(HAVE_IOCTLSOCKET) && (SETBLOCK == 0) - /* Windows? */ +#elif defined(HAVE_IOCTLSOCKET_FIONBIO) + + /* Windows */ unsigned long flags; flags = nonblock; - return ioctlsocket(sockfd, FIONBIO, &flags); -#undef SETBLOCK -#define SETBLOCK 3 -#endif -#if defined(HAVE_IOCTLSOCKET_CASE) && (SETBLOCK == 0) - /* presumably for Amiga */ +#elif defined(HAVE_IOCTLSOCKET_CAMEL_FIONBIO) + + /* Amiga */ return IoctlSocket(sockfd, FIONBIO, (long)nonblock); -#undef SETBLOCK -#define SETBLOCK 4 -#endif -#if defined(HAVE_SO_NONBLOCK) && (SETBLOCK == 0) +#elif defined(HAVE_SETSOCKOPT_SO_NONBLOCK) + /* BeOS */ long b = nonblock ? 1 : 0; return setsockopt(sockfd, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b)); -#undef SETBLOCK -#define SETBLOCK 5 -#endif -#ifdef HAVE_DISABLED_NONBLOCKING - return 0; /* returns success */ -#undef SETBLOCK -#define SETBLOCK 6 -#endif - -#if(SETBLOCK == 0) -#error "no non-blocking method was found/used/set" +#else +# error "no non-blocking method was found/used/set" #endif } diff --git a/m4/curl-confopts.m4 b/m4/curl-confopts.m4 index b0c1f3cd4..5ad3e1830 100644 --- a/m4/curl-confopts.m4 +++ b/m4/curl-confopts.m4 @@ -22,7 +22,7 @@ #*************************************************************************** # File version for 'aclocal' use. Keep it a single number. -# serial 3 +# serial 4 dnl CURL_CHECK_OPTION_DEBUG @@ -58,6 +58,38 @@ AC_HELP_STRING([--disable-debug],[Disable debug build options]), ]) +dnl CURL_CHECK_OPTION_NONBLOCKING +dnl ------------------------------------------------- +dnl Verify if configure has been invoked with option +dnl --enable-nonblocking or --disable-nonblocking, and +dnl set shell variable want_nonblocking as appropriate. + +AC_DEFUN([CURL_CHECK_OPTION_NONBLOCKING], [ + AC_BEFORE([$0],[CURL_CHECK_NONBLOCKING_SOCKET])dnl + AC_MSG_CHECKING([whether to enable non-blocking communications]) + OPT_NONBLOCKING="default" + AC_ARG_ENABLE(nonblocking, +AC_HELP_STRING([--enable-nonblocking],[Enable non-blocking communications]) +AC_HELP_STRING([--disable-nonblocking],[Disable non-blocking communications]), + OPT_NONBLOCKING=$enableval) + case "$OPT_NONBLOCKING" in + no) + dnl --disable-nonblocking option used + want_nonblocking="no" + ;; + default) + dnl configure option not specified + want_nonblocking="yes" + ;; + *) + dnl --enable-nonblocking option used + want_nonblocking="yes" + ;; + esac + AC_MSG_RESULT([$want_nonblocking]) +]) + + dnl CURL_CHECK_OPTION_OPTIMIZE dnl ------------------------------------------------- dnl Verify if configure has been invoked with option @@ -147,3 +179,42 @@ AC_HELP_STRING([--disable-warnings],[Disable strict compiler warnings]), AC_MSG_RESULT([$want_warnings]) ]) + +dnl CURL_CHECK_NONBLOCKING_SOCKET +dnl ------------------------------------------------- +dnl Check for how to set a socket into non-blocking state. + +AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET], [ + AC_REQUIRE([CURL_CHECK_OPTION_NONBLOCKING])dnl + AC_REQUIRE([CURL_CHECK_FUNC_FCNTL])dnl + AC_REQUIRE([CURL_CHECK_FUNC_IOCTL])dnl + AC_REQUIRE([CURL_CHECK_FUNC_IOCTLSOCKET])dnl + AC_REQUIRE([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL])dnl + AC_REQUIRE([CURL_CHECK_FUNC_SETSOCKOPT])dnl + # + tst_method="unknown" + if test "$want_nonblocking" = "yes"; then + AC_MSG_CHECKING([how to set a socket into non-blocking mode]) + if test "x$ac_cv_func_fcntl_o_nonblock" = "xyes"; then + tst_method="fcntl O_NONBLOCK" + elif test "x$ac_cv_func_ioctl_fionbio" = "xyes"; then + tst_method="ioctl FIONBIO" + elif test "x$ac_cv_func_ioctlsocket_fionbio" = "xyes"; then + tst_method="ioctlsocket FIONBIO" + elif test "x$ac_cv_func_ioctlsocket_camel_fionbio" = "xyes"; then + tst_method="IoctlSocket FIONBIO" + elif test "x$ac_cv_func_setsockopt_so_nonblock" = "xyes"; then + tst_method="setsockopt SO_NONBLOCK" + fi + AC_MSG_RESULT([$tst_method]) + if test "$tst_method" = "unknown"; then + AC_MSG_WARN([cannot determine non-blocking socket method.]) + fi + fi + if test "$tst_method" = "unknown"; then + AC_DEFINE_UNQUOTED(USE_BLOCKING_SOCKETS, 1, + [Define to disable non-blocking sockets.]) + AC_MSG_WARN([non-blocking sockets disabled.]) + fi +]) + diff --git a/m4/curl-functions.m4 b/m4/curl-functions.m4 index 9b0d08018..118b55785 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 34 +# serial 35 dnl CURL_INCLUDES_ARPA_INET @@ -52,6 +52,30 @@ curl_includes_arpa_inet="\ ]) +dnl CURL_INCLUDES_FCNTL +dnl ------------------------------------------------- +dnl Set up variable with list of headers that must be +dnl included when fcntl.h is to be included. + +AC_DEFUN([CURL_INCLUDES_FCNTL], [ +curl_includes_fcntl="\ +/* includes start */ +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif +#ifdef HAVE_STROPTS_H +# include <fcntl.h> +#endif +/* includes end */" + AC_CHECK_HEADERS( + sys/types.h unistd.h fcntl.h, + [], [], [$curl_includes_fcntl]) +]) + + dnl CURL_INCLUDES_IFADDRS dnl ------------------------------------------------- dnl Set up variable with list of headers that must be @@ -208,6 +232,36 @@ curl_includes_string="\ ]) +dnl CURL_INCLUDES_STROPTS +dnl ------------------------------------------------- +dnl Set up variable with list of headers that must be +dnl included when stropts.h is to be included. + +AC_DEFUN([CURL_INCLUDES_STROPTS], [ +curl_includes_stropts="\ +/* includes start */ +#ifdef HAVE_SYS_TYPES_H +# include <sys/types.h> +#endif +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif +#ifdef HAVE_SYS_SOCKET_H +# include <sys/socket.h> +#endif +#ifdef HAVE_SYS_IOCTL_H +# include <sys/ioctl.h> +#endif +#ifdef HAVE_STROPTS_H +# include <stropts.h> +#endif +/* includes end */" + AC_CHECK_HEADERS( + sys/types.h unistd.h sys/socket.h sys/ioctl.h stropts.h, + [], [], [$curl_includes_stropts]) +]) + + dnl CURL_INCLUDES_SYS_SOCKET dnl ------------------------------------------------- dnl Set up variable with list of headers that must be @@ -440,6 +494,155 @@ AC_DEFUN([CURL_CHECK_FUNC_ALARM], [ ]) +dnl CURL_CHECK_FUNC_FCNTL +dnl ------------------------------------------------- +dnl Verify if fcntl 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_fcntl, then +dnl HAVE_FCNTL will be defined. + +AC_DEFUN([CURL_CHECK_FUNC_FCNTL], [ + AC_REQUIRE([CURL_INCLUDES_FCNTL])dnl + # + tst_links_fcntl="unknown" + tst_proto_fcntl="unknown" + tst_compi_fcntl="unknown" + tst_allow_fcntl="unknown" + # + AC_MSG_CHECKING([if fcntl can be linked]) + AC_LINK_IFELSE([ + AC_LANG_FUNC_LINK_TRY([fcntl]) + ],[ + AC_MSG_RESULT([yes]) + tst_links_fcntl="yes" + ],[ + AC_MSG_RESULT([no]) + tst_links_fcntl="no" + ]) + # + if test "$tst_links_fcntl" = "yes"; then + AC_MSG_CHECKING([if fcntl is prototyped]) + AC_EGREP_CPP([fcntl],[ + $curl_includes_fcntl + ],[ + AC_MSG_RESULT([yes]) + tst_proto_fcntl="yes" + ],[ + AC_MSG_RESULT([no]) + tst_proto_fcntl="no" + ]) + fi + # + if test "$tst_proto_fcntl" = "yes"; then + AC_MSG_CHECKING([if fcntl is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_fcntl + ]],[[ + if(0 != fcntl(0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_fcntl="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_fcntl="no" + ]) + fi + # + if test "$tst_compi_fcntl" = "yes"; then + AC_MSG_CHECKING([if fcntl usage allowed]) + if test "x$curl_disallow_fcntl" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_fcntl="yes" + else + AC_MSG_RESULT([no]) + tst_allow_fcntl="no" + fi + fi + # + AC_MSG_CHECKING([if fcntl might be used]) + if test "$tst_links_fcntl" = "yes" && + test "$tst_proto_fcntl" = "yes" && + test "$tst_compi_fcntl" = "yes" && + test "$tst_allow_fcntl" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_FCNTL, 1, + [Define to 1 if you have the fcntl function.]) + ac_cv_func_fcntl="yes" + CURL_CHECK_FUNC_FCNTL_O_NONBLOCK + else + AC_MSG_RESULT([no]) + ac_cv_func_fcntl="no" + fi +]) + + +dnl CURL_CHECK_FUNC_FCNTL_O_NONBLOCK +dnl ------------------------------------------------- +dnl Verify if fcntl with status flag O_NONBLOCK is +dnl available, can be compiled, and seems to work. If +dnl all of these are true, then HAVE_FCNTL_O_NONBLOCK +dnl will be defined. + +AC_DEFUN([CURL_CHECK_FUNC_FCNTL_O_NONBLOCK], [ + # + tst_compi_fcntl_o_nonblock="unknown" + tst_allow_fcntl_o_nonblock="unknown" + # + case $host_os in + sunos4* | aix3* | beos*) + dnl O_NONBLOCK does not work on these platforms + curl_disallow_fcntl_o_nonblock="yes" + ;; + esac + # + if test "$ac_cv_func_fcntl" = "yes"; then + AC_MSG_CHECKING([if fcntl O_NONBLOCK is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_fcntl + ]],[[ + int flags = 0; + if(0 != fcntl(0, F_SETFL, flags | O_NONBLOCK)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_fcntl_o_nonblock="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_fcntl_o_nonblock="no" + ]) + fi + # + if test "$tst_compi_fcntl_o_nonblock" = "yes"; then + AC_MSG_CHECKING([if fcntl O_NONBLOCK usage allowed]) + if test "x$curl_disallow_fcntl_o_nonblock" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_fcntl_o_nonblock="yes" + else + AC_MSG_RESULT([no]) + tst_allow_fcntl_o_nonblock="no" + fi + fi + # + AC_MSG_CHECKING([if fcntl O_NONBLOCK might be used]) + if test "$tst_compi_fcntl_o_nonblock" = "yes" && + test "$tst_allow_fcntl_o_nonblock" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_FCNTL_O_NONBLOCK, 1, + [Define to 1 if you have a working fcntl O_NONBLOCK function.]) + ac_cv_func_fcntl_o_nonblock="yes" + else + AC_MSG_RESULT([no]) + ac_cv_func_fcntl_o_nonblock="no" + fi +]) + + dnl CURL_CHECK_FUNC_FDOPEN dnl ------------------------------------------------- dnl Verify if fdopen is available, prototyped, and @@ -2120,6 +2323,436 @@ AC_DEFUN([CURL_CHECK_FUNC_INET_PTON], [ ]) +dnl CURL_CHECK_FUNC_IOCTL +dnl ------------------------------------------------- +dnl Verify if ioctl 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_ioctl, then +dnl HAVE_IOCTL will be defined. + +AC_DEFUN([CURL_CHECK_FUNC_IOCTL], [ + AC_REQUIRE([CURL_INCLUDES_STROPTS])dnl + # + tst_links_ioctl="unknown" + tst_proto_ioctl="unknown" + tst_compi_ioctl="unknown" + tst_allow_ioctl="unknown" + # + AC_MSG_CHECKING([if ioctl can be linked]) + AC_LINK_IFELSE([ + AC_LANG_FUNC_LINK_TRY([ioctl]) + ],[ + AC_MSG_RESULT([yes]) + tst_links_ioctl="yes" + ],[ + AC_MSG_RESULT([no]) + tst_links_ioctl="no" + ]) + # + if test "$tst_links_ioctl" = "yes"; then + AC_MSG_CHECKING([if ioctl is prototyped]) + AC_EGREP_CPP([ioctl],[ + $curl_includes_stropts + ],[ + AC_MSG_RESULT([yes]) + tst_proto_ioctl="yes" + ],[ + AC_MSG_RESULT([no]) + tst_proto_ioctl="no" + ]) + fi + # + if test "$tst_proto_ioctl" = "yes"; then + AC_MSG_CHECKING([if ioctl is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_stropts + ]],[[ + if(0 != ioctl(0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_ioctl="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_ioctl="no" + ]) + fi + # + if test "$tst_compi_ioctl" = "yes"; then + AC_MSG_CHECKING([if ioctl usage allowed]) + if test "x$curl_disallow_ioctl" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_ioctl="yes" + else + AC_MSG_RESULT([no]) + tst_allow_ioctl="no" + fi + fi + # + AC_MSG_CHECKING([if ioctl might be used]) + if test "$tst_links_ioctl" = "yes" && + test "$tst_proto_ioctl" = "yes" && + test "$tst_compi_ioctl" = "yes" && + test "$tst_allow_ioctl" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_IOCTL, 1, + [Define to 1 if you have the ioctl function.]) + ac_cv_func_ioctl="yes" + CURL_CHECK_FUNC_IOCTL_FIONBIO + else + AC_MSG_RESULT([no]) + ac_cv_func_ioctl="no" + fi +]) + + +dnl CURL_CHECK_FUNC_IOCTL_FIONBIO +dnl ------------------------------------------------- +dnl Verify if ioctl with the FIONBIO command is +dnl available, can be compiled, and seems to work. If +dnl all of these are true, then HAVE_IOCTL_FIONBIO +dnl will be defined. + +AC_DEFUN([CURL_CHECK_FUNC_IOCTL_FIONBIO], [ + # + tst_compi_ioctl_fionbio="unknown" + tst_allow_ioctl_fionbio="unknown" + # + if test "$ac_cv_func_ioctl" = "yes"; then + AC_MSG_CHECKING([if ioctl FIONBIO is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_stropts + ]],[[ + int flags = 0; + if(0 != ioctl(0, FIONBIO, &flags)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_ioctl_fionbio="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_ioctl_fionbio="no" + ]) + fi + # + if test "$tst_compi_ioctl_fionbio" = "yes"; then + AC_MSG_CHECKING([if ioctl FIONBIO usage allowed]) + if test "x$curl_disallow_ioctl_fionbio" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_ioctl_fionbio="yes" + else + AC_MSG_RESULT([no]) + tst_allow_ioctl_fionbio="no" + fi + fi + # + AC_MSG_CHECKING([if ioctl FIONBIO might be used]) + if test "$tst_compi_ioctl_fionbio" = "yes" && + test "$tst_allow_ioctl_fionbio" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_IOCTL_FIONBIO, 1, + [Define to 1 if you have a working ioctl FIONBIO function.]) + ac_cv_func_ioctl_fionbio="yes" + else + AC_MSG_RESULT([no]) + ac_cv_func_ioctl_fionbio="no" + fi +]) + + +dnl CURL_CHECK_FUNC_IOCTLSOCKET +dnl ------------------------------------------------- +dnl Verify if ioctlsocket 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_ioctlsocket, then +dnl HAVE_IOCTLSOCKET will be defined. + +AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET], [ + AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl + # + tst_links_ioctlsocket="unknown" + tst_proto_ioctlsocket="unknown" + tst_compi_ioctlsocket="unknown" + tst_allow_ioctlsocket="unknown" + # + AC_MSG_CHECKING([if ioctlsocket can be linked]) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_winsock2 + ]],[[ + if(0 != ioctlsocket(0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_links_ioctlsocket="yes" + ],[ + AC_MSG_RESULT([no]) + tst_links_ioctlsocket="no" + ]) + # + if test "$tst_links_ioctlsocket" = "yes"; then + AC_MSG_CHECKING([if ioctlsocket is prototyped]) + AC_EGREP_CPP([ioctlsocket],[ + $curl_includes_winsock2 + ],[ + AC_MSG_RESULT([yes]) + tst_proto_ioctlsocket="yes" + ],[ + AC_MSG_RESULT([no]) + tst_proto_ioctlsocket="no" + ]) + fi + # + if test "$tst_proto_ioctlsocket" = "yes"; then + AC_MSG_CHECKING([if ioctlsocket is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_winsock2 + ]],[[ + if(0 != ioctlsocket(0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_ioctlsocket="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_ioctlsocket="no" + ]) + fi + # + if test "$tst_compi_ioctlsocket" = "yes"; then + AC_MSG_CHECKING([if ioctlsocket usage allowed]) + if test "x$curl_disallow_ioctlsocket" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_ioctlsocket="yes" + else + AC_MSG_RESULT([no]) + tst_allow_ioctlsocket="no" + fi + fi + # + AC_MSG_CHECKING([if ioctlsocket might be used]) + if test "$tst_links_ioctlsocket" = "yes" && + test "$tst_proto_ioctlsocket" = "yes" && + test "$tst_compi_ioctlsocket" = "yes" && + test "$tst_allow_ioctlsocket" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET, 1, + [Define to 1 if you have the ioctlsocket function.]) + ac_cv_func_ioctlsocket="yes" + CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO + else + AC_MSG_RESULT([no]) + ac_cv_func_ioctlsocket="no" + fi +]) + + +dnl CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO +dnl ------------------------------------------------- +dnl Verify if ioctlsocket with the FIONBIO command is +dnl available, can be compiled, and seems to work. If +dnl all of these are true, then HAVE_IOCTLSOCKET_FIONBIO +dnl will be defined. + +AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_FIONBIO], [ + # + tst_compi_ioctlsocket_fionbio="unknown" + tst_allow_ioctlsocket_fionbio="unknown" + # + if test "$ac_cv_func_ioctlsocket" = "yes"; then + AC_MSG_CHECKING([if ioctlsocket FIONBIO is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_winsock2 + ]],[[ + int flags = 0; + if(0 != ioctlsocket(0, FIONBIO, &flags)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_ioctlsocket_fionbio="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_ioctlsocket_fionbio="no" + ]) + fi + # + if test "$tst_compi_ioctlsocket_fionbio" = "yes"; then + AC_MSG_CHECKING([if ioctlsocket FIONBIO usage allowed]) + if test "x$curl_disallow_ioctlsocket_fionbio" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_ioctlsocket_fionbio="yes" + else + AC_MSG_RESULT([no]) + tst_allow_ioctlsocket_fionbio="no" + fi + fi + # + AC_MSG_CHECKING([if ioctlsocket FIONBIO might be used]) + if test "$tst_compi_ioctlsocket_fionbio" = "yes" && + test "$tst_allow_ioctlsocket_fionbio" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_FIONBIO, 1, + [Define to 1 if you have a working ioctlsocket FIONBIO function.]) + ac_cv_func_ioctlsocket_fionbio="yes" + else + AC_MSG_RESULT([no]) + ac_cv_func_ioctlsocket_fionbio="no" + fi +]) + + +dnl CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL +dnl ------------------------------------------------- +dnl Verify if IoctlSocket 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_ioctlsocket_camel, +dnl then HAVE_IOCTLSOCKET_CAMEL will be defined. + +AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL], [ + AC_REQUIRE([CURL_INCLUDES_STROPTS])dnl + # + tst_links_ioctlsocket_camel="unknown" + tst_proto_ioctlsocket_camel="unknown" + tst_compi_ioctlsocket_camel="unknown" + tst_allow_ioctlsocket_camel="unknown" + # + AC_MSG_CHECKING([if IoctlSocket can be linked]) + AC_LINK_IFELSE([ + AC_LANG_FUNC_LINK_TRY([IoctlSocket]) + ],[ + AC_MSG_RESULT([yes]) + tst_links_ioctlsocket_camel="yes" + ],[ + AC_MSG_RESULT([no]) + tst_links_ioctlsocket_camel="no" + ]) + # + if test "$tst_links_ioctlsocket_camel" = "yes"; then + AC_MSG_CHECKING([if IoctlSocket is prototyped]) + AC_EGREP_CPP([IoctlSocket],[ + $curl_includes_stropts + ],[ + AC_MSG_RESULT([yes]) + tst_proto_ioctlsocket_camel="yes" + ],[ + AC_MSG_RESULT([no]) + tst_proto_ioctlsocket_camel="no" + ]) + fi + # + if test "$tst_proto_ioctlsocket_camel" = "yes"; then + AC_MSG_CHECKING([if IoctlSocket is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_stropts + ]],[[ + if(0 != IoctlSocket(0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_ioctlsocket_camel="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_ioctlsocket_camel="no" + ]) + fi + # + if test "$tst_compi_ioctlsocket_camel" = "yes"; then + AC_MSG_CHECKING([if IoctlSocket usage allowed]) + if test "x$curl_disallow_ioctlsocket_camel" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_ioctlsocket_camel="yes" + else + AC_MSG_RESULT([no]) + tst_allow_ioctlsocket_camel="no" + fi + fi + # + AC_MSG_CHECKING([if IoctlSocket might be used]) + if test "$tst_links_ioctlsocket_camel" = "yes" && + test "$tst_proto_ioctlsocket_camel" = "yes" && + test "$tst_compi_ioctlsocket_camel" = "yes" && + test "$tst_allow_ioctlsocket_camel" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL, 1, + [Define to 1 if you have the IoctlSocket camel case function.]) + ac_cv_func_ioctlsocket_camel="yes" + CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO + else + AC_MSG_RESULT([no]) + ac_cv_func_ioctlsocket_camel="no" + fi +]) + + +dnl CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO +dnl ------------------------------------------------- +dnl Verify if IoctlSocket with FIONBIO command is available, +dnl can be compiled, and seems to work. If all of these are +dnl true, then HAVE_IOCTLSOCKET_CAMEL_FIONBIO will be defined. + +AC_DEFUN([CURL_CHECK_FUNC_IOCTLSOCKET_CAMEL_FIONBIO], [ + # + tst_compi_ioctlsocket_camel_fionbio="unknown" + tst_allow_ioctlsocket_camel_fionbio="unknown" + # + if test "$ac_cv_func_ioctlsocket_camel" = "yes"; then + AC_MSG_CHECKING([if IoctlSocket FIONBIO is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_stropts + ]],[[ + long flags = 0; + if(0 != ioctlsocket(0, FIONBIO, &flags)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_ioctlsocket_camel_fionbio="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_ioctlsocket_camel_fionbio="no" + ]) + fi + # + if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes"; then + AC_MSG_CHECKING([if IoctlSocket FIONBIO usage allowed]) + if test "x$curl_disallow_ioctlsocket_camel_fionbio" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_ioctlsocket_camel_fionbio="yes" + else + AC_MSG_RESULT([no]) + tst_allow_ioctlsocket_camel_fionbio="no" + fi + fi + # + AC_MSG_CHECKING([if IoctlSocket FIONBIO might be used]) + if test "$tst_compi_ioctlsocket_camel_fionbio" = "yes" && + test "$tst_allow_ioctlsocket_camel_fionbio" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_IOCTLSOCKET_CAMEL_FIONBIO, 1, + [Define to 1 if you have a working IoctlSocket camel case FIONBIO function.]) + ac_cv_func_ioctlsocket_camel_fionbio="yes" + else + AC_MSG_RESULT([no]) + ac_cv_func_ioctlsocket_camel_fionbio="no" + fi +]) + + dnl CURL_CHECK_FUNC_LOCALTIME_R dnl ------------------------------------------------- dnl Verify if localtime_r is available, prototyped, can @@ -2236,6 +2869,157 @@ AC_DEFUN([CURL_CHECK_FUNC_LOCALTIME_R], [ ]) +dnl CURL_CHECK_FUNC_SETSOCKOPT +dnl ------------------------------------------------- +dnl Verify if setsockopt 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_setsockopt, then +dnl HAVE_SETSOCKOPT will be defined. + +AC_DEFUN([CURL_CHECK_FUNC_SETSOCKOPT], [ + AC_REQUIRE([CURL_INCLUDES_WINSOCK2])dnl + AC_REQUIRE([CURL_INCLUDES_SYS_SOCKET])dnl + # + tst_links_setsockopt="unknown" + tst_proto_setsockopt="unknown" + tst_compi_setsockopt="unknown" + tst_allow_setsockopt="unknown" + # + AC_MSG_CHECKING([if setsockopt can be linked]) + AC_LINK_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_winsock2 + $curl_includes_sys_socket + ]],[[ + if(0 != setsockopt(0, 0, 0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_links_setsockopt="yes" + ],[ + AC_MSG_RESULT([no]) + tst_links_setsockopt="no" + ]) + # + if test "$tst_links_setsockopt" = "yes"; then + AC_MSG_CHECKING([if setsockopt is prototyped]) + AC_EGREP_CPP([setsockopt],[ + $curl_includes_winsock2 + $curl_includes_sys_socket + ],[ + AC_MSG_RESULT([yes]) + tst_proto_setsockopt="yes" + ],[ + AC_MSG_RESULT([no]) + tst_proto_setsockopt="no" + ]) + fi + # + if test "$tst_proto_setsockopt" = "yes"; then + AC_MSG_CHECKING([if setsockopt is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_winsock2 + $curl_includes_sys_socket + ]],[[ + if(0 != setsockopt(0, 0, 0, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_setsockopt="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_setsockopt="no" + ]) + fi + # + if test "$tst_compi_setsockopt" = "yes"; then + AC_MSG_CHECKING([if setsockopt usage allowed]) + if test "x$curl_disallow_setsockopt" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_setsockopt="yes" + else + AC_MSG_RESULT([no]) + tst_allow_setsockopt="no" + fi + fi + # + AC_MSG_CHECKING([if setsockopt might be used]) + if test "$tst_links_setsockopt" = "yes" && + test "$tst_proto_setsockopt" = "yes" && + test "$tst_compi_setsockopt" = "yes" && + test "$tst_allow_setsockopt" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT, 1, + [Define to 1 if you have the setsockopt function.]) + ac_cv_func_setsockopt="yes" + CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK + else + AC_MSG_RESULT([no]) + ac_cv_func_setsockopt="no" + fi +]) + + +dnl CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK +dnl ------------------------------------------------- +dnl Verify if setsockopt with the SO_NONBLOCK command is +dnl available, can be compiled, and seems to work. If +dnl all of these are true, then HAVE_SETSOCKOPT_SO_NONBLOCK +dnl will be defined. + +AC_DEFUN([CURL_CHECK_FUNC_SETSOCKOPT_SO_NONBLOCK], [ + # + tst_compi_setsockopt_so_nonblock="unknown" + tst_allow_setsockopt_so_nonblock="unknown" + # + if test "$ac_cv_func_setsockopt" = "yes"; then + AC_MSG_CHECKING([if setsockopt SO_NONBLOCK is compilable]) + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([[ + $curl_includes_winsock2 + $curl_includes_sys_socket + ]],[[ + if(0 != setsockopt(0, SOL_SOCKET, SO_NONBLOCK, 0, 0)) + return 1; + ]]) + ],[ + AC_MSG_RESULT([yes]) + tst_compi_setsockopt_so_nonblock="yes" + ],[ + AC_MSG_RESULT([no]) + tst_compi_setsockopt_so_nonblock="no" + ]) + fi + # + if test "$tst_compi_setsockopt_so_nonblock" = "yes"; then + AC_MSG_CHECKING([if setsockopt SO_NONBLOCK usage allowed]) + if test "x$curl_disallow_setsockopt_so_nonblock" != "xyes"; then + AC_MSG_RESULT([yes]) + tst_allow_setsockopt_so_nonblock="yes" + else + AC_MSG_RESULT([no]) + tst_allow_setsockopt_so_nonblock="no" + fi + fi + # + AC_MSG_CHECKING([if setsockopt SO_NONBLOCK might be used]) + if test "$tst_compi_setsockopt_so_nonblock" = "yes" && + test "$tst_allow_setsockopt_so_nonblock" = "yes"; then + AC_MSG_RESULT([yes]) + AC_DEFINE_UNQUOTED(HAVE_SETSOCKOPT_SO_NONBLOCK, 1, + [Define to 1 if you have a working setsockopt SO_NONBLOCK function.]) + ac_cv_func_setsockopt_so_nonblock="yes" + else + AC_MSG_RESULT([no]) + ac_cv_func_setsockopt_so_nonblock="no" + fi +]) + + dnl CURL_CHECK_FUNC_SIGACTION dnl ------------------------------------------------- dnl Verify if sigaction is available, prototyped, and diff --git a/packages/vms/config-vms.h b/packages/vms/config-vms.h index 7efbc3c0d..fe51c9a72 100644 --- a/packages/vms/config-vms.h +++ b/packages/vms/config-vms.h @@ -61,6 +61,12 @@ /* Define if you have the inet_addr function. */ #define HAVE_INET_ADDR 1 +/* Define if you have the ioctl function. */ +#define HAVE_IOCTL 1 + +/* Define if you have a working ioctl FIONBIO function. */ +#define HAVE_IOCTL_FIONBIO 1 + /* Define if you have the perror function. */ #define HAVE_PERROR 1 @@ -247,8 +253,6 @@ /* Define if you have the <memory.h> header file. */ #define HAVE_MEMORY_H 1 -#define HAVE_FIONBIO 1 - /* Define if you have the `sigsetjmp' function. */ #define HAVE_SIGSETJMP 1 diff --git a/src/Makefile.netware b/src/Makefile.netware index 1ec0b8254..6b02935f2 100644 --- a/src/Makefile.netware +++ b/src/Makefile.netware @@ -449,12 +449,13 @@ endif @echo $(DL)#define HAVE_ASSERT_H 1$(DL) >> $@ @echo $(DL)#define HAVE_ERR_H 1$(DL) >> $@ @echo $(DL)#define HAVE_FCNTL_H 1$(DL) >> $@ - @echo $(DL)#define HAVE_FIONBIO 1$(DL) >> $@ @echo $(DL)#define HAVE_GETHOSTBYADDR 1$(DL) >> $@ @echo $(DL)#define HAVE_GETHOSTBYNAME 1$(DL) >> $@ @echo $(DL)#define HAVE_GETPROTOBYNAME 1$(DL) >> $@ @echo $(DL)#define HAVE_GMTIME_R 1$(DL) >> $@ @echo $(DL)#define HAVE_INET_ADDR 1$(DL) >> $@ + @echo $(DL)#define HAVE_IOCTL 1$(DL) >> $@ + @echo $(DL)#define HAVE_IOCTL_FIONBIO 1$(DL) >> $@ @echo $(DL)#define HAVE_LL 1$(DL) >> $@ @echo $(DL)#define HAVE_LOCALE_H 1$(DL) >> $@ @echo $(DL)#define HAVE_LOCALTIME_R 1$(DL) >> $@ diff --git a/src/config-riscos.h b/src/config-riscos.h index bb27a0d02..dc5a4c7d6 100644 --- a/src/config-riscos.h +++ b/src/config-riscos.h @@ -374,5 +374,8 @@ #define IOCTL_3_ARGS -#define HAVE_FIONBIO +/* Define if you have the ioctl function. */ +#define HAVE_IOCTL +/* Define if you have a working ioctl FIONBIO function. */ +#define HAVE_IOCTL_FIONBIO diff --git a/src/config-win32.h b/src/config-win32.h index 8b18bd5c0..337d4e798 100644 --- a/src/config-win32.h +++ b/src/config-win32.h @@ -72,15 +72,21 @@ /* FUNCTIONS */ /* ---------------------------------------------------------------- */ -/* Define if you have the setmode function. */ -#define HAVE_SETMODE 1 - /* Define if you have the ftruncate function. */ #define HAVE_FTRUNCATE 1 +/* Define if you have the ioctlsocket function. */ +#define HAVE_IOCTLSOCKET 1 + +/* Define if you have a working ioctlsocket FIONBIO function. */ +#define HAVE_IOCTLSOCKET_FIONBIO 1 + /* Define if you have the setlocale function. */ #define HAVE_SETLOCALE 1 +/* Define if you have the setmode function. */ +#define HAVE_SETMODE 1 + /* Define if you have the strcasecmp function. */ /* #define HAVE_STRCASECMP 1 */ |