summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1994-05-31 12:51:13 (GMT)
committerGuido van Rossum <guido@python.org>1994-05-31 12:51:13 (GMT)
commit6299d1ee031b6fde5080b6f9d2e15cad6f75eee2 (patch)
tree567ea496cc5b1e218753c8d40a81dc33a25117a6
parentc50158e70ca7dd308e5632259f66544fb2bb95c8 (diff)
downloadcpython-6299d1ee031b6fde5080b6f9d2e15cad6f75eee2.zip
cpython-6299d1ee031b6fde5080b6f9d2e15cad6f75eee2.tar.gz
cpython-6299d1ee031b6fde5080b6f9d2e15cad6f75eee2.tar.bz2
Speed up checking for signals and define intrcheck differently
-rw-r--r--Modules/signalmodule.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index a2ed72a..c36a9cf 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -30,6 +30,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "intrcheck.h"
#include <signal.h>
+#include <errno.h>
struct signalhandler_list {
int tripped;
@@ -37,6 +38,7 @@ struct signalhandler_list {
};
static struct signalhandler_list sig_list[NSIG];
+static int tripped = 0; /* Speed up sigcheck() when none tripped */
static object *default_sig_object;
static object *default_ignore_object;
@@ -55,6 +57,7 @@ static RETSIGTYPE
signal_handler(sig_num)
int sig_num;
{
+ tripped++;
sig_list[sig_num].tripped = 1;
(void *)signal(sig_num, &signal_handler);
}
@@ -148,7 +151,7 @@ initsignal()
sig_list[0].tripped = 0;
for (i = 1; i < NSIG; i++) {
- void *t; /* type cop-out */
+ RETSIGTYPE (*t)();
t = signal(i, SIG_IGN);
signal(i, t);
sig_list[i].tripped = 0;
@@ -313,7 +316,10 @@ int
sigcheck()
{
int i;
- object *f = getframe();
+ object *f;
+ if (!tripped)
+ return 0;
+ f = getframe();
if (f == NULL)
f = None;
for (i = 1; i < NSIG; i++) {
@@ -334,6 +340,7 @@ sigcheck()
}
}
}
+ tripped = 0;
return 0;
}
@@ -348,8 +355,9 @@ initintr()
int
intrcheck()
{
- if (!sigcheck())
- return 0;
- err_clear();
- return 1;
+ if (sig_list[SIGINT].tripped) {
+ sig_list[SIGINT].tripped = 0;
+ return 1;
+ }
+ return 0;
}