From 44055ff37f41bb8fe8927945a37d80dbea38fadd Mon Sep 17 00:00:00 2001 From: petermcs Date: Mon, 30 Apr 2012 08:31:41 +0000 Subject: [PATCH] I had a weird timing glitch when running mstpcap which I think was caused by a truncation error in timer.c so I've made some slight changes to try stop it happening again. --- bacnet-stack/ports/win32/timer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bacnet-stack/ports/win32/timer.c b/bacnet-stack/ports/win32/timer.c index dfe762e0..092df5d6 100644 --- a/bacnet-stack/ports/win32/timer.c +++ b/bacnet-stack/ports/win32/timer.c @@ -84,7 +84,7 @@ int gettimeofday( /* a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC). */ GetSystemTimeAsFileTime(&ft); - usec_timer |= ft.dwHighDateTime; + usec_timer = ft.dwHighDateTime; usec_timer <<= 32; usec_timer |= ft.dwLowDateTime; /*converting file time to unix epoch 1970 */ @@ -95,7 +95,7 @@ int gettimeofday( time_start = timeGetTime(); } else { elapsed_milliseconds = timeGetTime() - time_start; - usec_elapsed = usec_timer + (elapsed_milliseconds * 1000UL); + usec_elapsed = usec_timer + ((LONGLONG)elapsed_milliseconds * 1000UL); tp->tv_sec = (long) (usec_elapsed / 1000000UL); tp->tv_usec = (long) (usec_elapsed % 1000000UL); }