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

numpy-svn at scipy.org numpy-svn at scipy.org
Thu Aug 24 18:39:29 CDT 2006


Author: oliphant
Date: 2006-08-24 18:39:18 -0500 (Thu, 24 Aug 2006)
New Revision: 3064

Modified:
   trunk/numpy/core/code_generators/multiarray_api_order.txt
   trunk/numpy/core/include/numpy/ndarrayobject.h
   trunk/numpy/core/include/numpy/npy_interrupt.h
   trunk/numpy/core/src/multiarraymodule.c
Log:
Move signal handler and global variable getter to C-API

Modified: trunk/numpy/core/code_generators/multiarray_api_order.txt
===================================================================
--- trunk/numpy/core/code_generators/multiarray_api_order.txt	2006-08-24 22:50:26 UTC (rev 3063)
+++ trunk/numpy/core/code_generators/multiarray_api_order.txt	2006-08-24 23:39:18 UTC (rev 3064)
@@ -75,3 +75,5 @@
 PyArray_TypeNumFromName
 PyArray_ClipmodeConverter
 PyArray_OutputConverter
+_PyArray_SigintHandler
+_PyArray_GetSigintBuf
\ No newline at end of file

Modified: trunk/numpy/core/include/numpy/ndarrayobject.h
===================================================================
--- trunk/numpy/core/include/numpy/ndarrayobject.h	2006-08-24 22:50:26 UTC (rev 3063)
+++ trunk/numpy/core/include/numpy/ndarrayobject.h	2006-08-24 23:39:18 UTC (rev 3064)
@@ -1392,7 +1392,6 @@
    They are available as import_array()
 */
 
-
 #include "__multiarray_api.h"
 
 

Modified: trunk/numpy/core/include/numpy/npy_interrupt.h
===================================================================
--- trunk/numpy/core/include/numpy/npy_interrupt.h	2006-08-24 22:50:26 UTC (rev 3063)
+++ trunk/numpy/core/include/numpy/npy_interrupt.h	2006-08-24 23:39:18 UTC (rev 3064)
@@ -71,7 +71,9 @@
 
 */
 
-/* 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 @@
 #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
 

Modified: trunk/numpy/core/src/multiarraymodule.c
===================================================================
--- trunk/numpy/core/src/multiarraymodule.c	2006-08-24 22:50:26 UTC (rev 3063)
+++ trunk/numpy/core/src/multiarraymodule.c	2006-08-24 23:39:18 UTC (rev 3064)
@@ -6430,6 +6430,44 @@
 }
 
 
+#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)
 {



More information about the Numpy-svn mailing list