emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r110319: Improve 'alarm' implementati


From: Eli Zaretskii
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r110319: Improve 'alarm' implementation on MS-Windows.
Date: Mon, 01 Oct 2012 11:46:01 +0200
User-agent: Bazaar (2.5.0)

------------------------------------------------------------
revno: 110319
committer: Eli Zaretskii <address@hidden>
branch nick: trunk
timestamp: Mon 2012-10-01 11:46:01 +0200
message:
  Improve 'alarm' implementation on MS-Windows.
  
   src/w32proc.c (alarm) [HAVE_SETITIMER]: Be more conformant to the expected
   return results.
   [!HAVE_SETITIMER]: Behave as the previous version that didn't
   support timers.
modified:
  src/ChangeLog
  src/w32proc.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2012-10-01 09:29:14 +0000
+++ b/src/ChangeLog     2012-10-01 09:46:01 +0000
@@ -7,6 +7,10 @@
        (getitimer, setitimer): If disable_itimers is non-zero, return an
        error indication without doing anything.  Reported by Fabrice
        Popineau <address@hidden> as part of bug#12544.
+       (alarm) [HAVE_SETITIMER]: Be more conformant to the expected
+       return results.
+       [!HAVE_SETITIMER]: Behave as the previous version that didn't
+       support timers.
 
        * emacs.c (shut_down_emacs) [WINDOWSNT]: Move the call to
        term_ntproc after all the other bookkeeping, to get timers working

=== modified file 'src/w32proc.c'
--- a/src/w32proc.c     2012-10-01 09:29:14 +0000
+++ b/src/w32proc.c     2012-10-01 09:46:01 +0000
@@ -669,15 +669,19 @@
 int
 alarm (int seconds)
 {
-  struct itimerval new_values;
+#ifdef HAVE_SETITIMER
+  struct itimerval new_values, old_values;
 
   new_values.it_value.tv_sec = seconds;
   new_values.it_value.tv_usec = 0;
   new_values.it_interval.tv_sec = new_values.it_interval.tv_usec = 0;
 
-  setitimer (ITIMER_REAL, &new_values, NULL);
-
+  if (setitimer (ITIMER_REAL, &new_values, &old_values) < 0)
+    return 0;
+  return old_values.it_value.tv_sec;
+#else
   return seconds;
+#endif
 }
 
 /* Defined in <process.h> which conflicts with the local copy */


reply via email to

[Prev in Thread] Current Thread [Next in Thread]