1 #ifndef __TIME_BASE_H__ 2 #define __TIME_BASE_H__ 20 #include <sys/types.h> 21 #include <sys/timeb.h> 29 enum { USEC = 1000000 };
33 inline void NormalizeTime(timeval &in)
35 while (in.tv_usec >= USEC)
41 while (in.tv_usec < 0)
51 inline void TimeDif(
const struct timeval &start,
const struct timeval &fin,
struct timeval &answer)
53 answer.tv_usec = fin.tv_usec - start.tv_usec;
54 answer.tv_sec = fin.tv_sec - start.tv_sec;
55 NormalizeTime(answer);
60 inline void TimeAdd(
const struct timeval &start,
const struct timeval &delta,
struct timeval &answer)
62 answer.tv_usec = start.tv_usec + delta.tv_usec;
63 answer.tv_sec = start.tv_sec + delta.tv_sec;
64 NormalizeTime(answer);
73 inline int gettimeofday(
struct timeval *tv,
void * trash)
77 tv->tv_sec = (long)timeb.time;
78 tv->tv_usec = (
unsigned int)timeb.millitm * 1000;
83 #include "time_clock.h" 84 #include "time_span.h" 85 #include "time_general.h" 88 #endif //__TIME_BASE_H__