Commit 167ff177 authored by Guido van Rossum's avatar Guido van Rossum

Use PyOS_setsig() instead of signal(). Also remove redundant spaces

from the FreeBSD code.
parent ccf3075e
...@@ -130,7 +130,7 @@ static void fpe_reset(Sigfunc *handler) ...@@ -130,7 +130,7 @@ static void fpe_reset(Sigfunc *handler)
(user_routine *)0, (user_routine *)0,
_ABORT_ON_ERROR, _ABORT_ON_ERROR,
NULL); NULL);
signal(SIGFPE, handler); PyOS_setsig(SIGFPE, handler);
/*-- SunOS and Solaris ----------------------------------------------------*/ /*-- SunOS and Solaris ----------------------------------------------------*/
#elif defined(sun) #elif defined(sun)
...@@ -144,7 +144,7 @@ static void fpe_reset(Sigfunc *handler) ...@@ -144,7 +144,7 @@ static void fpe_reset(Sigfunc *handler)
(void) nonstandard_arithmetic(); (void) nonstandard_arithmetic();
(void) ieee_flags("clearall",mode,in,&out); (void) ieee_flags("clearall",mode,in,&out);
(void) ieee_handler("set","common",(sigfpe_handler_type)handler); (void) ieee_handler("set","common",(sigfpe_handler_type)handler);
signal(SIGFPE, handler); PyOS_setsig(SIGFPE, handler);
/*-- HPUX -----------------------------------------------------------------*/ /*-- HPUX -----------------------------------------------------------------*/
#elif defined(__hppa) || defined(hppa) #elif defined(__hppa) || defined(hppa)
...@@ -153,7 +153,7 @@ static void fpe_reset(Sigfunc *handler) ...@@ -153,7 +153,7 @@ static void fpe_reset(Sigfunc *handler)
/* ld -b -o fpectlmodule.sl fpectlmodule.o -lm */ /* ld -b -o fpectlmodule.sl fpectlmodule.o -lm */
#include <math.h> #include <math.h>
fpsetdefaults(); fpsetdefaults();
signal(SIGFPE, handler); PyOS_setsig(SIGFPE, handler);
/*-- IBM AIX --------------------------------------------------------------*/ /*-- IBM AIX --------------------------------------------------------------*/
#elif defined(__AIX) || defined(_AIX) #elif defined(__AIX) || defined(_AIX)
...@@ -161,7 +161,7 @@ static void fpe_reset(Sigfunc *handler) ...@@ -161,7 +161,7 @@ static void fpe_reset(Sigfunc *handler)
#include <fptrap.h> #include <fptrap.h>
fp_trap(FP_TRAP_SYNC); fp_trap(FP_TRAP_SYNC);
fp_enable(TRP_INVALID | TRP_DIV_BY_ZERO | TRP_OVERFLOW); fp_enable(TRP_INVALID | TRP_DIV_BY_ZERO | TRP_OVERFLOW);
signal(SIGFPE, handler); PyOS_setsig(SIGFPE, handler);
/*-- DEC ALPHA OSF --------------------------------------------------------*/ /*-- DEC ALPHA OSF --------------------------------------------------------*/
#elif defined(__alpha) && defined(__osf__) #elif defined(__alpha) && defined(__osf__)
...@@ -172,7 +172,7 @@ static void fpe_reset(Sigfunc *handler) ...@@ -172,7 +172,7 @@ static void fpe_reset(Sigfunc *handler)
unsigned long fp_control = unsigned long fp_control =
IEEE_TRAP_ENABLE_INV | IEEE_TRAP_ENABLE_DZE | IEEE_TRAP_ENABLE_OVF; IEEE_TRAP_ENABLE_INV | IEEE_TRAP_ENABLE_DZE | IEEE_TRAP_ENABLE_OVF;
ieee_set_fp_control(fp_control); ieee_set_fp_control(fp_control);
signal(SIGFPE, handler); PyOS_setsig(SIGFPE, handler);
/*-- Cray Unicos ----------------------------------------------------------*/ /*-- Cray Unicos ----------------------------------------------------------*/
#elif defined(cray) #elif defined(cray)
...@@ -180,13 +180,13 @@ static void fpe_reset(Sigfunc *handler) ...@@ -180,13 +180,13 @@ static void fpe_reset(Sigfunc *handler)
#ifdef HAS_LIBMSET #ifdef HAS_LIBMSET
libmset(-1); libmset(-1);
#endif #endif
signal(SIGFPE, handler); PyOS_setsig(SIGFPE, handler);
/*-- FreeBSD ----------------------------------------------------------------*/ /*-- FreeBSD ----------------------------------------------------------------*/
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
fpresetsticky( fpgetsticky() ); fpresetsticky(fpgetsticky());
fpsetmask( FP_X_INV | FP_X_DZ | FP_X_OFL ); fpsetmask(FP_X_INV | FP_X_DZ | FP_X_OFL);
signal( SIGFPE, handler ); PyOS_setsig(SIGFPE, handler);
/*-- Linux ----------------------------------------------------------------*/ /*-- Linux ----------------------------------------------------------------*/
#elif defined(linux) #elif defined(linux)
...@@ -196,13 +196,13 @@ static void fpe_reset(Sigfunc *handler) ...@@ -196,13 +196,13 @@ static void fpe_reset(Sigfunc *handler)
#include <i386/fpu_control.h> #include <i386/fpu_control.h>
#endif #endif
__setfpucw(0x1372); __setfpucw(0x1372);
signal(SIGFPE, handler); PyOS_setsig(SIGFPE, handler);
/*-- NeXT -----------------------------------------------------------------*/ /*-- NeXT -----------------------------------------------------------------*/
#elif defined(NeXT) && defined(m68k) && defined(__GNUC__) #elif defined(NeXT) && defined(m68k) && defined(__GNUC__)
/* NeXT needs explicit csr set to generate SIGFPE */ /* NeXT needs explicit csr set to generate SIGFPE */
asm("fmovel #0x1400,fpcr"); /* set OVFL and ZD bits */ asm("fmovel #0x1400,fpcr"); /* set OVFL and ZD bits */
signal(SIGFPE, handler); PyOS_setsig(SIGFPE, handler);
/*-- Microsoft Windows, NT ------------------------------------------------*/ /*-- Microsoft Windows, NT ------------------------------------------------*/
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
...@@ -211,7 +211,7 @@ static void fpe_reset(Sigfunc *handler) ...@@ -211,7 +211,7 @@ static void fpe_reset(Sigfunc *handler)
#include <float.h> #include <float.h>
unsigned int cw = _EM_INVALID | _EM_ZERODIVIDE | _EM_OVERFLOW; unsigned int cw = _EM_INVALID | _EM_ZERODIVIDE | _EM_OVERFLOW;
(void)_controlfp(0, cw); (void)_controlfp(0, cw);
signal(SIGFPE, handler); PyOS_setsig(SIGFPE, handler);
/*-- Give Up --------------------------------------------------------------*/ /*-- Give Up --------------------------------------------------------------*/
#else #else
...@@ -223,12 +223,12 @@ static void fpe_reset(Sigfunc *handler) ...@@ -223,12 +223,12 @@ static void fpe_reset(Sigfunc *handler)
static PyObject *turnoff_sigfpe(PyObject *self,PyObject *args) static PyObject *turnoff_sigfpe(PyObject *self,PyObject *args)
{ {
#ifdef __FreeBSD__ #ifdef __FreeBSD__
fpresetsticky( fpgetsticky() ); fpresetsticky(fpgetsticky());
fpsetmask( 0 ); fpsetmask(0);
#else #else
fputs("Operation not implemented\n", stderr); fputs("Operation not implemented\n", stderr);
#endif #endif
Py_INCREF (Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
......
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