diff options
| author | Paul Eggert | 2018-09-16 08:52:16 -0700 |
|---|---|---|
| committer | Paul Eggert | 2018-09-16 08:53:18 -0700 |
| commit | 238c7cd730819ddba2dbde3c46ee36136575695b (patch) | |
| tree | 150ad45986a23ff792912fcefeecd5a111190214 /src | |
| parent | 7fac15f9945ed6def9b60942f3595c18f1740f31 (diff) | |
| download | emacs-238c7cd730819ddba2dbde3c46ee36136575695b.tar.gz emacs-238c7cd730819ddba2dbde3c46ee36136575695b.zip | |
Don’t assume obsolescent setitimer function
* src/atimer.c (start_atimer, debug_timer_callback):
Don’t assume support for setitimer merely because struct
itimerspec works. POSIX no longer requires support for the
obsolescent setitimer function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/atimer.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/atimer.c b/src/atimer.c index 97f07362ae1..505f6bcea18 100644 --- a/src/atimer.c +++ b/src/atimer.c | |||
| @@ -113,10 +113,10 @@ start_atimer (enum atimer_type type, struct timespec timestamp, | |||
| 113 | sigset_t oldset; | 113 | sigset_t oldset; |
| 114 | 114 | ||
| 115 | /* Round TIMESTAMP up to the next full second if we don't have itimers. */ | 115 | /* Round TIMESTAMP up to the next full second if we don't have itimers. */ |
| 116 | #ifndef HAVE_SETITIMER | 116 | #if ! (defined HAVE_ITIMERSPEC || defined HAVE_SETITIMER) |
| 117 | if (timestamp.tv_nsec != 0 && timestamp.tv_sec < TYPE_MAXIMUM (time_t)) | 117 | if (timestamp.tv_nsec != 0 && timestamp.tv_sec < TYPE_MAXIMUM (time_t)) |
| 118 | timestamp = make_timespec (timestamp.tv_sec + 1, 0); | 118 | timestamp = make_timespec (timestamp.tv_sec + 1, 0); |
| 119 | #endif /* not HAVE_SETITIMER */ | 119 | #endif |
| 120 | 120 | ||
| 121 | /* Get an atimer structure from the free-list, or allocate | 121 | /* Get an atimer structure from the free-list, or allocate |
| 122 | a new one. */ | 122 | a new one. */ |
| @@ -494,15 +494,14 @@ debug_timer_callback (struct atimer *t) | |||
| 494 | r->intime = 0; | 494 | r->intime = 0; |
| 495 | else if (result >= 0) | 495 | else if (result >= 0) |
| 496 | { | 496 | { |
| 497 | #ifdef HAVE_SETITIMER | 497 | bool intime = true; |
| 498 | #if defined HAVE_ITIMERSPEC || defined HAVE_SETITIMER | ||
| 498 | struct timespec delta = timespec_sub (now, r->expected); | 499 | struct timespec delta = timespec_sub (now, r->expected); |
| 499 | /* Too late if later than expected + 0.02s. FIXME: | 500 | /* Too late if later than expected + 0.02s. FIXME: |
| 500 | this should depend from system clock resolution. */ | 501 | this should depend from system clock resolution. */ |
| 501 | if (timespec_cmp (delta, make_timespec (0, 20000000)) > 0) | 502 | intime = timespec_cmp (delta, make_timespec (0, 20000000)) <= 0; |
| 502 | r->intime = 0; | 503 | #endif |
| 503 | else | 504 | r->intime = intime; |
| 504 | #endif /* HAVE_SETITIMER */ | ||
| 505 | r->intime = 1; | ||
| 506 | } | 505 | } |
| 507 | } | 506 | } |
| 508 | 507 | ||