summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2015-04-10 10:14:43 +0200
committerStephan Bergmann <sbergman@redhat.com>2015-04-10 10:14:43 +0200
commit81090304414ce8b7ffbd3a36a14a010704185ab4 (patch)
treea6d4621b4d3e36165b2824dc72c5f6fc87fa72c2 /tools
parent6bee77922c2571a7b55f099531f024def3e1036b (diff)
No need to go via floating-point calculations
Change-Id: I049aa3f5be42c520f824ec62943c37e8ffac78ad
Diffstat (limited to 'tools')
-rw-r--r--tools/source/datetime/ttime.cxx19
1 files changed, 11 insertions, 8 deletions
diff --git a/tools/source/datetime/ttime.cxx b/tools/source/datetime/ttime.cxx
index 455c4a90ae19..ab1f651bb55e 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
}