summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2007-09-21 16:54:38 +0000
committerTravis Oliphant <oliphant@enthought.com>2007-09-21 16:54:38 +0000
commita64b5f0ee524a52cdb65fa8ae3dce1a18b58b589 (patch)
tree8a914fb10873b96e552f93cc8940726cb4a60837
parent393718f36954c375fba8d9b52b35ee0b0b85173c (diff)
downloadnumpy-a64b5f0ee524a52cdb65fa8ae3dce1a18b58b589.tar.gz
Add a fix for ticket #582 by adding a framework for clearing the floating point exception registers for extension modules compiled with different compilers.
-rw-r--r--numpy/core/code_generators/generate_ufunc_api.py8
-rw-r--r--numpy/core/include/numpy/ufuncobject.h10
2 files changed, 14 insertions, 4 deletions
diff --git a/numpy/core/code_generators/generate_ufunc_api.py b/numpy/core/code_generators/generate_ufunc_api.py
index 052405892..96bb47cae 100644
--- a/numpy/core/code_generators/generate_ufunc_api.py
+++ b/numpy/core/code_generators/generate_ufunc_api.py
@@ -48,13 +48,13 @@ _import_umath(void)
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
diff --git a/numpy/core/include/numpy/ufuncobject.h b/numpy/core/include/numpy/ufuncobject.h
index 9906096e6..36da30360 100644
--- a/numpy/core/include/numpy/ufuncobject.h
+++ b/numpy/core/include/numpy/ufuncobject.h
@@ -245,6 +245,11 @@ typedef struct _loop1d_info {
#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,6 +363,11 @@ static void generate_overflow_error(void) {
}
#endif
+ /* Make sure it gets defined if it isn't already */
+#ifndef UFUNC_NOFPE
+#define UFUNC_NOFPE
+#endif
+
#ifdef __cplusplus
}