upiwin/src/time_func.c

26 lines
482 B
C

#include <stddef.h>
#include <sys/time.h>
#include "time_func.h"
static TIMESTAMP start_timestamp = 0; /* time since epoch at start of run */
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;
}
TIMESTAMP Time_since_start(void)
{
return Time_since_epoch() - start_timestamp;
}
void Time_init(void)
{
start_timestamp = Time_since_epoch();
}