File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -68,6 +68,10 @@ extern "C" {
6868#include "Python.h"
6969#include <signal.h>
7070
71+ #if defined(__FreeBSD__ )
72+ # include <ieeefp.h>
73+ #endif
74+
7175#ifndef WANT_SIGFPE_HANDLER
7276/* Define locally if they are not defined in Python. This gives only
7377 * the limited control to induce a core dump in case of an exception.
@@ -178,6 +182,12 @@ static void fpe_reset(Sigfunc *handler)
178182#endif
179183 signal (SIGFPE , handler );
180184
185+ /*-- FreeBSD ----------------------------------------------------------------*/
186+ #elif defined(__FreeBSD__ )
187+ fpresetsticky ( fpgetsticky () );
188+ fpsetmask ( FP_X_INV | FP_X_DZ | FP_X_OFL );
189+ signal ( SIGFPE , handler );
190+
181191/*-- Linux ----------------------------------------------------------------*/
182192#elif defined(linux )
183193#ifdef __GLIBC__
@@ -212,7 +222,12 @@ static void fpe_reset(Sigfunc *handler)
212222
213223static PyObject * turnoff_sigfpe (PyObject * self ,PyObject * args )
214224{
225+ #ifdef __FreeBSD__
226+ fpresetsticky ( fpgetsticky () );
227+ fpsetmask ( 0 );
228+ #else
215229 fputs ("Operation not implemented\n" , stderr );
230+ #endif
216231 Py_INCREF (Py_None );
217232 return Py_None ;
218233}
You can’t perform that action at this time.
0 commit comments