Cumulative patch from commit 594516b4c28a94ca686b17f1e463dfd6712b75a7

594516b Use monotonic clock for relative time for eloop if available
461e3eb Fix and work around some MinGW compilation issues
81cbc04 Fix compiler warning for OpenSSL without HAVE_OCSP
68d628a hostapd: Fix interface enabling/disabling and DFS
1cba9be STA: Cancel sched_scan while initiating wps_reassoc
215a02f Add Wi-Fi Direct to the build configuration example
ca9c14f dbus_new: Add documentation for D-Bus TDLS methods
6fc4848 P2P: Short scan wait to speed up the group re-invocation
93a06fe Fix QoS Map Configure frame use

Change-Id: Id76002ca7fa742b6533e7e592ffd3867886dc50e
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/src/utils/os_unix.c b/src/utils/os_unix.c
index 960073a..fa67fdf 100644
--- a/src/utils/os_unix.c
+++ b/src/utils/os_unix.c
@@ -60,6 +60,43 @@
 }
 
 
+int os_get_reltime(struct os_reltime *t)
+{
+#if defined(CLOCK_BOOTTIME)
+	static clockid_t clock_id = CLOCK_BOOTTIME;
+#elif defined(CLOCK_MONOTONIC)
+	static clockid_t clock_id = CLOCK_MONOTONIC;
+#else
+	static clockid_t clock_id = CLOCK_REALTIME;
+#endif
+	struct timespec ts;
+	int res;
+
+	while (1) {
+		res = clock_gettime(clock_id, &ts);
+		if (res == 0) {
+			t->sec = ts.tv_sec;
+			t->usec = ts.tv_nsec / 1000;
+			return 0;
+		}
+		switch (clock_id) {
+#ifdef CLOCK_BOOTTIME
+		case CLOCK_BOOTTIME:
+			clock_id = CLOCK_MONOTONIC;
+			break;
+#endif
+#ifdef CLOCK_MONOTONIC
+		case CLOCK_MONOTONIC:
+			clock_id = CLOCK_REALTIME;
+			break;
+#endif
+		case CLOCK_REALTIME:
+			return -1;
+		}
+	}
+}
+
+
 int os_mktime(int year, int month, int day, int hour, int min, int sec,
 	      os_time_t *t)
 {