]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
Improve search for 'struct timespec'.
authorDarren Tucker <dtucker@dtucker.net>
Mon, 13 Jan 2020 22:42:52 +0000 (09:42 +1100)
committerDarren Tucker <dtucker@dtucker.net>
Tue, 14 Jan 2020 03:28:01 +0000 (14:28 +1100)
Make struct timespec test consistent with existing timeval test.
Include time.h for timespec in compat header where required.

configure.ac
openbsd-compat/bsd-misc.h

index a33acac85e8e3329ae39385d21765f43d4a35be2..b1b3bdacf6d7182ff9b1a86bbfee30df1e762abc 100644 (file)
@@ -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" && \
index 7bf7b048a56e185855a2b363a1da1d2548690dc4..3a7dd6f4c30e4c70ab3de4d4e8a9d0661b7f2105 100644 (file)
@@ -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