timeout.c
gurba-0.40/src/host/unix/timeout.c · 606 B
From the archive gurba.tgz
Download the archive « Back to the archive contents
# include "dgd.h"
# include <sys/time.h>
static struct timeval timeout;
/*
* NAME: P->alarm()
* DESCRIPTION: set the timeout to <delay> seconds in the future
*/
void P_alarm(delay)
unsigned int delay;
{
gettimeofday(&timeout, (struct timezone *) NULL);
timeout.tv_sec += delay;
}
/*
* NAME: P->timeout()
* DESCRIPTION: return TRUE if there is a timeout, FALSE otherwise
*/
bool P_timeout()
{
struct timeval t;
gettimeofday(&t, (struct timezone *) NULL);
return (t.tv_sec >= timeout.tv_sec &&
(t.tv_sec > timeout.tv_sec || t.tv_usec >= timeout.tv_usec));
}