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>
This commit is contained in:
parent
5e5138db9f
commit
7fa9b09bc2
@ -477,11 +477,12 @@ sal_uInt64 tools::Time::GetMonotonicTicks()
|
||||
#if defined(_POSIX_TIMERS)
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user