]> granicus.if.org Git - python/commitdiff
Randall Hopper: Add fpectl functionality patch for FreeBSD.
authorGuido van Rossum <guido@python.org>
Tue, 19 Sep 2000 13:35:40 +0000 (13:35 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 19 Sep 2000 13:35:40 +0000 (13:35 +0000)
Modules/fpectlmodule.c

index 039deb4dc46c2ad8accb8f716cabbcb48bc922e6..59d2b72bb129f8672545738768f0ab34ecbcc834 100644 (file)
@@ -68,6 +68,10 @@ extern "C" {
 #include "Python.h"
 #include <signal.h>
 
+#if defined(__FreeBSD__)
+#  include <ieeefp.h>
+#endif
+
 #ifndef WANT_SIGFPE_HANDLER
 /* Define locally if they are not defined in Python.  This gives only
  * the limited control to induce a core dump in case of an exception.
@@ -178,6 +182,12 @@ static void fpe_reset(Sigfunc *handler)
 #endif
     signal(SIGFPE, handler);
 
+/*-- FreeBSD ----------------------------------------------------------------*/
+#elif defined(__FreeBSD__)
+    fpresetsticky( fpgetsticky() );
+    fpsetmask( FP_X_INV | FP_X_DZ | FP_X_OFL );
+    signal( SIGFPE, handler );
+
 /*-- Linux ----------------------------------------------------------------*/
 #elif defined(linux)
 #ifdef __GLIBC__
@@ -212,7 +222,12 @@ static void fpe_reset(Sigfunc *handler)
 
 static PyObject *turnoff_sigfpe(PyObject *self,PyObject *args)
 {
+#ifdef __FreeBSD__
+    fpresetsticky( fpgetsticky() );
+    fpsetmask( 0 );
+#else
     fputs("Operation not implemented\n", stderr);
+#endif
     Py_INCREF (Py_None);
     return Py_None;
 }