upiwin/src/time_func.c

26 lines
433 B
C

#include <stddef.h>
#include <sys/time.h>
#include "time_func.h"
static TIMESTAMP start_timestamp = 0;
TIMESTAMP TimeSinceEpoch(void)
{
TIMESTAMP rc;
struct timeval tv;
gettimeofday(&tv, NULL);
rc = (tv.tv_sec * (TIMESTAMP)1000) + (tv.tv_usec / (TIMESTAMP)1000);
return rc;
}
TIMESTAMP TimeSinceStart(void)
{
return TimeSinceEpoch() - start_timestamp;
}
void TimeInit(void)
{
start_timestamp = TimeSinceEpoch();
}