/* Application - HPDI32 - Linux */
/* $Workfile: util_sleep.c $ */
/* $Revision: 1 $ */
/* $Date: 10/27/07 4:35p $ */
/* $Log: /NEW SOURCESAFE DATABASE/SDK/PLX/gsc/hpdi32/utils/linux/util_sleep.c $
 * 
 * 1     10/27/07 4:35p Dnewbold
*/

#include "util_sleep.h"
#include "gsc_common.h"

#include <unistd.h>



/*****************************************************************************
*
*	Function:	sleep_ms
*
*	Purpose:
*
*		Sleep for the given number of milliseconds. The OS may sleep longer
*		than requested, much longer, due to factors outside our control.
*
*	Arguments:
*
*		ms	The number of milleseconds to sleep. If zero or less is given we
*			use one.
*
*	Returned:
*
*		None.
*
*****************************************************************************/

void sleep_ms(long ms)
{
	for (;;)
	{
		if (ms == 0)
			break;

		if (ms > 10)
		{
			usleep(10000);
			ms	-= 10;
			continue;
		}

		usleep(ms * 1000);
		break;
	}
}


