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

Skip to content

Commit 4622e14

Browse files
committed
Randall Hopper: Add fpectl functionality patch for FreeBSD.
1 parent 6df27f8 commit 4622e14

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Modules/fpectlmodule.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff 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

213223
static 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
}

0 commit comments

Comments
 (0)