]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
Check for struct timeval at configuration time
authorYang Tse <yangsita@gmail.com>
Fri, 13 Oct 2006 01:35:14 +0000 (01:35 +0000)
committerYang Tse <yangsita@gmail.com>
Fri, 13 Oct 2006 01:35:14 +0000 (01:35 +0000)
acinclude.m4
ares/acinclude.m4
ares/configure.ac
configure.ac
lib/timeval.h

index f12a761dda1b0b1b9ca699c1887e93c04d604feb..7317974bd1c26eaaa88379c8f939c0d9932f7d25 100644 (file)
@@ -976,6 +976,65 @@ AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
 ]) # AC_DEFUN
 
 
+dnl CURL_CHECK_STRUCT_TIMEVAL
+dnl -------------------------------------------------
+dnl Check for timeval struct
+
+AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
+  AC_REQUIRE([AC_HEADER_TIME])dnl
+  AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
+  AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
+  AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
+  AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([
+#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
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#ifdef TIME_WITH_SYS_TIME
+#include <time.h>
+#endif
+#else
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+#endif
+      ],[
+        struct timeval ts;
+        ts.tv_sec  = 0;
+        ts.tv_usec = 0;
+      ])
+    ],[
+      ac_cv_struct_timeval="yes"
+    ],[
+      ac_cv_struct_timeval="no"
+    ])
+  ])
+  case "$ac_cv_struct_timeval" in
+    yes)
+      AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
+        [Define to 1 if you have the timeval struct.])
+      ;;
+  esac
+]) # AC_DEFUN
+
+
 dnl CURL_CHECK_NONBLOCKING_SOCKET
 dnl -------------------------------------------------
 dnl Check for how to set a socket to non-blocking state. There seems to exist
index 267d28dc66fdc09ed4f77a1410772911029ef658..9a2840401d173ac957a05b3d7b579d0c427975d4 100644 (file)
@@ -954,6 +954,65 @@ AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
 ]) # AC_DEFUN
 
 
+dnl CURL_CHECK_STRUCT_TIMEVAL
+dnl -------------------------------------------------
+dnl Check for timeval struct
+
+AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
+  AC_REQUIRE([AC_HEADER_TIME])dnl
+  AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK])dnl
+  AC_REQUIRE([CURL_CHECK_HEADER_WINSOCK2])dnl
+  AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
+  AC_CACHE_CHECK([for struct timeval], [ac_cv_struct_timeval], [
+    AC_COMPILE_IFELSE([
+      AC_LANG_PROGRAM([
+#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
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#ifdef TIME_WITH_SYS_TIME
+#include <time.h>
+#endif
+#else
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+#endif
+      ],[
+        struct timeval ts;
+        ts.tv_sec  = 0;
+        ts.tv_usec = 0;
+      ])
+    ],[
+      ac_cv_struct_timeval="yes"
+    ],[
+      ac_cv_struct_timeval="no"
+    ])
+  ])
+  case "$ac_cv_struct_timeval" in
+    yes)
+      AC_DEFINE_UNQUOTED(HAVE_STRUCT_TIMEVAL, 1,
+        [Define to 1 if you have the timeval struct.])
+      ;;
+  esac
+]) # AC_DEFUN
+
+
 dnl CURL_CHECK_NONBLOCKING_SOCKET
 dnl -------------------------------------------------
 dnl Check for how to set a socket to non-blocking state. There seems to exist
index 5f46549df529adb3846864d0729bf1bfeb807fa2..79292cebcd1c18bcdfd07de217fd955f58e2e9f3 100644 (file)
@@ -265,6 +265,7 @@ dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_TYPE_SIZE_T
 AC_HEADER_TIME
+CURL_CHECK_STRUCT_TIMEVAL
 
 AC_CHECK_SIZEOF(size_t)
 AC_CHECK_SIZEOF(long)
index 52d2818343ccf598a25ffed92f1f497344049603..31c00a38496575746477735215779d04c4b54e20 100644 (file)
@@ -1527,6 +1527,7 @@ dnl Checks for typedefs, structures, and compiler characteristics.
 AC_C_CONST
 AC_TYPE_SIZE_T
 AC_HEADER_TIME
+CURL_CHECK_STRUCT_TIMEVAL
 
 AC_CHECK_SIZEOF(curl_off_t, ,[
 #include <stdio.h>
index 5decc892b13e0056d254341e4d54eaeab2f1d8ad..0792064a78a7d295e8a0f602cfd1ff1090079400 100644 (file)
 #endif
 #endif
 
+#ifndef HAVE_STRUCT_TIMEVAL
+
+/* TODO: define HAVE_STRUCT_TIMEVAL as appropriate in our config files for
+         platforms that lack autotools support. Afterwards remove or simplify
+         the following logic which will become redundant */
+
 #ifndef HAVE_GETTIMEOFDAY
 #if !defined(_WINSOCKAPI_) && !defined(__MINGW32__) && !defined(_AMIGASF) && \
     !defined(__LCC__) && !defined(__WATCOMC__) && !defined(__POCC__) && \
@@ -51,6 +57,7 @@ struct timeval {
 };
 #endif
 #endif
+#endif
 
 struct timeval curlx_tvnow(void);