REORG: include: move time.h from common/ to haproxy/

This one is included almost everywhere and used to rely on a few other
.h that are not needed (unistd, stdlib, standard.h). It could possibly
make sense to split it into multiple parts to distinguish operations
performed on timers and the internal time accounting, but at this point
it does not appear much important.
diff --git a/contrib/mod_defender/defender.c b/contrib/mod_defender/defender.c
index b552a7c..f3b9055 100644
--- a/contrib/mod_defender/defender.c
+++ b/contrib/mod_defender/defender.c
@@ -21,7 +21,7 @@
 #include <haproxy/api.h>
 #include <common/standard.h>
 #include <common/chunk.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <proto/spoe.h>
 
diff --git a/contrib/modsecurity/modsec_wrapper.c b/contrib/modsecurity/modsec_wrapper.c
index 7ae831e..056da54 100644
--- a/contrib/modsecurity/modsec_wrapper.c
+++ b/contrib/modsecurity/modsec_wrapper.c
@@ -16,7 +16,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <types/global.h>
 #include <types/stream.h>
diff --git a/include/common/time.h b/include/haproxy/time.h
similarity index 98%
rename from include/common/time.h
rename to include/haproxy/time.h
index d6863d4..4f1dc85 100644
--- a/include/common/time.h
+++ b/include/haproxy/time.h
@@ -1,8 +1,8 @@
 /*
- * include/common/time.h
+ * include/haproxy/time.h
  * Time calculation functions and macros.
  *
- * Copyright (C) 2000-2011 Willy Tarreau - w@1wt.eu
+ * Copyright (C) 2000-2020 Willy Tarreau - w@1wt.eu
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -19,15 +19,13 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef _COMMON_TIME_H
-#define _COMMON_TIME_H
+#ifndef _HAPROXY_TIME_H
+#define _HAPROXY_TIME_H
 
-#include <stdlib.h>
-#include <unistd.h>
 #include <sys/time.h>
+#include <time.h>
 #include <haproxy/api.h>
 #include <haproxy/thread.h>
-#include <common/standard.h>
 
 /* eternity when exprimed in timeval */
 #ifndef TV_ETERNITY
@@ -82,16 +80,6 @@
  */
 int tv_ms_cmp2(const struct timeval *tv1, const struct timeval *tv2);
 
-/**** general purpose functions and macros *******************************/
-
-
-/* tv_now: sets <tv> to the current time */
-static inline struct timeval *tv_now(struct timeval *tv)
-{
-	gettimeofday(tv, NULL);
-	return tv;
-}
-
 /* tv_udpate_date: sets <date> to system time, and sets <now> to something as
  * close as possible to real time, following a monotonic function. The main
  * principle consists in detecting backwards and forwards time jumps and adjust
@@ -104,6 +92,16 @@
 
 char *timeofday_as_iso_us(int pad);
 
+/**** general purpose functions and macros *******************************/
+
+
+/* tv_now: sets <tv> to the current time */
+static inline struct timeval *tv_now(struct timeval *tv)
+{
+	gettimeofday(tv, NULL);
+	return tv;
+}
+
 /*
  * sets a struct timeval to its highest value so that it can never happen
  * note that only tv_usec is necessary to detect it since a tv_usec > 999999
@@ -602,7 +600,7 @@
 	ti->prev_mono_time = now_mono_time();
 }
 
-#endif /* _COMMON_TIME_H */
+#endif /* _HAPROXY_TIME_H */
 
 /*
  * Local variables:
diff --git a/include/proto/activity.h b/include/proto/activity.h
index 9d5044a..9ca9a42 100644
--- a/include/proto/activity.h
+++ b/include/proto/activity.h
@@ -24,7 +24,7 @@
 
 #include <haproxy/atomic.h>
 #include <haproxy/api.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <types/activity.h>
 #include <proto/freq_ctr.h>
 
diff --git a/include/proto/backend.h b/include/proto/backend.h
index 5160492..f702be9 100644
--- a/include/proto/backend.h
+++ b/include/proto/backend.h
@@ -23,7 +23,7 @@
 #define _PROTO_BACKEND_H
 
 #include <haproxy/api.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <types/backend.h>
 #include <types/proxy.h>
diff --git a/include/proto/channel.h b/include/proto/channel.h
index 16954ba..eaaa36b 100644
--- a/include/proto/channel.h
+++ b/include/proto/channel.h
@@ -31,7 +31,7 @@
 #include <common/chunk.h>
 #include <common/htx.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <types/channel.h>
 #include <types/global.h>
diff --git a/include/proto/fd.h b/include/proto/fd.h
index 9426e14..f882b54 100644
--- a/include/proto/fd.h
+++ b/include/proto/fd.h
@@ -29,7 +29,7 @@
 
 #include <haproxy/api.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <types/fd.h>
 #include <proto/activity.h>
 
diff --git a/include/proto/freq_ctr.h b/include/proto/freq_ctr.h
index 80529bf..896a469 100644
--- a/include/proto/freq_ctr.h
+++ b/include/proto/freq_ctr.h
@@ -25,7 +25,7 @@
 #include <haproxy/atomic.h>
 #include <haproxy/api.h>
 #include <common/standard.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <types/freq_ctr.h>
 
 
diff --git a/include/proto/peers.h b/include/proto/peers.h
index fbe6cf6..02fc67d 100644
--- a/include/proto/peers.h
+++ b/include/proto/peers.h
@@ -24,7 +24,7 @@
 
 #include <haproxy/api.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <proto/connection.h>
 #include <types/stream.h>
 #include <types/peers.h>
diff --git a/include/proto/proxy.h b/include/proto/proxy.h
index 630a011..066e807 100644
--- a/include/proto/proxy.h
+++ b/include/proto/proxy.h
@@ -24,7 +24,7 @@
 
 #include <haproxy/api.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <types/applet.h>
 #include <types/global.h>
 #include <types/proxy.h>
diff --git a/include/proto/server.h b/include/proto/server.h
index e184310..d158089 100644
--- a/include/proto/server.h
+++ b/include/proto/server.h
@@ -25,7 +25,7 @@
 #include <unistd.h>
 
 #include <haproxy/api.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <types/applet.h>
 #include <types/dns.h>
 #include <types/proxy.h>
diff --git a/include/proto/stick_table.h b/include/proto/stick_table.h
index 986c775..dcc2954 100644
--- a/include/proto/stick_table.h
+++ b/include/proto/stick_table.h
@@ -25,7 +25,7 @@
 
 #include <haproxy/errors.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <types/stick_table.h>
 #include <types/dict.h>
 
diff --git a/src/backend.c b/src/backend.c
index c876003..ff6c37d 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -24,7 +24,7 @@
 #include <haproxy/hash.h>
 #include <common/htx.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <common/namespace.h>
 
 #include <types/global.h>
diff --git a/src/calltrace.c b/src/calltrace.c
index a4f3bbe..2208ca1 100644
--- a/src/calltrace.c
+++ b/src/calltrace.c
@@ -48,7 +48,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <haproxy/api.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 static FILE *log;
 static int level;
diff --git a/src/cfgparse.c b/src/cfgparse.c
index f4de78a..a1917fa 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -39,7 +39,7 @@
 #include <haproxy/errors.h>
 #include <common/memory.h>
 #include <common/standard.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <common/uri_auth.h>
 #include <common/namespace.h>
 #include <haproxy/thread.h>
diff --git a/src/checks.c b/src/checks.c
index 92f1e4a..6744e2d 100644
--- a/src/checks.c
+++ b/src/checks.c
@@ -35,7 +35,7 @@
 #include <common/chunk.h>
 #include <haproxy/list.h>
 #include <common/standard.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <haproxy/thread.h>
 #include <common/http.h>
 #include <common/h1.h>
diff --git a/src/cli.c b/src/cli.c
index 4b9c31f..6c7bc3f 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -32,7 +32,7 @@
 #include <haproxy/list.h>
 #include <common/standard.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <common/uri_auth.h>
 #include <haproxy/version.h>
 #include <haproxy/base64.h>
diff --git a/src/dns.c b/src/dns.c
index b11622c..73258c0 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -22,7 +22,7 @@
 #include <haproxy/api.h>
 #include <common/cfgparse.h>
 #include <haproxy/errors.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <common/ticks.h>
 #include <common/net_helper.h>
 
diff --git a/src/ev_epoll.c b/src/ev_epoll.c
index 132d487..8378383 100644
--- a/src/ev_epoll.c
+++ b/src/ev_epoll.c
@@ -18,7 +18,7 @@
 #include <haproxy/thread-t.h>
 #include <common/standard.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <types/global.h>
 
diff --git a/src/ev_evports.c b/src/ev_evports.c
index e440f15..359acf9 100644
--- a/src/ev_evports.c
+++ b/src/ev_evports.c
@@ -21,7 +21,7 @@
 #include <haproxy/api.h>
 #include <haproxy/thread-t.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <types/global.h>
 
diff --git a/src/ev_kqueue.c b/src/ev_kqueue.c
index 5b14d51..efc2ecf 100644
--- a/src/ev_kqueue.c
+++ b/src/ev_kqueue.c
@@ -20,7 +20,7 @@
 #include <haproxy/api.h>
 #include <haproxy/thread-t.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <types/global.h>
 
diff --git a/src/ev_poll.c b/src/ev_poll.c
index c3c52f0..7239732 100644
--- a/src/ev_poll.c
+++ b/src/ev_poll.c
@@ -20,7 +20,7 @@
 #include <haproxy/api.h>
 #include <haproxy/thread-t.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <types/global.h>
 
diff --git a/src/ev_select.c b/src/ev_select.c
index 3b02bed..9168f59 100644
--- a/src/ev_select.c
+++ b/src/ev_select.c
@@ -17,7 +17,7 @@
 #include <haproxy/api.h>
 #include <haproxy/thread-t.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <types/global.h>
 
diff --git a/src/flt_spoe.c b/src/flt_spoe.c
index 7021e55..930c2ec 100644
--- a/src/flt_spoe.c
+++ b/src/flt_spoe.c
@@ -16,7 +16,7 @@
 #include <common/cfgparse.h>
 #include <haproxy/thread.h>
 #include <common/memory.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <types/arg.h>
 #include <types/global.h>
diff --git a/src/flt_trace.c b/src/flt_trace.c
index fdc74a7..69862ae 100644
--- a/src/flt_trace.c
+++ b/src/flt_trace.c
@@ -15,7 +15,7 @@
 #include <haproxy/api.h>
 #include <common/htx.h>
 #include <common/standard.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <types/channel.h>
 #include <types/filters.h>
diff --git a/src/freq_ctr.c b/src/freq_ctr.c
index 56ac97d..1620156 100644
--- a/src/freq_ctr.c
+++ b/src/freq_ctr.c
@@ -12,7 +12,7 @@
 
 #include <haproxy/api.h>
 #include <common/standard.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <proto/freq_ctr.h>
 
 /* Read a frequency counter taking history into account for missing time in
diff --git a/src/frontend.c b/src/frontend.c
index ce5c3d7..b111e6a 100644
--- a/src/frontend.c
+++ b/src/frontend.c
@@ -25,7 +25,7 @@
 #include <haproxy/api.h>
 #include <common/chunk.h>
 #include <common/standard.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <types/global.h>
 
diff --git a/src/haproxy.c b/src/haproxy.c
index 67e4237..a2ceeec 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -92,7 +92,7 @@
 #include <haproxy/openssl-compat.h>
 #include <common/regex.h>
 #include <common/standard.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <common/uri_auth.h>
 #include <haproxy/version.h>
 #include <haproxy/thread.h>
diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c
index a914066..da975c0 100644
--- a/src/hlua_fcn.c
+++ b/src/hlua_fcn.c
@@ -19,7 +19,7 @@
 #include <lualib.h>
 
 #include <common/net_helper.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <common/uri_auth.h>
 
 #include <types/cli.h>
diff --git a/src/listener.c b/src/listener.c
index 3315d60..8de3b37 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -23,7 +23,7 @@
 #include <haproxy/errors.h>
 #include <haproxy/list.h>
 #include <common/standard.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <types/global.h>
 #include <types/protocol.h>
diff --git a/src/log.c b/src/log.c
index a8bf820..d4f4922 100644
--- a/src/log.c
+++ b/src/log.c
@@ -26,7 +26,7 @@
 
 #include <haproxy/api.h>
 #include <common/standard.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <haproxy/version.h>
 
 #include <types/cli.h>
diff --git a/src/peers.c b/src/peers.c
index 6d5a5de..5f4dce3 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -22,7 +22,7 @@
 
 #include <haproxy/api.h>
 #include <common/net_helper.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <common/standard.h>
 #include <haproxy/thread.h>
 
diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c
index b627724..1c13518 100644
--- a/src/proto_sockpair.c
+++ b/src/proto_sockpair.c
@@ -30,7 +30,7 @@
 #include <haproxy/errors.h>
 #include <haproxy/list.h>
 #include <common/standard.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <haproxy/version.h>
 
 #include <types/global.h>
diff --git a/src/proto_uxst.c b/src/proto_uxst.c
index ae68a8d..99e4eff 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -30,7 +30,7 @@
 #include <haproxy/errors.h>
 #include <haproxy/list.h>
 #include <common/standard.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <haproxy/version.h>
 
 #include <types/global.h>
diff --git a/src/proxy.c b/src/proxy.c
index b5bc5ae..5e29ec9 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -21,7 +21,7 @@
 #include <common/cfgparse.h>
 #include <haproxy/errors.h>
 #include <common/memory.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <import/eb32tree.h>
 #include <import/ebistree.h>
diff --git a/src/queue.c b/src/queue.c
index f2407ed..e354e0a 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -71,7 +71,7 @@
 
 #include <haproxy/api.h>
 #include <common/memory.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <haproxy/thread.h>
 #include <import/eb32tree.h>
 
diff --git a/src/raw_sock.c b/src/raw_sock.c
index 3612442..1d930d8 100644
--- a/src/raw_sock.c
+++ b/src/raw_sock.c
@@ -26,7 +26,7 @@
 #include <common/buffer.h>
 #include <common/standard.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <proto/connection.h>
 #include <proto/fd.h>
diff --git a/src/server.c b/src/server.c
index bdf2c99..d06c465 100644
--- a/src/server.c
+++ b/src/server.c
@@ -20,7 +20,7 @@
 #include <common/cfgparse.h>
 #include <haproxy/errors.h>
 #include <common/namespace.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <types/applet.h>
 #include <types/cli.h>
diff --git a/src/sink.c b/src/sink.c
index 9ed75ac..b5ecdde 100644
--- a/src/sink.c
+++ b/src/sink.c
@@ -22,7 +22,7 @@
 #include <common/cfgparse.h>
 #include <import/ist.h>
 #include <haproxy/list.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <proto/cli.h>
 #include <proto/log.h>
 #include <proto/ring.h>
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index 0b0b4b9..729f26c 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -50,7 +50,7 @@
 #include <haproxy/openssl-compat.h>
 #include <common/standard.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <haproxy/base64.h>
 
 #include <import/ebpttree.h>
diff --git a/src/stats.c b/src/stats.c
index e7a1e76..c0d0eb0 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -33,7 +33,7 @@
 #include <haproxy/list.h>
 #include <common/standard.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <common/uri_auth.h>
 #include <haproxy/version.h>
 #include <haproxy/base64.h>
diff --git a/src/stick_table.c b/src/stick_table.c
index dc2ef4f..0fb0927 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -20,7 +20,7 @@
 #include <haproxy/list.h>
 #include <common/net_helper.h>
 #include <common/standard.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <import/ebmbtree.h>
 #include <import/ebsttree.h>
diff --git a/src/stream_interface.c b/src/stream_interface.c
index 91f844b..89f37ee 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -23,7 +23,7 @@
 #include <common/buffer.h>
 #include <common/standard.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <proto/applet.h>
 #include <proto/channel.h>
diff --git a/src/task.c b/src/task.c
index 55a54a4..452530e 100644
--- a/src/task.c
+++ b/src/task.c
@@ -16,7 +16,7 @@
 #include <common/memory.h>
 #include <haproxy/list.h>
 #include <common/standard.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <import/eb32sctree.h>
 #include <import/eb32tree.h>
 
diff --git a/src/tcp_rules.c b/src/tcp_rules.c
index 1943018..f79d2a3 100644
--- a/src/tcp_rules.c
+++ b/src/tcp_rules.c
@@ -14,7 +14,7 @@
 #include <haproxy/list.h>
 #include <common/standard.h>
 #include <common/ticks.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 
 #include <types/arg.h>
 #include <types/capture.h>
diff --git a/src/time.c b/src/time.c
index 86c2469..a6aaf40 100644
--- a/src/time.c
+++ b/src/time.c
@@ -15,7 +15,7 @@
 
 #include <haproxy/api.h>
 #include <common/standard.h>
-#include <common/time.h>
+#include <haproxy/time.h>
 #include <haproxy/thread-t.h>
 
 THREAD_LOCAL unsigned int   ms_left_scaled;  /* milliseconds left for current second (0..2^32-1) */