tools/source/datetime/ttime.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
New commits: commit e6421938fbab713fff64aef6ff864f68882fb258 Author: Urja Rannikko <[email protected]> AuthorDate: Sun Dec 5 14:29:09 2021 +0200 Commit: Xisco Fauli <[email protected]> CommitDate: Thu Dec 9 13:52:14 2021 +0100 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 <[email protected]> (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 <[email protected]> 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;
