diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2018-09-16 08:52:16 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2018-09-16 08:53:18 -0700 |
commit | 238c7cd730819ddba2dbde3c46ee36136575695b (patch) | |
tree | 150ad45986a23ff792912fcefeecd5a111190214 /src/atimer.c | |
parent | 7fac15f9945ed6def9b60942f3595c18f1740f31 (diff) | |
download | emacs-238c7cd730819ddba2dbde3c46ee36136575695b.tar.gz emacs-238c7cd730819ddba2dbde3c46ee36136575695b.tar.bz2 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/atimer.c')
-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, sigset_t oldset; /* Round TIMESTAMP up to the next full second if we don't have itimers. */ -#ifndef HAVE_SETITIMER +#if ! (defined HAVE_ITIMERSPEC || defined HAVE_SETITIMER) if (timestamp.tv_nsec != 0 && timestamp.tv_sec < TYPE_MAXIMUM (time_t)) timestamp = make_timespec (timestamp.tv_sec + 1, 0); -#endif /* not HAVE_SETITIMER */ +#endif /* Get an atimer structure from the free-list, or allocate a new one. */ @@ -494,15 +494,14 @@ debug_timer_callback (struct atimer *t) r->intime = 0; else if (result >= 0) { -#ifdef HAVE_SETITIMER + bool intime = true; +#if defined HAVE_ITIMERSPEC || defined HAVE_SETITIMER struct timespec delta = timespec_sub (now, r->expected); /* Too late if later than expected + 0.02s. FIXME: this should depend from system clock resolution. */ - if (timespec_cmp (delta, make_timespec (0, 20000000)) > 0) - r->intime = 0; - else -#endif /* HAVE_SETITIMER */ - r->intime = 1; + intime = timespec_cmp (delta, make_timespec (0, 20000000)) <= 0; +#endif + r->intime = intime; } } |