Slap u64 on everything time-y

* get_us_time() will overflow and reset to zero every now and then.
  Had it happen several times in one day,
  https://github.com/minetest/minetest/issues/10105
* backported b5eda416ce

Signed-off-by: mckaygerhard <mckaygerhard@gmail.com>
This commit is contained in:
mckaygerhard 2023-09-17 15:07:09 -04:00
parent 19afb03d0b
commit 3ee0fd6f92

View File

@ -237,21 +237,21 @@ inline u64 getTimeMs()
{ {
struct timespec ts; struct timespec ts;
os_get_clock(&ts); os_get_clock(&ts);
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000; return ((u64) ts.tv_sec) * 1000LL + ((u64) ts.tv_nsec) / 1000000LL;
} }
inline u64 getTimeUs() inline u64 getTimeUs()
{ {
struct timespec ts; struct timespec ts;
os_get_clock(&ts); os_get_clock(&ts);
return ts.tv_sec * 1000000 + ts.tv_nsec / 1000; return ((u64) ts.tv_sec) * 1000000LL + ((u64) ts.tv_nsec) / 1000LL;
} }
inline u64 getTimeNs() inline u64 getTimeNs()
{ {
struct timespec ts; struct timespec ts;
os_get_clock(&ts); os_get_clock(&ts);
return ts.tv_sec * 1000000000 + ts.tv_nsec; return ((u64) ts.tv_sec) * 1000000000LL + ((u64) ts.tv_nsec);
} }
#endif #endif