
#include "V.h"
/*
* Debug wrapper for the gettimeofday() system call.
*/
time_t
d_gettod(tp, tzp)
	TIMV* tp;
	TIMZ* tzp;
{	int   v;
	char* p;

	v = gettimeofday(tp,tzp);
	if (Vlvl > 6) {
		p = ctime((time_t*)&tp->tv_sec);
		p[24] = 0;
		V7 "gettimeofday(%08X,%08X)=%u=%s",tp,tzp,tp->tv_sec,p D;
	}
	return v;
}

/*
* Calculate the interval from t0 to t1.  We should have t0 <= t1.
* td is filled with the difference.  The return value is the tv_sec
* portion of the difference.
*/
d_timediff(td,t0,t1)
	TIMV* td;
	TIMV* t0;
	TIMV* t1;
{
	td->tv_sec  = t1->tv_sec  - t0->tv_sec;
	td->tv_usec = t1->tv_usec - t0->tv_usec;
	if (td->tv_usec < 0) {
		td->tv_sec  -= 1;
		td->tv_usec += 1000000;
	}
	return td->tv_sec;
}
