1*cfd712b4SDavid van Moolenbroek #include <minix/timers.h>
2433d6423SLionel Sambuc
3*cfd712b4SDavid van Moolenbroek /*
4*cfd712b4SDavid van Moolenbroek * Deactivate a timer and remove it from the timers queue. 'tmrs' is a pointer
5*cfd712b4SDavid van Moolenbroek * to the timers queue. 'tp' is a pointer to the timer to be removed, which
6*cfd712b4SDavid van Moolenbroek * generally should be on the queue (but this is not a requirement, and the
7*cfd712b4SDavid van Moolenbroek * kernel abuses this). If 'prev_time' is non-NULL, it is filled with the
8*cfd712b4SDavid van Moolenbroek * previous timer head time, which always exists since at least 'tp' is on it.
9*cfd712b4SDavid van Moolenbroek * The function returns TRUE if there is still at least one timer on the queue
10*cfd712b4SDavid van Moolenbroek * after this function is done, in which case 'next_time' (if non-NULL) is
11*cfd712b4SDavid van Moolenbroek * filled with the absolute expiry time of the new head timer.
12433d6423SLionel Sambuc */
13*cfd712b4SDavid van Moolenbroek int
tmrs_clrtimer(minix_timer_t ** tmrs,minix_timer_t * tp,clock_t * prev_time,clock_t * next_time)14*cfd712b4SDavid van Moolenbroek tmrs_clrtimer(minix_timer_t ** tmrs, minix_timer_t * tp, clock_t * prev_time,
15*cfd712b4SDavid van Moolenbroek clock_t * next_time)
16*cfd712b4SDavid van Moolenbroek {
17433d6423SLionel Sambuc minix_timer_t **atp;
18*cfd712b4SDavid van Moolenbroek int r;
19433d6423SLionel Sambuc
20*cfd712b4SDavid van Moolenbroek if (*tmrs != NULL) {
21*cfd712b4SDavid van Moolenbroek if (prev_time != NULL)
22*cfd712b4SDavid van Moolenbroek *prev_time = (*tmrs)->tmr_exp_time;
23*cfd712b4SDavid van Moolenbroek r = TRUE;
24*cfd712b4SDavid van Moolenbroek } else
25*cfd712b4SDavid van Moolenbroek r = FALSE;
26433d6423SLionel Sambuc
27*cfd712b4SDavid van Moolenbroek tp->tmr_func = NULL; /* clear the timer object */
28433d6423SLionel Sambuc
29433d6423SLionel Sambuc for (atp = tmrs; *atp != NULL; atp = &(*atp)->tmr_next) {
30433d6423SLionel Sambuc if (*atp == tp) {
31433d6423SLionel Sambuc *atp = tp->tmr_next;
32433d6423SLionel Sambuc break;
33433d6423SLionel Sambuc }
34433d6423SLionel Sambuc }
35433d6423SLionel Sambuc
36*cfd712b4SDavid van Moolenbroek if (next_time != NULL) {
37*cfd712b4SDavid van Moolenbroek if (*tmrs != NULL)
38433d6423SLionel Sambuc *next_time = (*tmrs)->tmr_exp_time;
39433d6423SLionel Sambuc else
40433d6423SLionel Sambuc *next_time = 0;
41433d6423SLionel Sambuc }
42433d6423SLionel Sambuc
43*cfd712b4SDavid van Moolenbroek return r;
44433d6423SLionel Sambuc }
45