]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
build-sys: use proper check to find if time_t is defined
authorSami Kerola <kerolasa@iki.fi>
Sun, 9 Oct 2016 21:21:34 +0000 (22:21 +0100)
committerSami Kerola <kerolasa@iki.fi>
Tue, 11 Oct 2016 18:29:20 +0000 (19:29 +0100)
The time_t check feels unlikely to be necessary, but perhaps it is useful.
At least it used to be back in 2004.

Reference: 3210151c58dd98731816b57b0e375250aeb8fb6f

configure.ac
curses.c
mtr.h

index 504bfcbf21456b25ca293da63cf561b55764f316..11fece610ef3d09d33702a8e0fc82caff14ea2bf 100644 (file)
@@ -163,6 +163,10 @@ AC_CHECK_TYPE([socklen_t],
 #include <sys/socket.h>
 #endif]])
 
+AC_CHECK_TYPES([time_t], [], [], [[
+#include <time.h>
+]])
+
 # Add C flags to display more warnings
 AC_MSG_CHECKING([for C flags to get more warnings])
 ac_save_CFLAGS="$CFLAGS"
index 16e4916e548433e22fa8d28120876a134a98115c..ca758dddeedde913654967e877fff49f5149d6ff 100644 (file)
--- a/curses.c
+++ b/curses.c
 
 #include "config.h"
 
+#include "mtr.h"
+
 #include <strings.h>
 #include <unistd.h>
 
 #include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
 
 /* MacOSX may need this before socket.h...*/
 #if defined(HAVE_SYS_TYPES_H)
 # include <sys/types.h>
-#else
-/* If a system doesn't have sys/types.h, lets hope that time_t is an int */
-# define time_t int
 #endif
 
 #include <sys/socket.h>
@@ -64,7 +64,6 @@
 #include "display.h"
 #include "utils.h"
 
-#include <time.h>
 
 enum { NUM_FACTORS = 8 };
 static double factors[NUM_FACTORS];
diff --git a/mtr.h b/mtr.h
index 524bba855186c3617b273df6a1538f2fc1a94395..2487ad6e154a54a26368ac26bad737fe526333c9 100644 (file)
--- a/mtr.h
+++ b/mtr.h
@@ -20,6 +20,8 @@
 #ifndef MTR_MTR_H
 #define MTR_MTR_H
 
+#include "config.h"
+
 #include <stdint.h>
 #include <sys/socket.h>
 #include <arpa/inet.h>
@@ -35,6 +37,10 @@ typedef struct in6_addr ip_t;
 typedef struct in_addr ip_t;
 #endif
 
+#ifndef HAVE_TIME_T
+typedef int time_t;
+#endif
+
 /* The __unused__ attribute was added in gcc 3.2.7.  */
 #if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 7)
 # define ATTRIBUTE_UNUSED __attribute__((__unused__))