From 84d060c768c10145374d48ebd2b3f00430c73638 Mon Sep 17 00:00:00 2001 From: volzhs Date: Thu, 20 Dec 2018 06:18:52 +0900 Subject: Added OS.get_system_time_msecs() --- drivers/unix/os_unix.cpp | 6 ++++++ drivers/unix/os_unix.h | 1 + 2 files changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 279274734f..12a1263042 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -202,6 +202,12 @@ uint64_t OS_Unix::get_system_time_secs() const { return uint64_t(tv_now.tv_sec); } +uint64_t OS_Unix::get_system_time_msecs() const { + struct timeval tv_now; + gettimeofday(&tv_now, NULL); + return uint64_t(tv_now.tv_sec * 1000 + tv_now.tv_usec / 1000); +} + OS::Date OS_Unix::get_date(bool utc) const { time_t t = time(NULL); diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index b702454603..94a8d040cd 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -84,6 +84,7 @@ public: virtual uint64_t get_unix_time() const; virtual uint64_t get_system_time_secs() const; + virtual uint64_t get_system_time_msecs() const; virtual void delay_usec(uint32_t p_usec) const; virtual uint64_t get_ticks_usec() const; -- cgit v1.2.3