[Numpy-svn] r4071 - in trunk/numpy/core: code_generators include/numpy

numpy-svn@scip... numpy-svn@scip...
Fri Sep 21 11:54:59 CDT 2007


Author: oliphant
Date: 2007-09-21 11:54:38 -0500 (Fri, 21 Sep 2007)
New Revision: 4071

Modified:
   trunk/numpy/core/code_generators/generate_ufunc_api.py
   trunk/numpy/core/include/numpy/ufuncobject.h
Log:
Add a fix for ticket #582 by adding a framework for clearing the floating point exception registers for extension modules compiled with different compilers.

Modified: trunk/numpy/core/code_generators/generate_ufunc_api.py
===================================================================
--- trunk/numpy/core/code_generators/generate_ufunc_api.py	2007-09-21 07:46:01 UTC (rev 4070)
+++ trunk/numpy/core/code_generators/generate_ufunc_api.py	2007-09-21 16:54:38 UTC (rev 4071)
@@ -48,13 +48,13 @@
   return 0;
 }
 
-#define import_umath() { if (_import_umath() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.umath failed to import"); return; }}
+#define import_umath() { UFUNC_NOFPE if (_import_umath() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.umath failed to import"); return; }}
 
-#define import_umath1(ret) { if (_import_umath() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.umath failed to import"); return ret; }}
+#define import_umath1(ret) { UFUNC_NOFPE if (_import_umath() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.umath failed to import"); return ret; }}
 
-#define import_umath2(msg, ret) { if (_import_umath() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, msg); return ret; }}
+#define import_umath2(msg, ret) { UFUNC_NOFPE if (_import_umath() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, msg); return ret; }}
 
-#define import_ufunc() { if (_import_umath() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.umath failed to import"); }}
+#define import_ufunc() { UFUNC_NOFPE if (_import_umath() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.umath failed to import"); }}
 
 
 #endif

Modified: trunk/numpy/core/include/numpy/ufuncobject.h
===================================================================
--- trunk/numpy/core/include/numpy/ufuncobject.h	2007-09-21 07:46:01 UTC (rev 4070)
+++ trunk/numpy/core/include/numpy/ufuncobject.h	2007-09-21 16:54:38 UTC (rev 4071)
@@ -245,6 +245,11 @@
 
 #include <float.h>
 
+  /* Clear the floating point exception default of Borland C++ */
+#if defined(__BORLANDC__)
+#define UFUNC_NOFPE _control87(MCW_EM, MCW_EM);
+#endif
+
 #define UFUNC_CHECK_STATUS(ret) {		 \
 	int fpstatus = (int) _clearfp();			\
 									\
@@ -358,7 +363,12 @@
 }
 #endif
 
+  /* Make sure it gets defined if it isn't already */
+#ifndef UFUNC_NOFPE
+#define UFUNC_NOFPE
+#endif
 
+
 #ifdef __cplusplus
 }
 #endif



More information about the Numpy-svn mailing list