diff options
-rw-r--r-- | numpy/core/code_generators/multiarray_api_order.txt | 2 | ||||
-rw-r--r-- | numpy/core/include/numpy/ndarrayobject.h | 1 | ||||
-rw-r--r-- | numpy/core/include/numpy/npy_interrupt.h | 27 | ||||
-rw-r--r-- | numpy/core/src/multiarraymodule.c | 38 |
4 files changed, 50 insertions, 18 deletions
diff --git a/numpy/core/code_generators/multiarray_api_order.txt b/numpy/core/code_generators/multiarray_api_order.txt index c6cf0c7f0..324b0c886 100644 --- a/numpy/core/code_generators/multiarray_api_order.txt +++ b/numpy/core/code_generators/multiarray_api_order.txt @@ -75,3 +75,5 @@ PyArray_IntTupleFromIntp PyArray_TypeNumFromName PyArray_ClipmodeConverter PyArray_OutputConverter +_PyArray_SigintHandler +_PyArray_GetSigintBuf
\ No newline at end of file diff --git a/numpy/core/include/numpy/ndarrayobject.h b/numpy/core/include/numpy/ndarrayobject.h index 4d5719949..31452f82a 100644 --- a/numpy/core/include/numpy/ndarrayobject.h +++ b/numpy/core/include/numpy/ndarrayobject.h @@ -1392,7 +1392,6 @@ typedef struct { They are available as import_array() */ - #include "__multiarray_api.h" diff --git a/numpy/core/include/numpy/npy_interrupt.h b/numpy/core/include/numpy/npy_interrupt.h index 072d8fb62..0d4bf4ce8 100644 --- a/numpy/core/include/numpy/npy_interrupt.h +++ b/numpy/core/include/numpy/npy_interrupt.h @@ -71,7 +71,9 @@ Interrupt handling does not work well with threads. */ -/* Add signal handling macros */ +/* Add signal handling macros + Make the global variable and signal handler part of the C-API +*/ #ifndef NPY_INTERRUPT_H #define NPY_INTERRUPT_H @@ -94,28 +96,19 @@ Interrupt handling does not work well with threads. #define SIGJMP_BUF sigjmp_buf #endif - -SIGJMP_BUF _NPY_SIGINT_BUF; - -static void -_npy_sighandler(int signum) -{ - PyOS_setsig(signum, SIG_IGN); - SIGLONGJMP(_NPY_SIGINT_BUF, signum); -} - # define NPY_SIGINT_ON { \ - PyOS_sighandler_t _npy_sig_save; \ - _npy_sig_save = PyOS_setsig(SIGINT, _npy_sighandler); \ - if (SIGSETJMP(_NPY_SIGINT_BUF, 1) == 0) { \ - + PyOS_sighandler_t _npy_sig_save; \ + _npy_sig_save = PyOS_setsig(SIGINT, _PyArray_SigintHandler); \ + if (SIGSETJMP(*((SIGJMP_BUF *)_PyArray_GetSigintBuf()), \ + 1) == 0) { \ + # define NPY_SIGINT_OFF } \ PyOS_setsig(SIGINT, _npy_sig_save); \ } - + #else /* NPY_NO_SIGNAL */ - + # define NPY_SIGINT_ON # define NPY_SIGINT_OFF diff --git a/numpy/core/src/multiarraymodule.c b/numpy/core/src/multiarraymodule.c index c64af03af..87189cd3a 100644 --- a/numpy/core/src/multiarraymodule.c +++ b/numpy/core/src/multiarraymodule.c @@ -6430,6 +6430,44 @@ compare_chararrays(PyObject *dummy, PyObject *args, PyObject *kwds) } +#ifndef NPY_NO_SIGNAL + +SIGJMP_BUF _NPY_SIGINT_BUF; + +/*MULTIARRAY_API +*/ +static void +_PyArray_SigintHandler(int signum) +{ + PyOS_setsig(signum, SIG_IGN); + SIGLONGJMP(_NPY_SIGINT_BUF, signum); +} + +/*MULTIARRAY_API +*/ +static void* +_PyArray_GetSigintBuf(void) +{ + return (void *)&_NPY_SIGINT_BUF; +} + +#else + +static void +_PyArray_SigintHandler(int signum) +{ + return; +} + +static void* +_PyArray_GetSigintBuf(void) +{ + return NULL; +} + +#endif + + static PyObject * test_interrupt(PyObject *self, PyObject *args) { |