aboutsummaryrefslogtreecommitdiffstats
path: root/src/system
diff options
context:
space:
mode:
Diffstat (limited to 'src/system')
-rw-r--r--src/system/Clock.cxx26
-rw-r--r--src/system/Clock.hxx11
2 files changed, 37 insertions, 0 deletions
diff --git a/src/system/Clock.cxx b/src/system/Clock.cxx
index 347997a44..17b221c15 100644
--- a/src/system/Clock.cxx
+++ b/src/system/Clock.cxx
@@ -96,3 +96,29 @@ MonotonicClockUS(void)
#endif
}
+#ifdef WIN32
+
+gcc_const
+static unsigned
+DeltaFileTimeS(FILETIME a, FILETIME b)
+{
+ ULARGE_INTEGER a2, b2;
+ b2.LowPart = b.dwLowDateTime;
+ b2.HighPart = b.dwHighDateTime;
+ a2.LowPart = a.dwLowDateTime;
+ a2.HighPart = a.dwHighDateTime;
+ return (a2.QuadPart - b2.QuadPart) / 10000000;
+}
+
+unsigned
+GetProcessUptimeS()
+{
+ FILETIME creation_time, now;
+ GetProcessTimes(GetCurrentProcess(), &creation_time,
+ nullptr, nullptr, nullptr);
+ GetSystemTimeAsFileTime(&now);
+
+ return DeltaFileTimeS(now, creation_time);
+}
+
+#endif
diff --git a/src/system/Clock.hxx b/src/system/Clock.hxx
index 7be1127bf..28df0c7e0 100644
--- a/src/system/Clock.hxx
+++ b/src/system/Clock.hxx
@@ -38,4 +38,15 @@ gcc_pure
uint64_t
MonotonicClockUS();
+#ifdef WIN32
+
+/**
+ * Returns the uptime of the current process in seconds.
+ */
+gcc_pure
+unsigned
+GetProcessUptimeS();
+
+#endif
+
#endif