- /* See if TIMER is active. */
- for (t = atimers, prev = 0; t && t != timer; t = t->next)
- ;
+ for (i = 0; i < 2; ++i)
+ {
+ struct atimer *t, *prev;
+ struct atimer **list = i ? &stopped_atimers : &atimers;
+
+ /* See if TIMER is active or stopped. */
+ for (t = *list, prev = NULL; t && t != timer; prev = t, t = t->next)
+ ;
+
+ /* If it is, take it off the its list, and put in on the
+ free-list. We don't bother to arrange for setting a
+ different alarm time, since a too early one doesn't hurt. */
+ if (t)
+ {
+ if (prev)
+ prev->next = t->next;
+ else
+ *list = t->next;
+
+ t->next = free_atimers;
+ free_atimers = t;
+ break;
+ }
+ }
+
+ UNBLOCK_ATIMERS;
+}
+
+
+/* Append two lists of atimers LIST1 and LIST2 and return the
+ result list. */
+
+static struct atimer *
+append_atimer_lists (list1, list2)
+ struct atimer *list1, *list2;
+{
+ if (list1 == NULL)
+ return list2;
+ else if (list2 == NULL)
+ return list1;
+ else
+ {
+ struct atimer *p;
+
+ for (p = list1; p->next; p = p->next)
+ ;
+ p->next = list2;
+ return list1;
+ }
+}
+
+
+/* Stop all timers except timer T. T null means stop all timers. */
+
+void
+stop_other_atimers (t)
+ struct atimer *t;
+{
+ BLOCK_ATIMERS;