Skip to content

Commit

Permalink
call cysignals hook
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Kliem authored and videlec committed Nov 11, 2022
1 parent c22cbe9 commit bd9cc8f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
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()
27 changes: 27 additions & 0 deletions cypari2/custom_block.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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():
PARI_SIGINT_block = 0

cdef void custom_set_pending_signal(int sig):
PARI_SIGINT_pending = sig

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

0 comments on commit bd9cc8f

Please sign in to comment.