Skip to content

Commit 2dff792

Browse files
author
gvanrossum
committed
Use PyOS_setsig() instead of signal(). Also remove redundant spaces
from the FreeBSD code. git-svn-id: http://svn.python.org/projects/python/trunk@17574 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 028dedb commit 2dff792

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

Modules/fpectlmodule.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static void fpe_reset(Sigfunc *handler)
130130
(user_routine *)0,
131131
_ABORT_ON_ERROR,
132132
NULL);
133-
signal(SIGFPE, handler);
133+
PyOS_setsig(SIGFPE, handler);
134134

135135
/*-- SunOS and Solaris ----------------------------------------------------*/
136136
#elif defined(sun)
@@ -144,7 +144,7 @@ static void fpe_reset(Sigfunc *handler)
144144
(void) nonstandard_arithmetic();
145145
(void) ieee_flags("clearall",mode,in,&out);
146146
(void) ieee_handler("set","common",(sigfpe_handler_type)handler);
147-
signal(SIGFPE, handler);
147+
PyOS_setsig(SIGFPE, handler);
148148

149149
/*-- HPUX -----------------------------------------------------------------*/
150150
#elif defined(__hppa) || defined(hppa)
@@ -153,15 +153,15 @@ static void fpe_reset(Sigfunc *handler)
153153
/* ld -b -o fpectlmodule.sl fpectlmodule.o -lm */
154154
#include <math.h>
155155
fpsetdefaults();
156-
signal(SIGFPE, handler);
156+
PyOS_setsig(SIGFPE, handler);
157157

158158
/*-- IBM AIX --------------------------------------------------------------*/
159159
#elif defined(__AIX) || defined(_AIX)
160160
/* References: fp_trap, fp_enable man pages */
161161
#include <fptrap.h>
162162
fp_trap(FP_TRAP_SYNC);
163163
fp_enable(TRP_INVALID | TRP_DIV_BY_ZERO | TRP_OVERFLOW);
164-
signal(SIGFPE, handler);
164+
PyOS_setsig(SIGFPE, handler);
165165

166166
/*-- DEC ALPHA OSF --------------------------------------------------------*/
167167
#elif defined(__alpha) && defined(__osf__)
@@ -172,21 +172,21 @@ static void fpe_reset(Sigfunc *handler)
172172
unsigned long fp_control =
173173
IEEE_TRAP_ENABLE_INV | IEEE_TRAP_ENABLE_DZE | IEEE_TRAP_ENABLE_OVF;
174174
ieee_set_fp_control(fp_control);
175-
signal(SIGFPE, handler);
175+
PyOS_setsig(SIGFPE, handler);
176176

177177
/*-- Cray Unicos ----------------------------------------------------------*/
178178
#elif defined(cray)
179179
/* UNICOS delivers SIGFPE by default, but no matherr */
180180
#ifdef HAS_LIBMSET
181181
libmset(-1);
182182
#endif
183-
signal(SIGFPE, handler);
183+
PyOS_setsig(SIGFPE, handler);
184184

185185
/*-- FreeBSD ----------------------------------------------------------------*/
186186
#elif defined(__FreeBSD__)
187-
fpresetsticky( fpgetsticky() );
188-
fpsetmask( FP_X_INV | FP_X_DZ | FP_X_OFL );
189-
signal( SIGFPE, handler );
187+
fpresetsticky(fpgetsticky());
188+
fpsetmask(FP_X_INV | FP_X_DZ | FP_X_OFL);
189+
PyOS_setsig(SIGFPE, handler);
190190

191191
/*-- Linux ----------------------------------------------------------------*/
192192
#elif defined(linux)
@@ -196,13 +196,13 @@ static void fpe_reset(Sigfunc *handler)
196196
#include <i386/fpu_control.h>
197197
#endif
198198
__setfpucw(0x1372);
199-
signal(SIGFPE, handler);
199+
PyOS_setsig(SIGFPE, handler);
200200

201201
/*-- NeXT -----------------------------------------------------------------*/
202202
#elif defined(NeXT) && defined(m68k) && defined(__GNUC__)
203203
/* NeXT needs explicit csr set to generate SIGFPE */
204204
asm("fmovel #0x1400,fpcr"); /* set OVFL and ZD bits */
205-
signal(SIGFPE, handler);
205+
PyOS_setsig(SIGFPE, handler);
206206

207207
/*-- Microsoft Windows, NT ------------------------------------------------*/
208208
#elif defined(_MSC_VER)
@@ -211,7 +211,7 @@ static void fpe_reset(Sigfunc *handler)
211211
#include <float.h>
212212
unsigned int cw = _EM_INVALID | _EM_ZERODIVIDE | _EM_OVERFLOW;
213213
(void)_controlfp(0, cw);
214-
signal(SIGFPE, handler);
214+
PyOS_setsig(SIGFPE, handler);
215215

216216
/*-- Give Up --------------------------------------------------------------*/
217217
#else
@@ -223,12 +223,12 @@ static void fpe_reset(Sigfunc *handler)
223223
static PyObject *turnoff_sigfpe(PyObject *self,PyObject *args)
224224
{
225225
#ifdef __FreeBSD__
226-
fpresetsticky( fpgetsticky() );
227-
fpsetmask( 0 );
226+
fpresetsticky(fpgetsticky());
227+
fpsetmask(0);
228228
#else
229229
fputs("Operation not implemented\n", stderr);
230230
#endif
231-
Py_INCREF (Py_None);
231+
Py_INCREF(Py_None);
232232
return Py_None;
233233
}
234234

0 commit comments

Comments
 (0)