2 * $RCSfile: lib_time.c,v $
19 #include "debugging.h"
20 #include "cdck_main.h"
26 void time_substract_timeval (struct timeval *t2, struct timeval *t1, struct timeval *td)
28 if (!t2 || !t1 || !td) {
29 // printf("null arg");
33 td->tv_sec = t2->tv_sec - t1->tv_sec;
35 if (t2->tv_usec < t1->tv_usec) {
37 td->tv_usec = (1000000 + t2->tv_usec) - t1->tv_usec;
39 td->tv_usec = t2->tv_usec - t1->tv_usec;
43 int time_get_time_usec (struct timeval *tv)
48 if (tv->tv_sec >= TV_INT_MAX_SEC)
51 return (tv->tv_sec * 1000000 + tv->tv_usec);
55 float time_get_time_ms (struct timeval *tv)
60 return ( (double)tv->tv_sec * 1000.0 + (double)tv->tv_usec / 1000.0);