add clockGetMillis()

This commit is contained in:
John
2022-09-10 14:21:39 +02:00
parent 327704ff3b
commit 1612080391
2 changed files with 11 additions and 0 deletions
+6
View File
@@ -44,4 +44,10 @@ void clockGettime(struct timespec* t) {
#endif
}
long long clockGetMillis() {
struct timespec t;
clockGettime(&t);
return t.tv_sec*1000LL + t.tv_nsec / 1000000;
}
} // namespace ebusd
+5
View File
@@ -31,6 +31,11 @@ namespace ebusd {
*/
void clockGettime(struct timespec* t);
/**
* Get the current system time in milliseconds since the Epoch.
*/
long long clockGetMillis();
} // namespace ebusd
#endif // LIB_UTILS_CLOCK_H_