X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/93afd0f1d463bec0fc8d3127c1d34ccaa4dbe99b..587e4b13796f78ed582f36ff8b2ea261c6902b6f:/src/atimer.c?ds=sidebyside
diff --git a/src/atimer.c b/src/atimer.c
index 41dd9e53a0..556272d791 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -1,13 +1,13 @@
/* Asynchronous timers.
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005,
- 2006, 2007 Free Software Foundation, Inc.
+ 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
This file is part of GNU Emacs.
-GNU Emacs is free software; you can redistribute it and/or modify
+GNU Emacs is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -15,13 +15,12 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-Boston, MA 02110-1301, USA. */
+along with GNU Emacs. If not, see . */
#include
#include
#include
+#include
#include
#include
#include
@@ -297,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;
@@ -355,20 +348,12 @@ schedule_atimer (t)
t->next = a;
}
-
-/* Signal handler for SIGALRM. SIGNO is the signal number, i.e.
- SIGALRM. */
-
-SIGTYPE
-alarm_signal_handler (signo)
- int signo;
+static void
+run_timers ()
{
EMACS_TIME now;
- SIGNAL_THREAD_CHECK (signo);
-
EMACS_GET_TIME (now);
- pending_atimers = 0;
while (atimers
&& (pending_atimers = interrupt_input_blocked) == 0
@@ -378,9 +363,7 @@ alarm_signal_handler (signo)
t = atimers;
atimers = atimers->next;
-#ifndef MAC_OSX
t->fn (t);
-#endif
if (t->type == ATIMER_CONTINUOUS)
{
@@ -392,16 +375,45 @@ alarm_signal_handler (signo)
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
+}
+
+
+/* Signal handler for SIGALRM. SIGNO is the signal number, i.e.
+ SIGALRM. */
+
+SIGTYPE
+alarm_signal_handler (signo)
+ int signo;
+{
+#ifndef SYNC_INPUT
+ SIGNAL_THREAD_CHECK (signo);
+#endif
+
+ pending_atimers = 1;
+#ifdef SYNC_INPUT
+ pending_signals = 1;
+#else
+ run_timers ();
+#endif
}
@@ -413,7 +425,7 @@ do_pending_atimers ()
if (pending_atimers)
{
BLOCK_ATIMERS;
- alarm_signal_handler (SIGALRM);
+ run_timers ();
UNBLOCK_ATIMERS;
}
}
@@ -439,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);
}