Skip to content

Commit 1ff620d

Browse files
Jonathan KliemMatthias Koeppe
authored andcommitted
call cysignals hook
1 parent 8bf626a commit 1ff620d

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

cypari2/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
from .pari_instance import Pari
22
from .handle_error import PariError
33
from .gen import Gen
4+
from .custom_block import init_custom_block
5+
6+
init_custom_block()

cypari2/custom_block.pyx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# distutils: libraries = gmp pari
2+
3+
#*****************************************************************************
4+
# Distributed under the terms of the GNU General Public License (GPL)
5+
# as published by the Free Software Foundation; either version 2 of
6+
# the License, or (at your option) any later version.
7+
# http://www.gnu.org/licenses/
8+
#*****************************************************************************
9+
10+
from cysignals.signals cimport add_custom_signals
11+
12+
cdef extern from "pari/pari.h":
13+
int PARI_SIGINT_block, PARI_SIGINT_pending
14+
15+
cdef int custom_signal_is_blocked():
16+
return PARI_SIGINT_block
17+
18+
cdef void custom_signal_unblock():
19+
PARI_SIGINT_block = 0
20+
21+
cdef void custom_set_pending_signal(int sig):
22+
PARI_SIGINT_pending = sig
23+
24+
def init_custom_block():
25+
add_custom_signals(&custom_signal_is_blocked,
26+
&custom_signal_unblock,
27+
&custom_set_pending_signal)

0 commit comments

Comments
 (0)