upiwin/src/time_func.c

26 lines
438 B
C
Raw Normal View History

#include <stddef.h>
#include <sys/time.h>
#include "time_func.h"
static TIMESTAMP start_timestamp = 0;
2019-12-01 15:43:05 -07:00
TIMESTAMP Time_since_epoch(void)
{
TIMESTAMP rc;
struct timeval tv;
gettimeofday(&tv, NULL);
rc = (tv.tv_sec * (TIMESTAMP)1000) + (tv.tv_usec / (TIMESTAMP)1000);
return rc;
}
2019-12-01 15:43:05 -07:00
TIMESTAMP Time_since_start(void)
{
return TimeSinceEpoch() - start_timestamp;
}
2019-12-01 15:43:05 -07:00
void Time_init(void)
{
start_timestamp = TimeSinceEpoch();
}