Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cysignals hook #117

Merged
merged 5 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jobs:
bash -x .travis-install-pari.sh
- name: Local build
run: |
pip install sphinx cython cysignals
pip install sphinx cython
pip install git+http://github.com/sagemath/cysignals.git@general_signal_hook#egg=cysignals
make build
make install
make check
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.3
2.2.0a0
3 changes: 3 additions & 0 deletions cypari2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from .pari_instance import Pari
from .handle_error import PariError
from .gen import Gen
from .custom_block import init_custom_block

init_custom_block()
29 changes: 29 additions & 0 deletions cypari2/custom_block.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# distutils: libraries = gmp pari

#*****************************************************************************
# Distributed under the terms of the GNU General Public License (GPL)
# as published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
# http://www.gnu.org/licenses/
#*****************************************************************************

from cysignals.signals cimport add_custom_signals

cdef extern from "pari/pari.h":
int PARI_SIGINT_block, PARI_SIGINT_pending

cdef int custom_signal_is_blocked():
return PARI_SIGINT_block

cdef void custom_signal_unblock():
global PARI_SIGINT_block
PARI_SIGINT_block = 0

cdef void custom_set_pending_signal(int sig):
global PARI_SIGINT_pending
PARI_SIGINT_pending = sig

def init_custom_block():
add_custom_signals(&custom_signal_is_blocked,
&custom_signal_unblock,
&custom_set_pending_signal)