]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Slap u64 on everything time-y (#10984)
authorLars Müller <34514239+appgurueu@users.noreply.github.com>
Wed, 24 Feb 2021 11:05:17 +0000 (12:05 +0100)
committerGitHub <noreply@github.com>
Wed, 24 Feb 2021 11:05:17 +0000 (12:05 +0100)
doc/lua_api.txt
src/porting.h

index d3165b9fd6008eea8c3731893a25c19ddca6702c..c09578a15aed170eb74cd510e54308b078253d9a 100644 (file)
@@ -3268,7 +3268,6 @@ Helper functions
     * returns true when the passed number represents NaN.
 * `minetest.get_us_time()`
     * returns time with microsecond precision. May not return wall time.
-    * This value might overflow on certain 32-bit systems!
 * `table.copy(table)`: returns a table
     * returns a deep copy of `table`
 * `table.indexof(list, val)`: returns the smallest numerical index containing
index e4ebe36fd15db100e6334344ae50becd9e2e56f8..93932e1d9ed3207a82bd680e6a7de0a32de4cc66 100644 (file)
@@ -234,21 +234,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