diff options
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/bscript | 4 | ||||
-rw-r--r-- | numpy/core/setup.py | 4 | ||||
-rw-r--r-- | numpy/core/src/multiarray/multiarraymodule_onefile.c | 1 | ||||
-rw-r--r-- | numpy/core/src/multiarray/python_xerbla.c | 51 |
4 files changed, 58 insertions, 2 deletions
diff --git a/numpy/core/bscript b/numpy/core/bscript index 5df5a3f8a..0f0f6816a 100644 --- a/numpy/core/bscript +++ b/numpy/core/bscript @@ -479,7 +479,9 @@ def pre_build(context): ] if bld.env.HAS_CBLAS: - sources.append(pjoin('src', 'multiarray', 'cblasfuncs.c')) + sources.extend([pjoin('src', 'multiarray', 'cblasfuncs.c'), + pjoin('src', 'multiarray', 'python_xerbla.c'), + ]) else: sources = extension.sources diff --git a/numpy/core/setup.py b/numpy/core/setup.py index a51eb690b..f178c4032 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -839,7 +839,9 @@ def configuration(parent_package='',top_path=None): blas_info = get_info('blas_opt', 0) if blas_info and ('HAVE_CBLAS', None) in blas_info.get('define_macros', []): extra_info = blas_info - multiarray_src.append(join('src', 'multiarray', 'cblasfuncs.c')) + multiarray_src.extend([join('src', 'multiarray', 'cblasfuncs.c'), + join('src', 'multiarray', 'python_xerbla.c'), + ]) else: extra_info = {} diff --git a/numpy/core/src/multiarray/multiarraymodule_onefile.c b/numpy/core/src/multiarray/multiarraymodule_onefile.c index 04fef61ce..7adfdf9da 100644 --- a/numpy/core/src/multiarray/multiarraymodule_onefile.c +++ b/numpy/core/src/multiarray/multiarraymodule_onefile.c @@ -56,5 +56,6 @@ #include "multiarraymodule.c" #if defined(HAVE_CBLAS) +#include "python_xerbla.c" #include "cblasfuncs.c" #endif diff --git a/numpy/core/src/multiarray/python_xerbla.c b/numpy/core/src/multiarray/python_xerbla.c new file mode 100644 index 000000000..bdf0b9058 --- /dev/null +++ b/numpy/core/src/multiarray/python_xerbla.c @@ -0,0 +1,51 @@ +#include "Python.h" + +/* + * From f2c.h, this should be safe unless fortran is set to use 64 + * bit integers. We don't seem to have any good way to detect that. + */ +typedef int integer; + +/* + From the original manpage: + -------------------------- + XERBLA is an error handler for the LAPACK routines. + It is called by an LAPACK routine if an input parameter has an invalid value. + A message is printed and execution stops. + + Instead of printing a message and stopping the execution, a + ValueError is raised with the message. + + Parameters: + ----------- + srname: Subroutine name to use in error message, maximum six characters. + Spaces at the end are skipped. + info: Number of the invalid parameter. +*/ + +int xerbla_(char *srname, integer *info) +{ + static const char format[] = "On entry to %.*s" \ + " parameter number %d had an illegal value"; + char buf[sizeof(format) + 6 + 4]; /* 6 for name, 4 for param. num. */ + + int len = 0; /* length of subroutine name*/ +#ifdef WITH_THREAD + PyGILState_STATE save; +#endif + + while( len<6 && srname[len]!='\0' ) + len++; + while( len && srname[len-1]==' ' ) + len--; +#ifdef WITH_THREAD + save = PyGILState_Ensure(); +#endif + PyOS_snprintf(buf, sizeof(buf), format, len, srname, *info); + PyErr_SetString(PyExc_ValueError, buf); +#ifdef WITH_THREAD + PyGILState_Release(save); +#endif + + return 0; +} |