Improve search for 'struct timespec'.

Make struct timespec test consistent with existing timeval test.
Include time.h for timespec in compat header where required.
This commit is contained in:
Darren Tucker 2020-01-14 09:42:52 +11:00
Родитель acaf9e0585
Коммит e0cedcad51
2 изменённых файлов: 26 добавлений и 1 удалений

Просмотреть файл

@ -4025,6 +4025,8 @@ if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
[define if you have struct addrinfo data type])
fi
AC_HEADER_TIME
AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <sys/time.h> ]],
[[ struct timeval tv; tv.tv_sec = 1;]])],
@ -4037,7 +4039,28 @@ if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
have_struct_timeval=1
fi
AC_CHECK_TYPES([struct timespec])
AC_CACHE_CHECK([for struct timespec], ac_cv_have_struct_timespec, [
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#ifdef TIME_WITH_SYS_TIME
# include <sys/time.h>
# include <time.h>
#else
# ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
# else
# include <time.h>
# endif
#endif
]],
[[ struct timespec ts; ts.tv_sec = 1;]])],
[ ac_cv_have_struct_timespec="yes" ],
[ ac_cv_have_struct_timespec="no"
])
])
if test "x$ac_cv_have_struct_timespec" = "xyes" ; then
AC_DEFINE([HAVE_STRUCT_TIMESPEC], [1], [define if you have struct timespec])
have_struct_timespec=1
fi
# We need int64_t or else certain parts of the compile will fail.
if test "x$ac_cv_have_int64_t" = "xno" && \

Просмотреть файл

@ -88,10 +88,12 @@ struct timespec {
#endif /* !HAVE_STRUCT_TIMESPEC */
#if !defined(HAVE_NANOSLEEP) && !defined(HAVE_NSLEEP)
# include <time.h>
int nanosleep(const struct timespec *, struct timespec *);
#endif
#ifndef HAVE_UTIMENSAT
# include <time.h>
/* start with the high bits and work down to minimise risk of overlap */
# ifndef AT_SYMLINK_NOFOLLOW
# define AT_SYMLINK_NOFOLLOW 0x80000000