1 #ifndef __TIME_BASE_H__
2 #define __TIME_BASE_H__
31 #include <sys/types.h>
32 #include <sys/timeb.h>
40 enum { USEC = 1000000 };
47 inline void NormalizeTime(timeval &in)
49 while (in.tv_usec >= USEC)
55 while (in.tv_usec < 0)
69 inline void TimeDif(
const struct timeval &start,
const struct timeval &fin,
struct timeval &answer)
71 answer.tv_usec = fin.tv_usec - start.tv_usec;
72 answer.tv_sec = fin.tv_sec - start.tv_sec;
73 NormalizeTime(answer);
83 inline void TimeAdd(
const struct timeval &start,
const struct timeval &delta,
struct timeval &answer)
85 answer.tv_usec = start.tv_usec + delta.tv_usec;
86 answer.tv_sec = start.tv_sec + delta.tv_sec;
87 NormalizeTime(answer);
102 inline int gettimeofday(
struct timeval *tv,
void * trash)
106 tv->tv_sec = (long)timeb.time;
107 tv->tv_usec = (
unsigned int)timeb.millitm * 1000;
112 #include "time_clock.h"
113 #include "time_span.h"
114 #include "time_general.h"
115 #include "time_out.h"
117 #endif //__TIME_BASE_H__