summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@dtucker.net>2020-01-13 23:42:52 +0100
committerDarren Tucker <dtucker@dtucker.net>2020-01-14 04:28:01 +0100
commite0cedcad51fe02683943bf4f1ad2961aa3f35313 (patch)
treecb8a3197f708f4b1b51809661ec885689521f2bc
parentUpdate depend to remove rmd160.h. (diff)
downloadopenssh-e0cedcad51fe02683943bf4f1ad2961aa3f35313.tar.xz
openssh-e0cedcad51fe02683943bf4f1ad2961aa3f35313.zip
Improve search for 'struct timespec'.
Make struct timespec test consistent with existing timeval test. Include time.h for timespec in compat header where required.
-rw-r--r--configure.ac25
-rw-r--r--openbsd-compat/bsd-misc.h2
2 files changed, 26 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index a33acac85..b1b3bdacf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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" && \
diff --git a/openbsd-compat/bsd-misc.h b/openbsd-compat/bsd-misc.h
index 7bf7b048a..3a7dd6f4c 100644
--- a/openbsd-compat/bsd-misc.h
+++ b/openbsd-compat/bsd-misc.h
@@ -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