/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1982-2010 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
#include <ast.h>
#include <sig.h>
#include <error.h>
#include "fault.h"
#include "defs.h"
#include "FEATURE/sigfeatures"
typedef struct _timer
{
double wakeup;
double incr;
void (*action)(void*);
void *handle;
} Timer_t;
static char time_state;
static double getnow(void)
{
register double now;
#ifdef timeofday
#else
#endif /* timeofday */
return(now+.001);
}
/*
* set an alarm for <t> seconds
*/
static double setalarm(register double t)
{
#if defined(_lib_setitimer) && defined(ITIMER_REAL)
#else
unsigned seconds = (unsigned)t;
if(t && seconds<1)
seconds=1;
#endif
return(t);
}
/* signal handler for alarm call */
{
double now;
static double left;
left = 0;
time_state &= ~SIGALRM_CALL;
else if(alarm(0))
if(time_state)
{
return;
}
time_state |= IN_SIGALRM;
while(1)
{
{
{
{
}
else
{
}
}
else
{
if(tplast)
else
}
}
{
}
{
if(left==0)
else
}
if(tp)
{
void (*action)(void*);
time_state &= ~IN_SIGALRM;
time_state |= IN_SIGALRM;
}
else
break;
}
if(!tpmin)
time_state &= ~IN_SIGALRM;
}
{
}
{
double t;
t = ((double)msec)/1000.;
if(t<=0 || !action)
return((void*)0);
return((void*)0);
{
{
if(hp)
{
}
}
}
time_state &= ~IN_ADDTIMEOUT;
{
tp=0;
}
return((void*)tp);
}
/*
* delete timer <tp>. If <tp> is NULL, all timers are deleted
*/
{
if(tp)
else
{
if(tpmin)
{
tpmin = 0;
setalarm((double)0);
}
}
}