|
|
@ -33,6 +33,17 @@ void TimeGet(struct timeval *);
|
|
|
|
/** \brief intialize a 'struct timespec' from a 'struct timeval'. */
|
|
|
|
/** \brief intialize a 'struct timespec' from a 'struct timeval'. */
|
|
|
|
#define FROM_TIMEVAL(timev) { .tv_sec = (timev).tv_sec, .tv_nsec = (timev).tv_usec * 1000 }
|
|
|
|
#define FROM_TIMEVAL(timev) { .tv_sec = (timev).tv_sec, .tv_nsec = (timev).tv_usec * 1000 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** \brief compare two 'struct timeval' and return the difference in seconds */
|
|
|
|
|
|
|
|
#define TIMEVAL_DIFF_SEC(tv_new, tv_old) \
|
|
|
|
|
|
|
|
(uint64_t)((((uint64_t)(tv_new).tv_sec * 1000000 + (tv_new).tv_usec) - \
|
|
|
|
|
|
|
|
((uint64_t)(tv_old).tv_sec * 1000000 + (tv_old).tv_usec)) / \
|
|
|
|
|
|
|
|
1000000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** \brief compare two 'struct timeval' and return if the first is earlier than the second */
|
|
|
|
|
|
|
|
#define TIMEVAL_EARLIER(tv_first, tv_second) \
|
|
|
|
|
|
|
|
(((tv_first).tv_sec < (tv_second).tv_sec) || \
|
|
|
|
|
|
|
|
((tv_first).tv_sec == (tv_second).tv_sec && (tv_first).tv_usec < (tv_second).tv_usec))
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef UNITTESTS
|
|
|
|
#ifdef UNITTESTS
|
|
|
|
void TimeSet(struct timeval *);
|
|
|
|
void TimeSet(struct timeval *);
|
|
|
|
void TimeSetToCurrentTime(void);
|
|
|
|
void TimeSetToCurrentTime(void);
|
|
|
|