summary refs log tree commit diff
path: root/include/compat/sys/time.h
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-07-27 21:55:29 -0400
committerJune McEnroe <june@causal.agency>2020-07-30 19:02:22 -0400
commit4bb261b015d382a567563571ae4d399a16caebe2 (patch)
tree19862c3060f67c92df964ed948084e234e7a4952 /include/compat/sys/time.h
parentimport: Add script to extract libtls from libressl-portable (diff)
downloadlibretls-4bb261b015d382a567563571ae4d399a16caebe2.tar.gz
libretls-4bb261b015d382a567563571ae4d399a16caebe2.zip
Import LibreSSL 3.2.0
Diffstat (limited to 'include/compat/sys/time.h')
-rw-r--r--include/compat/sys/time.h28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/compat/sys/time.h b/include/compat/sys/time.h
new file mode 100644
index 0000000..76428c1
--- /dev/null
+++ b/include/compat/sys/time.h
@@ -0,0 +1,28 @@
+/*
+ * Public domain
+ * sys/time.h compatibility shim
+ */
+
+#ifndef LIBCRYPTOCOMPAT_SYS_TIME_H
+#define LIBCRYPTOCOMPAT_SYS_TIME_H
+
+#ifdef _MSC_VER
+#include <winsock2.h>
+int gettimeofday(struct timeval *tp, void *tzp);
+#else
+#include_next <sys/time.h>
+#endif
+
+#ifndef timersub
+#define timersub(tvp, uvp, vvp)                                         \
+	do {                                                            \
+		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;          \
+		(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;       \
+		if ((vvp)->tv_usec < 0) {                               \
+			(vvp)->tv_sec--;                                \
+			(vvp)->tv_usec += 1000000;                      \
+		}                                                       \
+	} while (0)
+#endif
+
+#endif