Skip to content

Commit

Permalink
Merge pull request #187 from dimpase/more_robust_docbuild
Browse files Browse the repository at this point in the history
make docbuild more robust, add noexcept's
  • Loading branch information
dimpase authored Oct 4, 2023
2 parents 820d36a + 0ebd0a7 commit 81903a4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dist: configure
chmod -R go+rX-w .
umask 0022 && $(PYTHON) setup.py sdist --formats=gztar

doc:
doc: install
cd docs && $(MAKE) html


Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXBUILD = python3 $(shell which sphinx-build)
PAPER =
BUILDDIR = build

Expand Down
10 changes: 5 additions & 5 deletions src/cysignals/memory.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,35 @@ cdef extern from *:
int unlikely(int) nogil # Defined by Cython


cdef inline void* sig_malloc "sig_malloc"(size_t n) nogil:
cdef inline void* sig_malloc "sig_malloc"(size_t n) noexcept nogil:
sig_block()
cdef void* ret = malloc(n)
sig_unblock()
return ret


cdef inline void* sig_realloc "sig_realloc"(void* ptr, size_t size) nogil:
cdef inline void* sig_realloc "sig_realloc"(void* ptr, size_t size) noexcept nogil:
sig_block()
cdef void* ret = realloc(ptr, size)
sig_unblock()
return ret


cdef inline void* sig_calloc "sig_calloc"(size_t nmemb, size_t size) nogil:
cdef inline void* sig_calloc "sig_calloc"(size_t nmemb, size_t size) noexcept nogil:
sig_block()
cdef void* ret = calloc(nmemb, size)
sig_unblock()
return ret


cdef inline void sig_free "sig_free"(void* ptr) nogil:
cdef inline void sig_free "sig_free"(void* ptr) noexcept nogil:
sig_block()
free(ptr)
sig_unblock()


@cython.cdivision(True)
cdef inline size_t mul_overflowcheck(size_t a, size_t b) nogil:
cdef inline size_t mul_overflowcheck(size_t a, size_t b) noexcept nogil:
"""
Return a*b, checking for overflow. Assume that a > 0.
If overflow occurs, return <size_t>(-1).
Expand Down
20 changes: 10 additions & 10 deletions src/cysignals/signals.pxd.in
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ cdef extern from "macros.h" nogil:
int sig_check_no_except "sig_check"()

# This function adds custom block/unblock/pending.
cdef int add_custom_signals(int (*custom_signal_is_blocked)(),
void (*custom_signal_unblock)(),
void (*custom_set_pending_signal)(int)) except -1
cdef int add_custom_signals(int (*custom_signal_is_blocked)() noexcept,
void (*custom_signal_unblock)() noexcept,
void (*custom_set_pending_signal)(int) noexcept) except -1

# This function does nothing, but it is declared cdef except *, so it
# can be used to make Cython check whether there is a pending exception
Expand All @@ -62,9 +62,9 @@ cdef inline void cython_check_exception() except * nogil:
pass


cdef void verify_exc_value()
cdef void verify_exc_value() noexcept

cdef inline PyObject* sig_occurred():
cdef inline PyObject* sig_occurred() noexcept:
"""
Borrowed reference to the exception which is currently being
propagated from cysignals. If there is no exception or if we
Expand All @@ -88,13 +88,13 @@ cdef inline PyObject* sig_occurred():
# these available to every Cython module cimporting this file.
cdef nogil:
cysigs_t cysigs "cysigs"
void _sig_on_interrupt_received "_sig_on_interrupt_received"()
void _sig_on_recover "_sig_on_recover"()
void _sig_off_warning "_sig_off_warning"(const char*, int)
void print_backtrace "print_backtrace"()
void _sig_on_interrupt_received "_sig_on_interrupt_received"() noexcept
void _sig_on_recover "_sig_on_recover"() noexcept
void _sig_off_warning "_sig_off_warning"(const char*, int) noexcept
void print_backtrace "print_backtrace"() noexcept


cdef inline void __generate_declarations():
cdef inline void __generate_declarations() noexcept:
cysigs
_sig_on_interrupt_received
_sig_on_recover
Expand Down
8 changes: 4 additions & 4 deletions src/cysignals/signals.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def _pari_version():
return v.decode('ascii')


cdef int add_custom_signals(int (*custom_signal_is_blocked)(),
void (*custom_signal_unblock)(),
void (*custom_set_pending_signal)(int)) except -1:
cdef int add_custom_signals(int (*custom_signal_is_blocked)() noexcept,
void (*custom_signal_unblock)() noexcept,
void (*custom_set_pending_signal)(int) noexcept) except -1:
"""
Add an external block/unblock/pending to cysignals.
Expand Down Expand Up @@ -341,7 +341,7 @@ def python_check_interrupt(sig, frame):
sig_check()


cdef void verify_exc_value():
cdef void verify_exc_value() noexcept:
"""
Check that ``cysigs.exc_value`` is still the exception being raised.
Clear ``cysigs.exc_value`` if not.
Expand Down
10 changes: 5 additions & 5 deletions src/cysignals/tests.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ set_debug_level(0)
########################################################################
# C helper functions #
########################################################################
cdef void infinite_loop() nogil:
cdef void infinite_loop() noexcept nogil:
# Ensure that the compiler cannot "optimize away" this infinite
# loop, see https://bugs.llvm.org/show_bug.cgi?id=965
cdef volatile_int x = 0
while x == 0:
pass

cdef void infinite_malloc_loop() nogil:
cdef void infinite_malloc_loop() noexcept nogil:
cdef size_t s = 1
while True:
sig_free(sig_malloc(s))
Expand All @@ -106,12 +106,12 @@ cdef void infinite_malloc_loop() nogil:
# Dereference a NULL pointer on purpose. This signals a SIGSEGV on most
# systems, but on older Mac OS X and possibly other systems, this
# signals a SIGBUS instead. In any case, this should give some signal.
cdef void dereference_null_pointer() nogil:
cdef void dereference_null_pointer() noexcept nogil:
cdef volatile_int* ptr = <volatile_int*>(0)
ptr[0] += 1


cdef int stack_overflow(volatile_int* x=NULL) nogil:
cdef int stack_overflow(volatile_int* x=NULL) noexcept nogil:
cdef volatile_int a = 0
if x is not NULL:
a = x[0]
Expand Down Expand Up @@ -258,7 +258,7 @@ def test_sig_str(long delay=DEFAULT_DELAY):
signal_after_delay(SIGABRT, delay)
infinite_loop()

cdef c_test_sig_on_cython():
cdef c_test_sig_on_cython() noexcept:
sig_on()
infinite_loop()

Expand Down

0 comments on commit 81903a4

Please sign in to comment.