simplified mstimer_now for BSD, Windows, and Linux ports. (#309)
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user