diff options
author | Urja Rannikko <urjaman@gmail.com> | 2021-12-05 14:29:09 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2021-12-09 13:52:14 +0100 |
commit | e6421938fbab713fff64aef6ff864f68882fb258 (patch) | |
tree | 39bc10b6e106fb9ea166a4f81cead022b0fbaf2b /tools | |
parent | 19fa11ede8606e69513a942ac952b5e8d0981612 (diff) |
tdf#128715 fix tools::Time::GetMonotonicTicks() on 32-bit linux
Since time_t and thus tv_sec is (still, for now) 32-bit on these
architechtures, the multiplication of seconds to microseconds
happened in 32-bit thus causing a rollover roughly every 4295 seconds.
Fix by casting tv_sec to sal_uInt64 before the multiplication.
Also fixes tdf#144975.
Change-Id: I829d3406208545a816979cb58daaeb99ec2d5294
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126379
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
(cherry picked from commit 7fa9b09bc271d91792fe78c5cb03430bf38155a8)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126305
(cherry picked from commit 18407807085e47f56ec972c2e1ce6db9a2375e21)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126434
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/datetime/ttime.cxx | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx index 0049c33efd9d..e1fdc25615d2 100644 --- a/tools/source/datetime/ttime.cxx +++ b/tools/source/datetime/ttime.cxx @@ -476,11 +476,12 @@ sal_uInt64 tools::Time::GetMonotonicTicks() #if defined(USE_CLOCK_GETTIME) struct timespec currentTime; clock_gettime( CLOCK_MONOTONIC, ¤tTime ); - nMicroSeconds = currentTime.tv_sec * 1000 * 1000 + currentTime.tv_nsec / 1000; + nMicroSeconds + = static_cast<sal_uInt64>(currentTime.tv_sec) * 1000 * 1000 + currentTime.tv_nsec / 1000; #else struct timeval currentTime; gettimeofday( ¤tTime, nullptr ); - nMicroSeconds = currentTime.tv_sec * 1000 * 1000 + currentTime.tv_usec; + nMicroSeconds = static_cast<sal_uInt64>(currentTime.tv_sec) * 1000 * 1000 + currentTime.tv_usec; #endif #endif // __MACH__ return nMicroSeconds; |