X-Git-Url: https://git.hcoop.net/bpt/emacs.git/blobdiff_plain/a3aca278d6afbfdb5bf07d4ed314d3f3b936876e..ab5796a9f97180707734a81320e3eb81937281fe:/src/atimer.c diff --git a/src/atimer.c b/src/atimer.c index 54a038fd54..6b0e077788 100644 --- a/src/atimer.c +++ b/src/atimer.c @@ -35,11 +35,6 @@ Boston, MA 02111-1307, USA. */ #include #endif -/* The ubiquitous min/max macros. */ - -#define max(X, Y) ((X) > (Y) ? (X) : (Y)) -#define min(X, Y) ((X) < (Y) ? (X) : (Y)) - /* Free-list of atimer structures. */ static struct atimer *free_atimers; @@ -62,7 +57,7 @@ static struct atimer *atimers; int pending_atimers; -/* Block/unblock SIGALRM.. */ +/* Block/unblock SIGALRM. */ #define BLOCK_ATIMERS sigblock (sigmask (SIGALRM)) #define UNBLOCK_ATIMERS sigunblock (sigmask (SIGALRM)) @@ -137,12 +132,12 @@ start_atimer (type, time, fn, client_data) case ATIMER_ABSOLUTE: t->expiration = time; break; - + case ATIMER_RELATIVE: EMACS_GET_TIME (t->expiration); EMACS_ADD_TIME (t->expiration, t->expiration, time); break; - + case ATIMER_CONTINUOUS: EMACS_GET_TIME (t->expiration); EMACS_ADD_TIME (t->expiration, t->expiration, time); @@ -156,7 +151,7 @@ start_atimer (type, time, fn, client_data) /* Arrange for a SIGALRM at the time the next atimer is ripe. */ set_alarm (); - + return t; } @@ -168,14 +163,14 @@ cancel_atimer (timer) struct atimer *timer; { int i; - + BLOCK_ATIMERS; 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) ; @@ -189,7 +184,7 @@ cancel_atimer (timer) prev->next = t->next; else *list = t->next; - + t->next = free_atimers; free_atimers = t; break; @@ -214,7 +209,7 @@ append_atimer_lists (list1, list2) else { struct atimer *p; - + for (p = list1; p->next; p = p->next) ; p->next = list2; @@ -230,11 +225,11 @@ stop_other_atimers (t) struct atimer *t; { BLOCK_ATIMERS; - + if (t) { struct atimer *p, *prev; - + /* See if T is active. */ for (p = atimers, prev = 0; p && p != t; p = p->next) ; @@ -251,7 +246,7 @@ stop_other_atimers (t) /* T is not active. Let's handle this like T == 0. */ t = NULL; } - + stopped_atimers = append_atimer_lists (atimers, stopped_atimers); atimers = t; UNBLOCK_ATIMERS; @@ -268,18 +263,18 @@ run_all_atimers () { struct atimer *t = atimers; struct atimer *next; - + BLOCK_ATIMERS; atimers = stopped_atimers; stopped_atimers = NULL; - + while (t) { next = t->next; schedule_atimer (t); t = next; } - + UNBLOCK_ATIMERS; } } @@ -306,7 +301,7 @@ set_alarm () must reestablish each time. */ signal (SIGALRM, alarm_signal_handler); #endif /* USG */ - + if (atimers) { EMACS_TIME now, time; @@ -325,7 +320,7 @@ set_alarm () EMACS_SET_SECS (time, 0); EMACS_SET_USECS (time, 1000); } - + bzero (&it, sizeof it); it.it_value = time; setitimer (ITIMER_REAL, &it, 0); @@ -355,7 +350,7 @@ schedule_atimer (t) prev->next = t; else atimers = t; - + t->next = a; } @@ -368,20 +363,20 @@ alarm_signal_handler (signo) int signo; { EMACS_TIME now; - + EMACS_GET_TIME (now); pending_atimers = 0; - + while (atimers && (pending_atimers = interrupt_input_blocked) == 0 && EMACS_TIME_LE (atimers->expiration, now)) { struct atimer *t; - + t = atimers; atimers = atimers->next; t->fn (t); - + if (t->type == ATIMER_CONTINUOUS) { EMACS_ADD_TIME (t->expiration, now, t->interval); @@ -392,16 +387,10 @@ alarm_signal_handler (signo) t->next = free_atimers; free_atimers = t; } - + EMACS_GET_TIME (now); } - -#if defined (USG) && !defined (POSIX_SIGNALS) - /* USG systems forget handlers when they are used; - must reestablish each time. */ - signal (SIGALRM, alarm_signal_handler); -#endif /* USG */ - + set_alarm (); } @@ -444,3 +433,6 @@ init_atimer () pending_atimers = 0; signal (SIGALRM, alarm_signal_handler); } + +/* arch-tag: e6308261-eec6-404b-89fb-6e5909518d70 + (do not change this comment) */