xref: /minix/minix/lib/libtimers/tmrs_clr.c (revision 7f5f010b)
1 #include "timers.h"
2 
3 /*===========================================================================*
4  *				tmrs_clrtimer				     *
5  *===========================================================================*/
6 clock_t tmrs_clrtimer(tmrs, tp, next_time)
7 minix_timer_t **tmrs;				/* pointer to timers queue */
8 minix_timer_t *tp;				/* timer to be removed */
9 clock_t *next_time;
10 {
11 /* Deactivate a timer and remove it from the timers queue.
12  */
13   minix_timer_t **atp;
14   clock_t prev_time;
15 
16   if(*tmrs)
17   	prev_time = (*tmrs)->tmr_exp_time;
18   else
19   	prev_time = 0;
20 
21   tp->tmr_exp_time = TMR_NEVER;
22 
23   for (atp = tmrs; *atp != NULL; atp = &(*atp)->tmr_next) {
24 	if (*atp == tp) {
25 		*atp = tp->tmr_next;
26 		break;
27 	}
28   }
29 
30   if(next_time) {
31   	if(*tmrs)
32   		*next_time = (*tmrs)->tmr_exp_time;
33   	else
34   		*next_time = 0;
35   }
36 
37   return prev_time;
38 }
39 
40