/**************************************************************************
 *                                                                        *
 * Copyright (c) 1996 Michael Richmond and Richard Treffers               *
 *                                                                        *
 *                    This software may be copied and distributed for     *
 *                    educational, research and not for profit services   *
 *                    provided that this copyright and statement are      *
 *                    included in all such copies.                        *
 *                                                                        *
 **************************************************************************/


#include <sys/time.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>

#ifdef LINUX
	/* Linux has the 'usleep' function */
int
vista_usleep(microseconds)
int microseconds;
{
	usleep((unsigned long) microseconds);
	return(0);
}

#else
	/* for systems that don't have a 'usleep' function, we make one */

static void foo(int);

/*	a foolish replacement for the BSD function
	I don't know why sigpause(SIGALRM) didn't work
	so i used signal(); 
	
	5/19/94 - prototypes added
*/

int
vista_usleep(microseconds)
int microseconds;
{
	int rval;
	struct itimerval val;


	val.it_interval.tv_sec=0;
	val.it_interval.tv_usec=0;

	val.it_value.tv_sec=0;
	val.it_value.tv_usec=microseconds;
	signal(SIGALRM,foo);
	rval=setitimer(ITIMER_REAL, &val, NULL);
	pause();
	
	return 0;
}

static void foo(x)
int x;
{
	
}

#endif     /* LINUX */
