]> code.delx.au - gnu-emacs/blobdiff - src/atimer.c
Merge from emacs-23
[gnu-emacs] / src / atimer.c
index f1e2b1dfdd5de0cf86eaf2dfc176afd498b6293e..556272d79181aec92c32f32df45d50bbdd529b6a 100644 (file)
@@ -1,6 +1,6 @@
 /* Asynchronous timers.
    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005,
-                 2006, 2007, 2008  Free Software Foundation, Inc.
+                 2006, 2007, 2008, 2009, 2010  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -20,6 +20,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <config.h>
 #include <signal.h>
 #include <stdio.h>
+#include <setjmp.h>
 #include <lisp.h>
 #include <syssignal.h>
 #include <systime.h>
@@ -295,12 +296,6 @@ unwind_stop_other_atimers (dummy)
 static void
 set_alarm ()
 {
-#if defined (USG) && !defined (POSIX_SIGNALS)
-  /* USG systems forget handlers when they are used;
-     must reestablish each time.  */
-  signal (SIGALRM, alarm_signal_handler);
-#endif /* USG */
-
   if (atimers)
     {
       EMACS_TIME now, time;
@@ -368,9 +363,7 @@ run_timers ()
 
       t = atimers;
       atimers = atimers->next;
-#ifndef MAC_OSX
       t->fn (t);
-#endif
 
       if (t->type == ATIMER_CONTINUOUS)
        {
@@ -382,16 +375,25 @@ run_timers ()
          t->next = free_atimers;
          free_atimers = t;
        }
-#ifdef MAC_OSX
-      /* Fix for Ctrl-G.  Perhaps this should apply to all platforms. */
-      t->fn (t); 
-#endif
 
       EMACS_GET_TIME (now);
     }
 
+  if (! atimers)
+    pending_atimers = 0;
+
+#ifdef SYNC_INPUT
+  if (pending_atimers)
+    pending_signals = 1;
+  else
+    {
+      pending_signals = interrupt_input_pending;
+      set_alarm ();
+    }
+#else
   if (! pending_atimers)
     set_alarm ();
+#endif
 }
 
 
@@ -402,8 +404,14 @@ SIGTYPE
 alarm_signal_handler (signo)
      int signo;
 {
-  pending_atimers = 1;
 #ifndef SYNC_INPUT
+  SIGNAL_THREAD_CHECK (signo);
+#endif
+
+  pending_atimers = 1;
+#ifdef SYNC_INPUT
+  pending_signals = 1;
+#else
   run_timers ();
 #endif
 }
@@ -443,8 +451,9 @@ turn_on_atimers (on)
 void
 init_atimer ()
 {
-  free_atimers = atimers = NULL;
+  free_atimers = stopped_atimers = atimers = NULL;
   pending_atimers = 0;
+  /* pending_signals is initialized in init_keyboard.*/
   signal (SIGALRM, alarm_signal_handler);
 }