#include <../arch/arch.h>

/*
 * TODO: linux RTC stuff
 */

#ifdef	  EMULATE_USLEEP

/*
 * nap()'ing support routine for 4.2BSD system call emulations
 * Author: D A Gwyn, 29-Oct-1984
 */
void V_CALL
archDelayExecution(u32_t milliseconds)
{
	struct timeval delay;
	delay.tv_sec = milliseconds / 1000;
	delay.tv_usec = 1000 * (milliseconds % 1000);
	select(0,NULL,NULL,NULL,&delay);
}

#else	   /* !EMULATE_USLEEP */

void V_CALL
archDelayExecution(u32_t milliseconds)
{
	usleep(1000*milliseconds);
}

#endif	  /* !EMULATE_USLEEP */

vsize_t	V_CALL
archTickCount(void)
{
	struct timezone tz={0,0};
	struct timeval tv;
	gettimeofday((struct timeval*)&tv,&tz);
	return tv.tv_sec * 1000 + tv.tv_usec / 1000;
}
