minix/lib/libtimers/tmrs_clr.c

40 lines
843 B
C
Raw Normal View History

2005-04-21 16:53:53 +02:00
#include "timers.h"
/*===========================================================================*
* tmrs_clrtimer *
*===========================================================================*/
clock_t tmrs_clrtimer(tmrs, tp, next_time)
minix_timer_t **tmrs; /* pointer to timers queue */
minix_timer_t *tp; /* timer to be removed */
clock_t *next_time;
2005-04-21 16:53:53 +02:00
{
/* Deactivate a timer and remove it from the timers queue.
*/
minix_timer_t **atp;
clock_t prev_time;
if(*tmrs)
prev_time = (*tmrs)->tmr_exp_time;
else
prev_time = 0;
2005-04-21 16:53:53 +02:00
tp->tmr_exp_time = TMR_NEVER;
for (atp = tmrs; *atp != NULL; atp = &(*atp)->tmr_next) {
if (*atp == tp) {
*atp = tp->tmr_next;
break;
2005-04-21 16:53:53 +02:00
}
}
if(next_time) {
if(*tmrs)
*next_time = (*tmrs)->tmr_exp_time;
else
*next_time = 0;
}
return prev_time;
2005-04-21 16:53:53 +02:00
}