From: Yang Tse Date: Fri, 13 Oct 2006 01:35:14 +0000 (+0000) Subject: Check for struct timeval at configuration time X-Git-Tag: curl-7_16_0~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32ac4edeedb44cb1c95c522e8366665147d463d5;p=thirdparty%2Fcurl.git Check for struct timeval at configuration time --- diff --git a/acinclude.m4 b/acinclude.m4 index f12a761dda..7317974bd1 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -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 +#ifdef HAVE_WINSOCK2_H +#include +#else +#ifdef HAVE_WINSOCK_H +#include +#endif +#endif +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_TIME_H +#include +#ifdef TIME_WITH_SYS_TIME +#include +#endif +#else +#ifdef HAVE_TIME_H +#include +#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 diff --git a/ares/acinclude.m4 b/ares/acinclude.m4 index 267d28dc66..9a2840401d 100644 --- a/ares/acinclude.m4 +++ b/ares/acinclude.m4 @@ -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 +#ifdef HAVE_WINSOCK2_H +#include +#else +#ifdef HAVE_WINSOCK_H +#include +#endif +#endif +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_TIME_H +#include +#ifdef TIME_WITH_SYS_TIME +#include +#endif +#else +#ifdef HAVE_TIME_H +#include +#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 diff --git a/ares/configure.ac b/ares/configure.ac index 5f46549df5..79292cebcd 100644 --- a/ares/configure.ac +++ b/ares/configure.ac @@ -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) diff --git a/configure.ac b/configure.ac index 52d2818343..31c00a3849 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/lib/timeval.h b/lib/timeval.h index 5decc892b1..0792064a78 100644 --- a/lib/timeval.h +++ b/lib/timeval.h @@ -41,6 +41,12 @@ #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);