Skip to content

Commit 8474c9c

Browse files
authored
Merge pull request #117 from sagemath/use_cysignals_hook
Use cysignals hook
2 parents 002739f + e107553 commit 8474c9c

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

.github/workflows/main.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ jobs:
3535
bash -x .travis-install-pari.sh
3636
- name: Local build
3737
run: |
38-
pip install sphinx cython cysignals
38+
pip install sphinx cython
39+
pip install git+http://github.com/sagemath/cysignals.git@general_signal_hook#egg=cysignals
3940
make build
4041
make install
4142
make check

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.3
1+
2.2.0a0

cypari2/__init__.py

+3
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

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
global PARI_SIGINT_block
20+
PARI_SIGINT_block = 0
21+
22+
cdef void custom_set_pending_signal(int sig):
23+
global PARI_SIGINT_pending
24+
PARI_SIGINT_pending = sig
25+
26+
def init_custom_block():
27+
add_custom_signals(&custom_signal_is_blocked,
28+
&custom_signal_unblock,
29+
&custom_set_pending_signal)

0 commit comments

Comments
 (0)