From f731e9e171eab7cf6f77b5579110b518b13f18ce Mon Sep 17 00:00:00 2001 From: mckaygerhard Date: Sun, 17 Sep 2023 15:07:09 -0400 Subject: [PATCH] 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 https://github.com/MultiCraft/MultiCraft/commit/b5eda416cea3157ae3590fb7d229cd2cd17c3bf9 --- src/porting.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/porting.h b/src/porting.h index ca0518a16..eecd011ab 100644 --- a/src/porting.h +++ b/src/porting.h @@ -239,21 +239,21 @@ inline u64 getTimeMs() { struct timespec 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() { struct timespec 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() { struct timespec ts; os_get_clock(&ts); - return ts.tv_sec * 1000000000 + ts.tv_nsec; + return ((u64) ts.tv_sec) * 1000000000LL + ((u64) ts.tv_nsec); } #endif