simplified mstimer_now for BSD, Windows, and Linux ports. (#309)

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2022-07-19 10:57:25 -05:00
committed by GitHub
parent 1388b668f9
commit a07e9ebebf
3 changed files with 3 additions and 39 deletions
+1 -13
View File
@@ -34,9 +34,6 @@
#endif #endif
/** @file bsd/timer.c Provides BSD-specific time and timer functions. */ /** @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 */ /* start time for the clock */
static struct timespec start; static struct timespec start;
/* The timeGetTime function retrieves the system time, in milliseconds. /* The timeGetTime function retrieves the system time, in milliseconds.
@@ -69,16 +66,7 @@ unsigned long timeGetTime(void)
*/ */
unsigned long mstimer_now(void) unsigned long mstimer_now(void)
{ {
unsigned long now = timeGetTime(); return 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;
} }
/** /**
+1 -13
View File
@@ -32,9 +32,6 @@
/** @file linux/mstimer.c Provides Linux-specific time and timer functions. */ /** @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 */ /* start time for the clock */
static struct timespec start; static struct timespec start;
@@ -60,16 +57,7 @@ static unsigned long timeGetTime(void)
*/ */
unsigned long mstimer_now(void) unsigned long mstimer_now(void)
{ {
unsigned long now = timeGetTime(); return 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;
} }
/** /**
+1 -13
View File
@@ -32,9 +32,6 @@
#include "bacport.h" #include "bacport.h"
#include "bacnet/basic/sys/mstimer.h" #include "bacnet/basic/sys/mstimer.h"
/* counter for the various timers */
static volatile unsigned long Millisecond_Counter;
/* Windows timer period - in milliseconds */ /* Windows timer period - in milliseconds */
static unsigned long Timer_Period = 1; static unsigned long Timer_Period = 1;
@@ -44,16 +41,7 @@ static unsigned long Timer_Period = 1;
*/ */
unsigned long mstimer_now(void) unsigned long mstimer_now(void)
{ {
unsigned long now = timeGetTime(); return 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;
} }
/** /**