diff --git a/acinclude.m4 b/acinclude.m4 index 03cdd128e..1e6af4f4b 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -8,6 +8,7 @@ AC_DEFUN([CURL_CHECK_HEADER_WINDOWS], [ AC_CACHE_CHECK([for windows.h], [ac_cv_header_windows_h], [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([ +#undef inline #define WIN32_LEAN_AND_MEAN #include ],[ @@ -35,6 +36,7 @@ AC_DEFUN([CURL_CHECK_HEADER_WINSOCK], [ AC_CACHE_CHECK([for winsock.h], [ac_cv_header_winsock_h], [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([ +#undef inline #define WIN32_LEAN_AND_MEAN #include #include @@ -63,6 +65,7 @@ AC_DEFUN([CURL_CHECK_HEADER_WINSOCK2], [ AC_CACHE_CHECK([for winsock2.h], [ac_cv_header_winsock2_h], [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([ +#undef inline #define WIN32_LEAN_AND_MEAN #include #include @@ -91,6 +94,7 @@ AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [ AC_CACHE_CHECK([for ws2tcpip.h], [ac_cv_header_ws2tcpip_h], [ AC_COMPILE_IFELSE([ AC_LANG_PROGRAM([ +#undef inline #define WIN32_LEAN_AND_MEAN #include #include @@ -111,6 +115,83 @@ AC_DEFUN([CURL_CHECK_HEADER_WS2TCPIP], [ ]) +dnl CURL_CHECK_TYPE_SOCKLEN_T +dnl ------------------------------------------------- +dnl Checks for existing socklen_t type, and provides +dnl an equivalent type if socklen_t is not available +dnl This function is experimental and shall not be +dnl used while this notice is in place -------------- + +AC_DEFUN([CURL_CHECK_TYPE_SOCKLEN_T], [ + AC_REQUIRE([CURL_CHECK_HEADER_WS2TCPIP])dnl + AC_CHECK_TYPE([socklen_t], ,[ + AC_CACHE_CHECK([for socklen_t equivalent bis], + [curl_cv_socklen_t_equiv_bis], [ + curl_cv_socklen_t_equiv_bis= + for arg2 in "struct sockaddr" void; do + for t in int size_t unsigned long "unsigned long"; do + AC_COMPILE_IFELSE([ + AC_LANG_PROGRAM([ +#undef inline +#ifdef HAVE_WINDOWS_H +#define WIN32_LEAN_AND_MEAN +#include +#ifdef HAVE_WINSOCK2_H +#include +#else +#ifdef HAVE_WINSOCK_H +#include +#endif +#endif +#else +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#endif + int getpeername (int, $arg2 *, $t *); + int getsockname (int, $arg2 *, $t *); + int bind (int, $arg2 *, $t *); + int accept (int, $arg2 *, $t *); + ],[ + $t len; + getpeername(0,0,&len); + getsockname(0,0,&len); + bind(0,0,&len); + accept(0,0,&len); + ]) + ],[ + curl_cv_socklen_t_equiv_bis="$t" + break 2 + ]) + done + done + ]) + if test "x$curl_cv_socklen_t_equiv_bis" = "x"; then + AC_MSG_ERROR([Cannot find a type to use in place of socklen_t bis]) + else + AC_DEFINE_UNQUOTED(socklen_t_bis, $curl_cv_socklen_t_equiv_bis, + [type to use in place of socklen_t if not defined]) + fi + ],[ +#ifdef HAVE_WINDOWS_H +#ifdef HAVE_WS2TCPIP_H +#include +#endif +#else +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#endif + ]) +]) + + 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, diff --git a/configure.ac b/configure.ac index 2de3128a7..a0eac1d40 100644 --- a/configure.ac +++ b/configure.ac @@ -289,23 +289,6 @@ AC_HELP_STRING([--disable-manual],[Disable built-in manual]), dnl The actual use of the USE_MANUAL variable is done much later in this dnl script to allow other actions to disable it as well. -dnl ********************************************************************** -dnl Make sure that our checks for headers windows.h winsock.h winsock2.h -dnl and ws2tcpip.h take precedence over any other further check done later. -dnl ********************************************************************** - -dnl Do we have a compilable and valid windows.h header ? -CURL_CHECK_HEADER_WINDOWS - -dnl Do we have a compilable and valid winsock.h header ? -CURL_CHECK_HEADER_WINSOCK - -dnl Do we have a compilable and valid winsock2.h header ? -CURL_CHECK_HEADER_WINSOCK2 - -dnl Do we have a compilable and valid ws2tcpip.h header ? -CURL_CHECK_HEADER_WS2TCPIP - dnl ********************************************************************** dnl Checks for libraries. dnl ********************************************************************** @@ -1411,7 +1394,18 @@ dnl ********************************************************************** dnl Checks for header files. AC_HEADER_STDC -dnl First check for the very most basic headers. Then we can use these +dnl ********************************************************************** +dnl Make sure that our checks for headers windows.h winsock.h winsock2.h +dnl and ws2tcpip.h take precedence over any other further check which +dnl could be done later using AC_CHECK_HEADER or AC_CHECK_HEADERS. +dnl ********************************************************************** + +CURL_CHECK_HEADER_WINDOWS +CURL_CHECK_HEADER_WINSOCK +CURL_CHECK_HEADER_WINSOCK2 +CURL_CHECK_HEADER_WS2TCPIP + +dnl Now check for the very most basic headers. Then we can use these dnl ones as default-headers when checking for the rest! AC_CHECK_HEADERS( sys/types.h \ @@ -1509,6 +1503,9 @@ fi AC_CHECK_TYPE(ssize_t, , AC_DEFINE(ssize_t, int, [the signed version of size_t])) +# Experimental check +CURL_CHECK_TYPE_SOCKLEN_T + TYPE_SOCKLEN_T TYPE_IN_ADDR_T