mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 09:21:50 -05:00
configure: include <time.h> unconditionally
In 2682e5f5, several instances of AC_HEADER_TIME were removed since it is a deprecated autoconf macro. However, this was the macro that defined TIME_WITH_SYS_TIME, which was used to indicate that <time.h> can be included alongside <sys/time.h>. TIME_WITH_SYS_TIME is still used in the configure test body and since it is no longer defined, <time.h> is *not* included on systems that have <sys/time.h>. In particular, at least on musl libc and glibc, <sys/time.h> does not implicitly include <time.h> and does not declare clock_gettime, gmtime_r, or localtime_r. This causes configure to fail to detect those functions. The AC_HEADER_TIME macro deprecation text says > All current systems provide time.h; it need not be checked for. > Not all systems provide sys/time.h, but those that do, all allow > you to include it and time.h simultaneously. So, to fix this issue, simply include <time.h> unconditionally when testing for time-related functions and in libcurl, and don't bother checking for it. Closes #6859
This commit is contained in:
parent
812fce9dcf
commit
eaa1d73229
52
acinclude.m4
52
acinclude.m4
@ -1410,7 +1410,7 @@ dnl Check for timeval struct
|
||||
AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
|
||||
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 sys/socket.h)
|
||||
AC_CHECK_HEADERS(sys/types.h sys/time.h sys/socket.h)
|
||||
AC_CACHE_CHECK([for struct timeval], [curl_cv_struct_timeval], [
|
||||
AC_COMPILE_IFELSE([
|
||||
AC_LANG_PROGRAM([[
|
||||
@ -1433,14 +1433,8 @@ AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
#endif
|
||||
#include <time.h>
|
||||
#endif
|
||||
#else
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
@ -1605,7 +1599,7 @@ dnl -------------------------------------------------
|
||||
dnl Check if monotonic clock_gettime is available.
|
||||
|
||||
AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
|
||||
AC_CHECK_HEADERS(sys/types.h sys/time.h time.h)
|
||||
AC_CHECK_HEADERS(sys/types.h sys/time.h)
|
||||
AC_MSG_CHECKING([for monotonic clock_gettime])
|
||||
#
|
||||
if test "x$dontwant_rt" = "xno" ; then
|
||||
@ -1616,14 +1610,8 @@ AC_DEFUN([CURL_CHECK_FUNC_CLOCK_GETTIME_MONOTONIC], [
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
#endif
|
||||
#include <time.h>
|
||||
#endif
|
||||
#else
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
#endif
|
||||
]],[[
|
||||
struct timespec ts;
|
||||
(void)clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
@ -1670,14 +1658,8 @@ AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
#endif
|
||||
#include <time.h>
|
||||
#endif
|
||||
#else
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
#endif
|
||||
]],[[
|
||||
struct timespec ts;
|
||||
(void)clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
@ -1725,14 +1707,8 @@ AC_DEFUN([CURL_CHECK_LIBS_CLOCK_GETTIME_MONOTONIC], [
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
#endif
|
||||
#include <time.h>
|
||||
#endif
|
||||
#else
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
#endif
|
||||
]],[[
|
||||
struct timespec ts;
|
||||
if (0 == clock_gettime(CLOCK_MONOTONIC, &ts))
|
||||
@ -1902,14 +1878,8 @@ AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
#endif
|
||||
#include <time.h>
|
||||
#endif
|
||||
#else
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
#endif
|
||||
#ifndef HAVE_WINDOWS_H
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
@ -1967,14 +1937,8 @@ struct Library *SocketBase = NULL;
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
#endif
|
||||
#include <time.h>
|
||||
#endif
|
||||
#else
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
#endif
|
||||
#ifndef HAVE_WINDOWS_H
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
|
@ -4277,7 +4277,6 @@ AC_CHECK_HEADERS(
|
||||
sgtty.h \
|
||||
fcntl.h \
|
||||
alloca.h \
|
||||
time.h \
|
||||
io.h \
|
||||
pwd.h \
|
||||
utime.h \
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
@ -55,13 +56,6 @@
|
||||
|
||||
#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
|
||||
|
||||
#ifdef WIN32
|
||||
|
@ -453,17 +453,11 @@ curl_includes_time="\
|
||||
#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
|
||||
#include <time.h>
|
||||
/* includes end */"
|
||||
AC_CHECK_HEADERS(
|
||||
sys/types.h sys/time.h time.h,
|
||||
sys/types.h sys/time.h,
|
||||
[], [], [$curl_includes_time])
|
||||
])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user