configure: drop macro 'AC_HEADER_TIME'
authorAntonio Borneo <borneo.antonio@gmail.com>
Fri, 8 Jan 2021 22:48:43 +0000 (23:48 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Mon, 18 Jan 2021 15:32:46 +0000 (15:32 +0000)
The macro AC_HEADER_TIME has been obsoleted by autoconf 2.70.

Not all systems provide 'sys/time.h', plus some old system didn't
allowed to include both 'time.h' and 'sys/time.h' because 'time.h'
was included by 'sys/time.h' and was not properly protected to
allow multiple inclusion.
The macro AC_HEADER_TIME helps to detect such odd case.
Nowadays all the systems properly protect 'time.h', so its safe to
unconditionally include 'time.h', even if it is also included by
'sys/time.h'.

The case of systems without 'sys/time.h' is already covered by
configure.ac through the directive
AC_CHECK_HEADERS([sys/time.h])

Remove the obsoleted autoconf macro and simplify the code by
including 'time.h' unconditionally and check HAVE_SYS_TIME_H to
include 'sys/time.h'.

Change-Id: Iddb3f3f1d90c22668b97f8e756e1b4f733367a7d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6010
Tested-by: jenkins
Reviewed-by: Marc Schink <dev@zapb.de>
configure.ac
src/helper/system.h
src/helper/time_support.h

index 6d0c7d096df6b8543386a674af762f15e206db38..d7133183c8f2315cadbf7e30288097ee5bdc69fb 100644 (file)
@@ -81,7 +81,6 @@ AC_CHECK_HEADERS([arpa/inet.h ifaddrs.h netinet/in.h netinet/tcp.h net/if.h], []
 
 AC_HEADER_ASSERT
 AC_HEADER_STDBOOL
-AC_HEADER_TIME
 
 AC_C_BIGENDIAN
 
index 97b3443bedb543ac5351ffd0a82fa0aa91ad3236..1aaca3b33e767b4e8a234f23fb87af67cc57e0b7 100644 (file)
 #include <assert.h>
 #include <ctype.h>
 #include <errno.h>
+#include <time.h>
 
-/* +++ AC_HEADER_TIME +++ */
-#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
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
 #endif
-/* --- AC_HEADER_TIME --- */
 
 /* +++ platform specific headers +++ */
 #ifdef _WIN32
index 7abbdb24d21778c0b14d2b2c36c4c80ee045e46d..a9f2dffad0d577a0df3dbb81a9153c8108f6494f 100644 (file)
 #ifndef OPENOCD_HELPER_TIME_SUPPORT_H
 #define OPENOCD_HELPER_TIME_SUPPORT_H
 
-#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
+#include <time.h>
+
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
 #endif
 
 int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y);