summaryrefslogtreecommitdiff
path: root/src/atimer.c
diff options
context:
space:
mode:
authorKen Brown <kbrown@cornell.edu>2019-03-09 17:06:54 -0500
committerKen Brown <kbrown@cornell.edu>2019-03-10 10:43:00 -0400
commitd6826546c4703d3a459dbf5f1f9453793e96a008 (patch)
treeea63c8a69e13ec7345b4b3cc9b60ceb6a4e14635 /src/atimer.c
parente70a65d403a67c25b17229bce8f173f0ab1b2f74 (diff)
downloademacs-d6826546c4703d3a459dbf5f1f9453793e96a008.tar.gz
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/atimer.c')
-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/>. */
#ifdef HAVE_TIMERFD
#include <errno.h>
-# include <sys/timerfd.h>
+#include <sys/timerfd.h>
+# ifdef CYGWIN
+# include <sys/utsname.h>
+# endif
#endif
#ifdef MSDOS
@@ -557,13 +560,28 @@ Return t if all self-tests are passed, nil otherwise. */)
#endif /* ENABLE_CHECKING */
+/* Cygwin has the timerfd interface starting with release 3.0.0, but
+ it is buggy until release 3.0.2. */
+#ifdef HAVE_TIMERFD
+static bool
+have_buggy_timerfd (void)
+{
+# ifdef CYGWIN
+ struct utsname name;
+ return uname (&name) < 0 || strverscmp (name.release, "3.0.2") < 0;
+# else
+ return false;
+# endif
+}
+#endif
+
void
init_atimer (void)
{
#ifdef HAVE_ITIMERSPEC
# ifdef HAVE_TIMERFD
/* Until this feature is considered stable, you can ask to not use it. */
- timerfd = (egetenv ("EMACS_IGNORE_TIMERFD") ? -1 :
+ timerfd = (egetenv ("EMACS_IGNORE_TIMERFD") || have_buggy_timerfd () ? -1 :
timerfd_create (CLOCK_REALTIME, TFD_NONBLOCK | TFD_CLOEXEC));
# endif
if (timerfd < 0)