]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
configure script now checks availability of the alarm() function
authorYang Tse <yangsita@gmail.com>
Fri, 19 Sep 2008 18:39:24 +0000 (18:39 +0000)
committerYang Tse <yangsita@gmail.com>
Fri, 19 Sep 2008 18:39:24 +0000 (18:39 +0000)
CHANGES
configure.ac
lib/setup.h
m4/curl-functions.m4

diff --git a/CHANGES b/CHANGES
index 7e8a5ac7ecb8f95559b4dc246577c7db01e3323f..4eb7cd8c363fa76d8245da1132ed413fddccc817 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,9 @@
 
                                   Changelog
 
+Yang Tse (19 Sep 2008)
+- configure script now checks availability of the alarm() function.
+
 Daniel Fandrich (18 Sep 2008)
 - Don't bother to install a SIGALRM handler unless alarm() is available.
   Also, leave the existing SIGALRM handler alone if the timeout is too small
index c39fbd9d66cdb7c6ff3b19302652e511e502e2a7..2a1bce95d143ece19ddbe0ea178202ffd7cc1531 100644 (file)
@@ -2045,6 +2045,7 @@ CURL_CHECK_FUNC_RECVFROM
 CURL_CHECK_FUNC_SEND
 CURL_CHECK_MSG_NOSIGNAL
 
+CURL_CHECK_FUNC_ALARM
 CURL_CHECK_FUNC_FDOPEN
 CURL_CHECK_FUNC_FTRUNCATE
 CURL_CHECK_FUNC_GETHOSTBYADDR_R
index 59da0e0d341dc11ea6178771fb6d532e86cc8938..df253662f65212824feb4966844f9505044d4899 100644 (file)
 
 #ifdef WIN32
 
-#if !defined(__CYGWIN__)
-#define sclose(x) closesocket(x)
-
-#undef HAVE_ALARM
-#else
-     /* gcc-for-win is still good :) */
-#define sclose(x) close(x)
-#define HAVE_ALARM
-#endif /* !GNU or mingw */
+#  if !defined(__CYGWIN__)
+#    define sclose(x) closesocket(x)
+#  else
+#    define sclose(x) close(x)
+#  endif
 
-#define DIR_CHAR      "\\"
-#define DOT_CHAR      "_"
+#  define DIR_CHAR      "\\"
+#  define DOT_CHAR      "_"
 
 #else /* WIN32 */
 
-#ifdef MSDOS  /* Watt-32 */
-#include <sys/ioctl.h>
-#define sclose(x)         close_s(x)
-#define select(n,r,w,x,t) select_s(n,r,w,x,t)
-#define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
-#define IOCTL_3_ARGS
-#include <tcp.h>
-#ifdef word
-#undef word
-#endif
-#ifdef byte
-#undef byte
-#endif
-
-#else /* MSDOS */
+#  ifdef MSDOS  /* Watt-32 */
 
-#ifdef __BEOS__
-#define sclose(x) closesocket(x)
-#else /* __BEOS__ */
-#define sclose(x) close(x)
-#endif /* __BEOS__ */
+#    include <sys/ioctl.h>
+#    define sclose(x)         close_s(x)
+#    define select(n,r,w,x,t) select_s(n,r,w,x,t)
+#    define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
+#    define IOCTL_3_ARGS
+#    include <tcp.h>
+#    ifdef word
+#      undef word
+#    endif
+#    ifdef byte
+#      undef byte
+#    endif
 
-#define HAVE_ALARM
+#  else /* MSDOS */
 
-#endif /* MSDOS */
+#    ifdef __BEOS__
+#      define sclose(x) closesocket(x)
+#    else /* __BEOS__ */
+#      define sclose(x) close(x)
+#    endif /* __BEOS__ */
 
-#ifdef _AMIGASF
-#undef HAVE_ALARM
-#undef sclose
-#define sclose(x) CloseSocket(x)
-#endif
+#  endif /* MSDOS */
 
-#ifdef __minix
-/* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
-extern char * strtok_r(char *s, const char *delim, char **last);
-extern struct tm * gmtime_r(const time_t * const timep, struct tm *tmp);
-#endif
+#  ifdef _AMIGASF
+#    undef sclose
+#    define sclose(x) CloseSocket(x)
+#  endif
 
-#ifdef __SYMBIAN32__
-#undef HAVE_ALARM
-#endif
+#  ifdef __minix
+     /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
+     extern char * strtok_r(char *s, const char *delim, char **last);
+     extern struct tm * gmtime_r(const time_t * const timep, struct tm *tmp);
+#  endif
 
-#define DIR_CHAR      "/"
-#ifndef DOT_CHAR
-#define DOT_CHAR      "."
-#endif
+#  define DIR_CHAR      "/"
+#  ifndef DOT_CHAR
+#    define DOT_CHAR      "."
+#  endif
 
-#ifdef MSDOS
-#undef DOT_CHAR
-#define DOT_CHAR      "_"
-#endif
+#  ifdef MSDOS
+#    undef DOT_CHAR
+#    define DOT_CHAR      "_"
+#  endif
 
-#ifndef fileno /* sunos 4 have this as a macro! */
-int fileno( FILE *stream);
-#endif
+#  ifndef fileno /* sunos 4 have this as a macro! */
+     int fileno( FILE *stream);
+#  endif
 
 #endif /* WIN32 */
 
@@ -450,7 +440,6 @@ int netware_init(void);
 #include <sys/bsdskt.h>
 #include <sys/timeval.h>
 #endif
-#undef HAVE_ALARM
 #endif
 
 #if defined(HAVE_LIBIDN) && defined(HAVE_TLD_H)
index 2b11d720e391291079c7c96bd02324b20dd6759c..bb8eef5423ed3dcf8ae2dea900b6222f4ff93d70 100644 (file)
@@ -204,6 +204,91 @@ curl_includes_unistd="\
 ])
 
 
+dnl CURL_CHECK_FUNC_ALARM
+dnl -------------------------------------------------
+dnl Verify if alarm 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_alarm, then
+dnl HAVE_ALARM will be defined.
+
+AC_DEFUN([CURL_CHECK_FUNC_ALARM], [
+  AC_REQUIRE([CURL_INCLUDES_UNISTD])dnl
+  #
+  tst_links_alarm="unknown"
+  tst_proto_alarm="unknown"
+  tst_compi_alarm="unknown"
+  tst_allow_alarm="unknown"
+  #
+  AC_MSG_CHECKING([if alarm can be linked])
+  AC_LINK_IFELSE([
+    AC_LANG_FUNC_LINK_TRY([alarm])
+  ],[
+    AC_MSG_RESULT([yes])
+    tst_links_alarm="yes"
+  ],[
+    AC_MSG_RESULT([no])
+    tst_links_alarm="no"
+  ])
+  #
+  if test "$tst_links_alarm" = "yes"; then
+    AC_MSG_CHECKING([if alarm is prototyped])
+    AC_EGREP_CPP([alarm],[
+      $curl_includes_unistd
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_proto_alarm="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_proto_alarm="no"
+    ])
+  fi
+  #
+  if test "$tst_proto_alarm" = "yes"; then
+    AC_MSG_CHECKING([if alarm is compilable])
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([[
+        $curl_includes_unistd
+      ]],[[
+        if(0 != alarm(0))
+          return 1;
+      ]])
+    ],[
+      AC_MSG_RESULT([yes])
+      tst_compi_alarm="yes"
+    ],[
+      AC_MSG_RESULT([no])
+      tst_compi_alarm="no"
+    ])
+  fi
+  #
+  if test "$tst_compi_alarm" = "yes"; then
+    AC_MSG_CHECKING([if alarm usage allowed])
+    if test "x$curl_disallow_alarm" != "xyes"; then
+      AC_MSG_RESULT([yes])
+      tst_allow_alarm="yes"
+    else
+      AC_MSG_RESULT([no])
+      tst_allow_alarm="no"
+    fi
+  fi
+  #
+  AC_MSG_CHECKING([if alarm might be used])
+  if test "$tst_links_alarm" = "yes" &&
+     test "$tst_proto_alarm" = "yes" &&
+     test "$tst_compi_alarm" = "yes" &&
+     test "$tst_allow_alarm" = "yes"; then
+    AC_MSG_RESULT([yes])
+    AC_DEFINE_UNQUOTED(HAVE_ALARM, 1,
+      [Define to 1 if you have the alarm function.])
+    ac_cv_func_alarm="yes"
+  else
+    AC_MSG_RESULT([no])
+    ac_cv_func_alarm="no"
+  fi
+])
+
+
 dnl CURL_CHECK_FUNC_FDOPEN
 dnl -------------------------------------------------
 dnl Verify if fdopen is available, prototyped, and