Skip to content

Commit

Permalink
Add missing noexcept clauses
Browse files Browse the repository at this point in the history
Note that the changes in memory.pxd are identical to upstream changes
made as part of sagemath/cysignals#187
  • Loading branch information
tornaria committed Mar 11, 2024
1 parent 346745c commit 47b1c64
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions memory_allocator/memory.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,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
2 changes: 1 addition & 1 deletion memory_allocator/memory_allocator.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ cdef extern from *:
int unlikely(int) nogil # defined by Cython


cdef inline void* align(void* ptr, size_t alignment):
cdef inline void* align(void* ptr, size_t alignment) noexcept:
"""
Round up ``ptr`` to the nearest multiple of ``alignment``, which
must be a power of 2
Expand Down
4 changes: 2 additions & 2 deletions memory_allocator/signals.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# Usage of ``sig_block`` / ``sig_unblock`` is not necesarry for ``MemoryAllocator``:
# One should not wrap its methods with ``sig_on`` ... ``sig_off`` anyway.

cdef inline void sig_block() nogil:
cdef inline void sig_block() noexcept nogil:
pass

cdef inline void sig_unblock() nogil:
cdef inline void sig_unblock() noexcept nogil:
pass

0 comments on commit 47b1c64

Please sign in to comment.