/**
*	msleep - microsecond resolution sleeper. Adapted from
*		Unix Network Programming by W. Richard Stevens, page 330.
*	This version by Gil Nardo (gil@netcom.com)
**/
#include <sys/types.h>
#include <sys/time.h>
#include <assert.h>

void
msleep(unsigned long msecs)
{
	struct timeval timeout;
	int oops;

	timeout.tv_sec = msecs / 1000;
	timeout.tv_usec = msecs % 1000;
	oops = select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &timeout);
	assert( oops >= 0 );
}

#ifdef TESTMODULE
main()
{
	printf("Sleeping 1000 us\n");
	msleep(1000);
	printf("Sleeping 100 us\n");
	msleep(100);
	printf("Sleeping 1500 us\n");
	msleep(1500);
	printf("Sleeping 500 us\n");
	msleep(500);
	printf("Sleeping 2000 us\n");
	msleep(2000);
	printf("Sleeping 2500 us\n");
	msleep(2500);
}
#endif
