Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4f1b208

Browse files
committed
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).
1 parent 56055a4 commit 4f1b208

6 files changed

Lines changed: 13 additions & 36 deletions

File tree

Include/pyport.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,6 @@ Meaning: To be defined iff i>>j does not extend the sign bit when i is a
2323
signed integral type and i < 0.
2424
Used in: Py_ARITHMETIC_RIGHT_SHIFT
2525
26-
RETSIGTYPE
27-
Meaning: Expands to void or int, depending on what the platform wants
28-
signal handlers to return. Note that only void is ANSI!
29-
Used in: Py_RETURN_FROM_SIGNAL_HANDLER
30-
3126
Py_DEBUG
3227
Meaning: Extra checks compiled in for debug mode.
3328
Used in: Py_SAFE_DOWNCAST
@@ -66,18 +61,6 @@ extern "C" {
6661
*/
6762
#define Py_FORCE_EXPANSION(X) X
6863

69-
/* Py_RETURN_FROM_SIGNAL_HANDLER
70-
* The return from a signal handler varies depending on whether RETSIGTYPE
71-
* is int or void. The macro Py_RETURN_FROM_SIGNAL_HANDLER(VALUE) expands
72-
* to
73-
* return VALUE
74-
* if RETSIGTYPE is int, else to nothing if RETSIGTYPE is void.
75-
*/
76-
#define int_PySIGRETURN(VALUE) return VALUE
77-
#define void_PySIGRETURN(VALUE)
78-
#define Py_RETURN_FROM_SIGNAL_HANDLER(VALUE) \
79-
Py_FORCE_EXPANSION(RETSIGTYPE) ## _PySIGRETURN(VALUE)
80-
8164
/* Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW)
8265
* Cast VALUE to type NARROW from type WIDE. In Py_DEBUG mode, this
8366
* assert-fails if any information is lost.

Modules/fpectlmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static jmp_buf PyFPE_jbuf;
7777
static int PyFPE_counter = 0;
7878
#endif
7979

80-
typedef RETSIGTYPE Sigfunc(int);
80+
typedef void Sigfunc(int);
8181
static Sigfunc sigfpe_handler;
8282
static void fpe_reset(Sigfunc *);
8383

Modules/readline.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,10 @@ setup_readline(void)
427427
static jmp_buf jbuf;
428428

429429
/* ARGSUSED */
430-
static RETSIGTYPE
430+
static void
431431
onintr(int sig)
432432
{
433433
longjmp(jbuf, 1);
434-
#if RETSIGTYPE != void
435-
return 0;
436-
#endif
437434
}
438435

439436

@@ -444,7 +441,7 @@ call_readline(char *prompt)
444441
{
445442
size_t n;
446443
char *p, *q;
447-
RETSIGTYPE (*old_inthandler)(int);
444+
void (*old_inthandler)(int);
448445
old_inthandler = signal(SIGINT, onintr);
449446
if (setjmp(jbuf)) {
450447
#ifdef HAVE_SIGRELSE

Modules/signalmodule.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
2626
#include <signal.h>
2727

2828
#ifndef SIG_ERR
29-
#define SIG_ERR ((RETSIGTYPE (*)(int))-1)
29+
#define SIG_ERR ((void (*)(int))-1)
3030
#endif
3131

3232
#if defined(PYOS_OS2)
@@ -92,7 +92,7 @@ static PyObject *DefaultHandler;
9292
static PyObject *IgnoreHandler;
9393
static PyObject *IntHandler;
9494

95-
static RETSIGTYPE (*old_siginthandler)(int) = SIG_DFL;
95+
static void (*old_siginthandler)(int) = SIG_DFL;
9696

9797

9898

@@ -117,7 +117,7 @@ checksignals_witharg(void * unused)
117117
return PyErr_CheckSignals();
118118
}
119119

120-
static RETSIGTYPE
120+
static void
121121
signal_handler(int sig_num)
122122
{
123123
#ifdef WITH_THREAD
@@ -136,14 +136,13 @@ signal_handler(int sig_num)
136136
reset until explicit re-instated.
137137
Don't clear the 'func' field as it is our pointer
138138
to the Python handler... */
139-
Py_RETURN_FROM_SIGNAL_HANDLER(0);
139+
return;
140140
}
141141
#endif
142142
#ifdef HAVE_SIGINTERRUPT
143143
siginterrupt(sig_num, 1);
144144
#endif
145145
signal(sig_num, signal_handler);
146-
Py_RETURN_FROM_SIGNAL_HANDLER(0);
147146
}
148147

149148

@@ -198,7 +197,7 @@ signal_signal(PyObject *self, PyObject *args)
198197
PyObject *obj;
199198
int sig_num;
200199
PyObject *old_handler;
201-
RETSIGTYPE (*func)(int);
200+
void (*func)(int);
202201
if (!PyArg_Parse(args, "(iO)", &sig_num, &obj))
203202
return NULL;
204203
#ifdef WITH_THREAD
@@ -355,7 +354,7 @@ initsignal(void)
355354

356355
Handlers[0].tripped = 0;
357356
for (i = 1; i < NSIG; i++) {
358-
RETSIGTYPE (*t)(int);
357+
void (*t)(int);
359358
#ifdef HAVE_SIGACTION
360359
struct sigaction act;
361360
sigaction(i, 0, &act);

Parser/intrcheck.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ checksignals_witharg(void * arg)
149149
return PyErr_CheckSignals();
150150
}
151151

152-
static RETSIGTYPE
152+
static void
153153
intcatcher(int sig)
154154
{
155155
extern void Py_Exit(int);
@@ -168,10 +168,9 @@ intcatcher(int sig)
168168
}
169169
signal(SIGINT, intcatcher);
170170
Py_AddPendingCall(checksignals_witharg, NULL);
171-
Py_RETURN_FROM_SIGNAL_HANDLER(0);
172171
}
173172

174-
static RETSIGTYPE (*old_siginthandler)(int) = SIG_DFL;
173+
static void (*old_siginthandler)(int) = SIG_DFL;
175174

176175
void
177176
PyOS_InitInterrupts(void)

README

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,9 +652,8 @@ has already been done for you). A good start is to copy the file
652652
config.h.in to config.h and edit the latter to reflect the actual
653653
configuration of your system. Most symbols must simply be defined as
654654
1 only if the corresponding feature is present and can be left alone
655-
otherwise; however RETSIGTYPE must always be defined, either as int or
656-
as void, and the *_t type symbols must be defined as some variant of
657-
int if they need to be defined at all.
655+
otherwise; however the *_t type symbols must be defined as some variant
656+
of int if they need to be defined at all.
658657

659658

660659

0 commit comments

Comments
 (0)