Permalink
Browse files

Refactor configure script detection of functions used to set sockets …

…into

non-blocking mode, and decouple function detection from function capability.
  • Loading branch information...
1 parent ae6530e commit 17d2a464ad42c47ec37870e4b01a18ef5593877f @yangtse yangtse committed Nov 13, 2008
View
@@ -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)
View
@@ -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()
View
@@ -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' \
@@ -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) >> $@
View
@@ -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()
Oops, something went wrong.

0 comments on commit 17d2a46

Please sign in to comment.