aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKen Brown2019-03-09 17:06:54 -0500
committerKen Brown2019-03-10 10:43:00 -0400
commitd6826546c4703d3a459dbf5f1f9453793e96a008 (patch)
treeea63c8a69e13ec7345b4b3cc9b60ceb6a4e14635 /src
parente70a65d403a67c25b17229bce8f173f0ab1b2f74 (diff)
downloademacs-d6826546c4703d3a459dbf5f1f9453793e96a008.tar.gz
emacs-d6826546c4703d3a459dbf5f1f9453793e96a008.zip
Use a runtime test for timerfd on Cygwin (Bug#34618)
* src/atimer.c [HAVE_TIMERFD] (have_buggy_timerfd): New function. (init_atimer) Use it.
Diffstat (limited to 'src')
-rw-r--r--src/atimer.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/atimer.c b/src/atimer.c
index d36c4f1f5a3..8387b8aa0e0 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -28,7 +28,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
28 28
29#ifdef HAVE_TIMERFD 29#ifdef HAVE_TIMERFD
30#include <errno.h> 30#include <errno.h>
31# include <sys/timerfd.h> 31#include <sys/timerfd.h>
32# ifdef CYGWIN
33# include <sys/utsname.h>
34# endif
32#endif 35#endif
33 36
34#ifdef MSDOS 37#ifdef MSDOS
@@ -557,13 +560,28 @@ Return t if all self-tests are passed, nil otherwise. */)
557 560
558#endif /* ENABLE_CHECKING */ 561#endif /* ENABLE_CHECKING */
559 562
563/* Cygwin has the timerfd interface starting with release 3.0.0, but
564 it is buggy until release 3.0.2. */
565#ifdef HAVE_TIMERFD
566static bool
567have_buggy_timerfd (void)
568{
569# ifdef CYGWIN
570 struct utsname name;
571 return uname (&name) < 0 || strverscmp (name.release, "3.0.2") < 0;
572# else
573 return false;
574# endif
575}
576#endif
577
560void 578void
561init_atimer (void) 579init_atimer (void)
562{ 580{
563#ifdef HAVE_ITIMERSPEC 581#ifdef HAVE_ITIMERSPEC
564# ifdef HAVE_TIMERFD 582# ifdef HAVE_TIMERFD
565 /* Until this feature is considered stable, you can ask to not use it. */ 583 /* Until this feature is considered stable, you can ask to not use it. */
566 timerfd = (egetenv ("EMACS_IGNORE_TIMERFD") ? -1 : 584 timerfd = (egetenv ("EMACS_IGNORE_TIMERFD") || have_buggy_timerfd () ? -1 :
567 timerfd_create (CLOCK_REALTIME, TFD_NONBLOCK | TFD_CLOEXEC)); 585 timerfd_create (CLOCK_REALTIME, TFD_NONBLOCK | TFD_CLOEXEC));
568# endif 586# endif
569 if (timerfd < 0) 587 if (timerfd < 0)