diff options
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/src/multiarray/multiarray_tests.c.src | 34 | ||||
-rw-r--r-- | numpy/core/src/private/npy_config.h | 9 |
2 files changed, 43 insertions, 0 deletions
diff --git a/numpy/core/src/multiarray/multiarray_tests.c.src b/numpy/core/src/multiarray/multiarray_tests.c.src index f5be52d74..657c4064e 100644 --- a/numpy/core/src/multiarray/multiarray_tests.c.src +++ b/numpy/core/src/multiarray/multiarray_tests.c.src @@ -1560,6 +1560,37 @@ extint_ceildiv_128_64(PyObject *NPY_UNUSED(self), PyObject *args) { } +static char get_fpu_mode_doc[] = ( + "get_fpu_mode()\n" + "\n" + "Get the current FPU control word, in a platform-dependent format.\n" + "Returns None if not implemented on current platform."); + +static PyObject * +get_fpu_mode(PyObject *NPY_UNUSED(self), PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) { + return NULL; + } + +#if defined(_MSC_VER) + { + unsigned int result = 0; + result = _controlfp(0, 0); + return PyLong_FromLongLong(result); + } +#elif defined(__GNUC__) && (defined(__x86_64__) || defined(__i386__)) + { + unsigned short cw = 0; + __asm__("fstcw %w0" : "=m" (cw)); + return PyLong_FromLongLong(cw); + } +#else + return Py_RETURN_NONE; +#endif +} + + static PyMethodDef Multiarray_TestsMethods[] = { {"IsPythonScalar", IsPythonScalar, @@ -1650,6 +1681,9 @@ static PyMethodDef Multiarray_TestsMethods[] = { {"extint_ceildiv_128_64", extint_ceildiv_128_64, METH_VARARGS, NULL}, + {"get_fpu_mode", + get_fpu_mode, + METH_VARARGS, get_fpu_mode_doc}, {NULL, NULL, 0, NULL} /* Sentinel */ }; diff --git a/numpy/core/src/private/npy_config.h b/numpy/core/src/private/npy_config.h index b8e18e961..1e2151447 100644 --- a/numpy/core/src/private/npy_config.h +++ b/numpy/core/src/private/npy_config.h @@ -62,6 +62,15 @@ #endif +/* MSVC _hypot messes with fp precision mode on 32-bit, see gh-9567 */ +#if defined(_MSC_VER) && (_MSC_VER >= 1900) && !defined(_WIN64) + +#undef HAVE_HYPOT +#undef HAVE_HYPOTF +#undef HAVE_HYPOTL + +#endif + /* Intel C for Windows uses POW for 64 bits longdouble*/ #if defined(_MSC_VER) && defined(__INTEL_COMPILER) |