Commit 902e1319 authored by Tim Peters's avatar Tim Peters

Removed all instances of RETSIGTYPE from the source code: signal

handlers "return void", according to ANSI C.
Removed the new Py_RETURN_FROM_SIGNAL_HANDLER macro.
Left RETSIGTYPE in the config stuff, because it's not clear to
me that others aren't relying on it (e.g., extension modules).
parent 84dff256
...@@ -23,11 +23,6 @@ Meaning: To be defined iff i>>j does not extend the sign bit when i is a ...@@ -23,11 +23,6 @@ Meaning: To be defined iff i>>j does not extend the sign bit when i is a
signed integral type and i < 0. signed integral type and i < 0.
Used in: Py_ARITHMETIC_RIGHT_SHIFT Used in: Py_ARITHMETIC_RIGHT_SHIFT
RETSIGTYPE
Meaning: Expands to void or int, depending on what the platform wants
signal handlers to return. Note that only void is ANSI!
Used in: Py_RETURN_FROM_SIGNAL_HANDLER
Py_DEBUG Py_DEBUG
Meaning: Extra checks compiled in for debug mode. Meaning: Extra checks compiled in for debug mode.
Used in: Py_SAFE_DOWNCAST Used in: Py_SAFE_DOWNCAST
...@@ -66,18 +61,6 @@ extern "C" { ...@@ -66,18 +61,6 @@ extern "C" {
*/ */
#define Py_FORCE_EXPANSION(X) X #define Py_FORCE_EXPANSION(X) X
/* Py_RETURN_FROM_SIGNAL_HANDLER
* The return from a signal handler varies depending on whether RETSIGTYPE
* is int or void. The macro Py_RETURN_FROM_SIGNAL_HANDLER(VALUE) expands
* to
* return VALUE
* if RETSIGTYPE is int, else to nothing if RETSIGTYPE is void.
*/
#define int_PySIGRETURN(VALUE) return VALUE
#define void_PySIGRETURN(VALUE)
#define Py_RETURN_FROM_SIGNAL_HANDLER(VALUE) \
Py_FORCE_EXPANSION(RETSIGTYPE) ## _PySIGRETURN(VALUE)
/* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) /* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW)
* Cast VALUE to type NARROW from type WIDE. In Py_DEBUG mode, this * Cast VALUE to type NARROW from type WIDE. In Py_DEBUG mode, this
* assert-fails if any information is lost. * assert-fails if any information is lost.
......
...@@ -77,7 +77,7 @@ static jmp_buf PyFPE_jbuf; ...@@ -77,7 +77,7 @@ static jmp_buf PyFPE_jbuf;
static int PyFPE_counter = 0; static int PyFPE_counter = 0;
#endif #endif
typedef RETSIGTYPE Sigfunc(int); typedef void Sigfunc(int);
static Sigfunc sigfpe_handler; static Sigfunc sigfpe_handler;
static void fpe_reset(Sigfunc *); static void fpe_reset(Sigfunc *);
......
...@@ -427,13 +427,10 @@ setup_readline(void) ...@@ -427,13 +427,10 @@ setup_readline(void)
static jmp_buf jbuf; static jmp_buf jbuf;
/* ARGSUSED */ /* ARGSUSED */
static RETSIGTYPE static void
onintr(int sig) onintr(int sig)
{ {
longjmp(jbuf, 1); longjmp(jbuf, 1);
#if RETSIGTYPE != void
return 0;
#endif
} }
...@@ -444,7 +441,7 @@ call_readline(char *prompt) ...@@ -444,7 +441,7 @@ call_readline(char *prompt)
{ {
size_t n; size_t n;
char *p, *q; char *p, *q;
RETSIGTYPE (*old_inthandler)(int); void (*old_inthandler)(int);
old_inthandler = signal(SIGINT, onintr); old_inthandler = signal(SIGINT, onintr);
if (setjmp(jbuf)) { if (setjmp(jbuf)) {
#ifdef HAVE_SIGRELSE #ifdef HAVE_SIGRELSE
......
...@@ -26,7 +26,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. ...@@ -26,7 +26,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#include <signal.h> #include <signal.h>
#ifndef SIG_ERR #ifndef SIG_ERR
#define SIG_ERR ((RETSIGTYPE (*)(int))-1) #define SIG_ERR ((void (*)(int))-1)
#endif #endif
#if defined(PYOS_OS2) #if defined(PYOS_OS2)
...@@ -92,7 +92,7 @@ static PyObject *DefaultHandler; ...@@ -92,7 +92,7 @@ static PyObject *DefaultHandler;
static PyObject *IgnoreHandler; static PyObject *IgnoreHandler;
static PyObject *IntHandler; static PyObject *IntHandler;
static RETSIGTYPE (*old_siginthandler)(int) = SIG_DFL; static void (*old_siginthandler)(int) = SIG_DFL;
...@@ -117,7 +117,7 @@ checksignals_witharg(void * unused) ...@@ -117,7 +117,7 @@ checksignals_witharg(void * unused)
return PyErr_CheckSignals(); return PyErr_CheckSignals();
} }
static RETSIGTYPE static void
signal_handler(int sig_num) signal_handler(int sig_num)
{ {
#ifdef WITH_THREAD #ifdef WITH_THREAD
...@@ -136,14 +136,13 @@ signal_handler(int sig_num) ...@@ -136,14 +136,13 @@ signal_handler(int sig_num)
reset until explicit re-instated. reset until explicit re-instated.
Don't clear the 'func' field as it is our pointer Don't clear the 'func' field as it is our pointer
to the Python handler... */ to the Python handler... */
Py_RETURN_FROM_SIGNAL_HANDLER(0); return;
} }
#endif #endif
#ifdef HAVE_SIGINTERRUPT #ifdef HAVE_SIGINTERRUPT
siginterrupt(sig_num, 1); siginterrupt(sig_num, 1);
#endif #endif
signal(sig_num, signal_handler); signal(sig_num, signal_handler);
Py_RETURN_FROM_SIGNAL_HANDLER(0);
} }
...@@ -198,7 +197,7 @@ signal_signal(PyObject *self, PyObject *args) ...@@ -198,7 +197,7 @@ signal_signal(PyObject *self, PyObject *args)
PyObject *obj; PyObject *obj;
int sig_num; int sig_num;
PyObject *old_handler; PyObject *old_handler;
RETSIGTYPE (*func)(int); void (*func)(int);
if (!PyArg_Parse(args, "(iO)", &sig_num, &obj)) if (!PyArg_Parse(args, "(iO)", &sig_num, &obj))
return NULL; return NULL;
#ifdef WITH_THREAD #ifdef WITH_THREAD
...@@ -355,7 +354,7 @@ initsignal(void) ...@@ -355,7 +354,7 @@ initsignal(void)
Handlers[0].tripped = 0; Handlers[0].tripped = 0;
for (i = 1; i < NSIG; i++) { for (i = 1; i < NSIG; i++) {
RETSIGTYPE (*t)(int); void (*t)(int);
#ifdef HAVE_SIGACTION #ifdef HAVE_SIGACTION
struct sigaction act; struct sigaction act;
sigaction(i, 0, &act); sigaction(i, 0, &act);
......
...@@ -149,7 +149,7 @@ checksignals_witharg(void * arg) ...@@ -149,7 +149,7 @@ checksignals_witharg(void * arg)
return PyErr_CheckSignals(); return PyErr_CheckSignals();
} }
static RETSIGTYPE static void
intcatcher(int sig) intcatcher(int sig)
{ {
extern void Py_Exit(int); extern void Py_Exit(int);
...@@ -168,10 +168,9 @@ intcatcher(int sig) ...@@ -168,10 +168,9 @@ intcatcher(int sig)
} }
signal(SIGINT, intcatcher); signal(SIGINT, intcatcher);
Py_AddPendingCall(checksignals_witharg, NULL); Py_AddPendingCall(checksignals_witharg, NULL);
Py_RETURN_FROM_SIGNAL_HANDLER(0);
} }
static RETSIGTYPE (*old_siginthandler)(int) = SIG_DFL; static void (*old_siginthandler)(int) = SIG_DFL;
void void
PyOS_InitInterrupts(void) PyOS_InitInterrupts(void)
......
...@@ -652,9 +652,8 @@ has already been done for you). A good start is to copy the file ...@@ -652,9 +652,8 @@ has already been done for you). A good start is to copy the file
config.h.in to config.h and edit the latter to reflect the actual config.h.in to config.h and edit the latter to reflect the actual
configuration of your system. Most symbols must simply be defined as configuration of your system. Most symbols must simply be defined as
1 only if the corresponding feature is present and can be left alone 1 only if the corresponding feature is present and can be left alone
otherwise; however RETSIGTYPE must always be defined, either as int or otherwise; however the *_t type symbols must be defined as some variant
as void, and the *_t type symbols must be defined as some variant of of int if they need to be defined at all.
int if they need to be defined at all.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment