From a07e9ebebf8293c516d8db09bb925f5d43de9a4d Mon Sep 17 00:00:00 2001 From: Steve Karg Date: Tue, 19 Jul 2022 10:57:25 -0500 Subject: [PATCH] simplified mstimer_now for BSD, Windows, and Linux ports. (#309) Co-authored-by: Steve Karg --- ports/bsd/mstimer-init.c | 14 +------------- ports/linux/mstimer-init.c | 14 +------------- ports/win32/mstimer-init.c | 14 +------------- 3 files changed, 3 insertions(+), 39 deletions(-) diff --git a/ports/bsd/mstimer-init.c b/ports/bsd/mstimer-init.c index bdc68b20..3196c94a 100644 --- a/ports/bsd/mstimer-init.c +++ b/ports/bsd/mstimer-init.c @@ -34,9 +34,6 @@ #endif /** @file bsd/timer.c Provides BSD-specific time and timer functions. */ -/* counter for the various timers */ -static volatile unsigned long Millisecond_Counter; - /* start time for the clock */ static struct timespec start; /* The timeGetTime function retrieves the system time, in milliseconds. @@ -69,16 +66,7 @@ unsigned long timeGetTime(void) */ unsigned long mstimer_now(void) { - unsigned long now = timeGetTime(); - unsigned long delta_time = 0; - - if (Millisecond_Counter <= now) { - delta_time = now - Millisecond_Counter; - } else { - delta_time = (ULONG_MAX - Millisecond_Counter) + now + 1; - } - - return delta_time; + return timeGetTime(); } /** diff --git a/ports/linux/mstimer-init.c b/ports/linux/mstimer-init.c index 2d9312ed..2fd77b5b 100644 --- a/ports/linux/mstimer-init.c +++ b/ports/linux/mstimer-init.c @@ -32,9 +32,6 @@ /** @file linux/mstimer.c Provides Linux-specific time and timer functions. */ -/* counter for the various timers */ -static volatile unsigned long Millisecond_Counter; - /* start time for the clock */ static struct timespec start; @@ -60,16 +57,7 @@ static unsigned long timeGetTime(void) */ unsigned long mstimer_now(void) { - unsigned long now = timeGetTime(); - unsigned long delta_time = 0; - - if (Millisecond_Counter <= now) { - delta_time = now - Millisecond_Counter; - } else { - delta_time = (ULONG_MAX - Millisecond_Counter) + now + 1; - } - - return delta_time; + return timeGetTime(); } /** diff --git a/ports/win32/mstimer-init.c b/ports/win32/mstimer-init.c index 2f90de95..2d33a258 100644 --- a/ports/win32/mstimer-init.c +++ b/ports/win32/mstimer-init.c @@ -32,9 +32,6 @@ #include "bacport.h" #include "bacnet/basic/sys/mstimer.h" -/* counter for the various timers */ -static volatile unsigned long Millisecond_Counter; - /* Windows timer period - in milliseconds */ static unsigned long Timer_Period = 1; @@ -44,16 +41,7 @@ static unsigned long Timer_Period = 1; */ unsigned long mstimer_now(void) { - unsigned long now = timeGetTime(); - unsigned long delta_time = 0; - - if (Millisecond_Counter <= now) { - delta_time = now - Millisecond_Counter; - } else { - delta_time = (ULONG_MAX - Millisecond_Counter) + now + 1; - } - - return delta_time; + return timeGetTime(); } /**