[Libreoffice-commits] core.git: tools/source
Stephan Bergmann
sbergman at redhat.com
Fri Apr 10 01:15:33 PDT 2015
tools/source/datetime/ttime.cxx | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
New commits:
commit 81090304414ce8b7ffbd3a36a14a010704185ab4
Author: Stephan Bergmann <sbergman at redhat.com>
Date: Fri Apr 10 10:14:43 2015 +0200
No need to go via floating-point calculations
Change-Id: I049aa3f5be42c520f824ec62943c37e8ffac78ad
diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx
index 455c4a9..ab1f651 100644
--- a/tools/source/datetime/ttime.cxx
+++ b/tools/source/datetime/ttime.cxx
@@ -17,6 +17,10 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <cerrno>
+
#if defined( WNT )
#include <windows.h>
#elif defined UNX
@@ -422,14 +426,13 @@ sal_uInt64 tools::Time::GetSystemTicks()
(nPerformanceCount.QuadPart*1000)/nTicksPerSecond.QuadPart);
#else
timeval tv;
- gettimeofday (&tv, 0);
-
- double fTicks = tv.tv_sec;
- fTicks *= 1000;
- fTicks += ((tv.tv_usec + 500) / 1000);
-
- fTicks = fmod (fTicks, double(SAL_MAX_UINT64));
- return static_cast<sal_uInt64>(fTicks);
+ int n = gettimeofday (&tv, 0);
+ if (n == -1) {
+ int e = errno;
+ SAL_WARN("tools.datetime", "gettimeofday failed: " << e);
+ }
+ return static_cast<sal_uInt64>(tv.tv_sec) * 1000
+ + (static_cast<sal_uInt64>(tv.tv_usec) + 500) / 1000;
#endif
}
More information about the Libreoffice-commits
mailing list