#include <cstdint>
#include <Windows.h>
-extern "C" int gettimeofday(timeval* tv, timezone*) {
+extern "C" {
+int gettimeofday(timeval* tv, timezone*) {
constexpr auto posixWinFtOffset = 116444736000000000ULL;
if (tv) {
return 0;
}
+
+void timeradd(timeval* a, timeval* b, timeval* res) {
+ res->tv_sec = a->tv_sec + b->tv_sec;
+ res->tv_usec = a->tv_usec + b->tv_usec;
+ if (res->tv_usec >= 1000000) {
+ res->tv_sec++;
+ res->tv_usec -= 1000000;
+ }
+}
+
+void timersub(timeval* a, timeval* b, timeval* res) {
+ res->tv_sec = a->tv_sec - b->tv_sec;
+ res->tv_usec = a->tv_usec - b->tv_usec;
+ if (res->tv_usec < 0) {
+ res->tv_sec--;
+ res->tv_usec += 1000000;
+ }
+}
+}
#endif
int tz_dsttime;
};
-extern "C" int gettimeofday(timeval* tv, timezone*);
+extern "C" {
+int gettimeofday(timeval* tv, timezone*);
+void timeradd(timeval* a, timeval* b, timeval* res);
+void timersub(timeval* a, timeval* b, timeval* res);
+}
#endif