Skip to content

Commit 09850de

Browse files
committed
Use SIZEOF_SLONG macro to fix Windows bug
1 parent f0754e9 commit 09850de

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/flint/flintlib/types/flint.pxd

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ cdef extern from *:
5555
"""
5656

5757
cdef extern from "flint/flint.h":
58+
# These defines are needed to work around a Cython bug.
59+
# Otherwise sizeof(ulong) will give the wrong size on 64 bit Windows.
60+
# https://github.com/cython/cython/issues/6339
5861
"""
5962
#define SIZEOF_ULONG sizeof(ulong)
6063
#define SIZEOF_SLONG sizeof(slong)

src/flint/types/fmpz_mat.pyx

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ from flint.types.fmpq cimport any_as_fmpq
99
cimport cython
1010
cimport libc.stdlib
1111

12+
from flint.flintlib.types.flint cimport SIZEOF_SLONG
13+
1214
from flint.flintlib.functions.fmpz cimport (
1315
fmpz_set,
1416
fmpz_init,
@@ -660,7 +662,7 @@ cdef class fmpz_mat(flint_mat):
660662
cdef fmpz_mat LU
661663
r = fmpz_mat_nrows(self.val)
662664
c = fmpz_mat_ncols(self.val)
663-
perm = <slong*>libc.stdlib.malloc(r * sizeof(slong))
665+
perm = <slong*>libc.stdlib.malloc(r * SIZEOF_SLONG)
664666
if perm is NULL:
665667
raise MemoryError("malloc failed")
666668
try:

0 commit comments

Comments
 (0)