132 |
case ATIMER_ABSOLUTE: |
case ATIMER_ABSOLUTE: |
133 |
t->expiration = time; |
t->expiration = time; |
134 |
break; |
break; |
135 |
|
|
136 |
case ATIMER_RELATIVE: |
case ATIMER_RELATIVE: |
137 |
EMACS_GET_TIME (t->expiration); |
EMACS_GET_TIME (t->expiration); |
138 |
EMACS_ADD_TIME (t->expiration, t->expiration, time); |
EMACS_ADD_TIME (t->expiration, t->expiration, time); |
139 |
break; |
break; |
140 |
|
|
141 |
case ATIMER_CONTINUOUS: |
case ATIMER_CONTINUOUS: |
142 |
EMACS_GET_TIME (t->expiration); |
EMACS_GET_TIME (t->expiration); |
143 |
EMACS_ADD_TIME (t->expiration, t->expiration, time); |
EMACS_ADD_TIME (t->expiration, t->expiration, time); |
151 |
|
|
152 |
/* Arrange for a SIGALRM at the time the next atimer is ripe. */ |
/* Arrange for a SIGALRM at the time the next atimer is ripe. */ |
153 |
set_alarm (); |
set_alarm (); |
154 |
|
|
155 |
return t; |
return t; |
156 |
} |
} |
157 |
|
|
163 |
struct atimer *timer; |
struct atimer *timer; |
164 |
{ |
{ |
165 |
int i; |
int i; |
166 |
|
|
167 |
BLOCK_ATIMERS; |
BLOCK_ATIMERS; |
168 |
|
|
169 |
for (i = 0; i < 2; ++i) |
for (i = 0; i < 2; ++i) |
170 |
{ |
{ |
171 |
struct atimer *t, *prev; |
struct atimer *t, *prev; |
172 |
struct atimer **list = i ? &stopped_atimers : &atimers; |
struct atimer **list = i ? &stopped_atimers : &atimers; |
173 |
|
|
174 |
/* See if TIMER is active or stopped. */ |
/* See if TIMER is active or stopped. */ |
175 |
for (t = *list, prev = NULL; t && t != timer; prev = t, t = t->next) |
for (t = *list, prev = NULL; t && t != timer; prev = t, t = t->next) |
176 |
; |
; |
184 |
prev->next = t->next; |
prev->next = t->next; |
185 |
else |
else |
186 |
*list = t->next; |
*list = t->next; |
187 |
|
|
188 |
t->next = free_atimers; |
t->next = free_atimers; |
189 |
free_atimers = t; |
free_atimers = t; |
190 |
break; |
break; |
209 |
else |
else |
210 |
{ |
{ |
211 |
struct atimer *p; |
struct atimer *p; |
212 |
|
|
213 |
for (p = list1; p->next; p = p->next) |
for (p = list1; p->next; p = p->next) |
214 |
; |
; |
215 |
p->next = list2; |
p->next = list2; |
225 |
struct atimer *t; |
struct atimer *t; |
226 |
{ |
{ |
227 |
BLOCK_ATIMERS; |
BLOCK_ATIMERS; |
228 |
|
|
229 |
if (t) |
if (t) |
230 |
{ |
{ |
231 |
struct atimer *p, *prev; |
struct atimer *p, *prev; |
232 |
|
|
233 |
/* See if T is active. */ |
/* See if T is active. */ |
234 |
for (p = atimers, prev = 0; p && p != t; p = p->next) |
for (p = atimers, prev = 0; p && p != t; p = p->next) |
235 |
; |
; |
246 |
/* T is not active. Let's handle this like T == 0. */ |
/* T is not active. Let's handle this like T == 0. */ |
247 |
t = NULL; |
t = NULL; |
248 |
} |
} |
249 |
|
|
250 |
stopped_atimers = append_atimer_lists (atimers, stopped_atimers); |
stopped_atimers = append_atimer_lists (atimers, stopped_atimers); |
251 |
atimers = t; |
atimers = t; |
252 |
UNBLOCK_ATIMERS; |
UNBLOCK_ATIMERS; |
263 |
{ |
{ |
264 |
struct atimer *t = atimers; |
struct atimer *t = atimers; |
265 |
struct atimer *next; |
struct atimer *next; |
266 |
|
|
267 |
BLOCK_ATIMERS; |
BLOCK_ATIMERS; |
268 |
atimers = stopped_atimers; |
atimers = stopped_atimers; |
269 |
stopped_atimers = NULL; |
stopped_atimers = NULL; |
270 |
|
|
271 |
while (t) |
while (t) |
272 |
{ |
{ |
273 |
next = t->next; |
next = t->next; |
274 |
schedule_atimer (t); |
schedule_atimer (t); |
275 |
t = next; |
t = next; |
276 |
} |
} |
277 |
|
|
278 |
UNBLOCK_ATIMERS; |
UNBLOCK_ATIMERS; |
279 |
} |
} |
280 |
} |
} |
301 |
must reestablish each time. */ |
must reestablish each time. */ |
302 |
signal (SIGALRM, alarm_signal_handler); |
signal (SIGALRM, alarm_signal_handler); |
303 |
#endif /* USG */ |
#endif /* USG */ |
304 |
|
|
305 |
if (atimers) |
if (atimers) |
306 |
{ |
{ |
307 |
EMACS_TIME now, time; |
EMACS_TIME now, time; |
320 |
EMACS_SET_SECS (time, 0); |
EMACS_SET_SECS (time, 0); |
321 |
EMACS_SET_USECS (time, 1000); |
EMACS_SET_USECS (time, 1000); |
322 |
} |
} |
323 |
|
|
324 |
bzero (&it, sizeof it); |
bzero (&it, sizeof it); |
325 |
it.it_value = time; |
it.it_value = time; |
326 |
setitimer (ITIMER_REAL, &it, 0); |
setitimer (ITIMER_REAL, &it, 0); |
350 |
prev->next = t; |
prev->next = t; |
351 |
else |
else |
352 |
atimers = t; |
atimers = t; |
353 |
|
|
354 |
t->next = a; |
t->next = a; |
355 |
} |
} |
356 |
|
|
363 |
int signo; |
int signo; |
364 |
{ |
{ |
365 |
EMACS_TIME now; |
EMACS_TIME now; |
366 |
|
|
367 |
EMACS_GET_TIME (now); |
EMACS_GET_TIME (now); |
368 |
pending_atimers = 0; |
pending_atimers = 0; |
369 |
|
|
370 |
while (atimers |
while (atimers |
371 |
&& (pending_atimers = interrupt_input_blocked) == 0 |
&& (pending_atimers = interrupt_input_blocked) == 0 |
372 |
&& EMACS_TIME_LE (atimers->expiration, now)) |
&& EMACS_TIME_LE (atimers->expiration, now)) |
373 |
{ |
{ |
374 |
struct atimer *t; |
struct atimer *t; |
375 |
|
|
376 |
t = atimers; |
t = atimers; |
377 |
atimers = atimers->next; |
atimers = atimers->next; |
378 |
t->fn (t); |
t->fn (t); |
379 |
|
|
380 |
if (t->type == ATIMER_CONTINUOUS) |
if (t->type == ATIMER_CONTINUOUS) |
381 |
{ |
{ |
382 |
EMACS_ADD_TIME (t->expiration, now, t->interval); |
EMACS_ADD_TIME (t->expiration, now, t->interval); |
387 |
t->next = free_atimers; |
t->next = free_atimers; |
388 |
free_atimers = t; |
free_atimers = t; |
389 |
} |
} |
390 |
|
|
391 |
EMACS_GET_TIME (now); |
EMACS_GET_TIME (now); |
392 |
} |
} |
393 |
|
|
394 |
set_alarm (); |
set_alarm (); |
395 |
} |
} |
396 |
|
|