From e2568047e1f83f2ff6095c88d9be4a4d838cd62b Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Mon, 21 Oct 2019 11:40:39 +0100 Subject: [PATCH] mp.c: Assert about the Python limb size statically. Python extensions build with assertions off, so this was much less helpful than it looked. --- mp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mp.c b/mp.c index a664627..b646846 100644 --- a/mp.c +++ b/mp.c @@ -33,6 +33,9 @@ PyTypeObject *mp_pytype = 0; PyTypeObject *gf_pytype = 0; +STATIC_ASSERT(MPW_BITS >= SHIFT, + "Catacomb's limbs are now narrower than than Python's!"); + mp *mp_frompylong(PyObject *obj) { unsigned long bits; @@ -47,7 +50,6 @@ mp *mp_frompylong(PyObject *obj) sz = Py_SIZE(l); if (sz < 0) sz = -sz; - assert(MPW_BITS >= SHIFT); bits = (unsigned long)sz * SHIFT; w = (bits + MPW_BITS - 1)/MPW_BITS; x = mp_new(w, Py_SIZE(l) < 0 ? MP_NEG : 0); @@ -80,7 +82,6 @@ PyObject *mp_topylong(mp *x) mpw *p = x->v; int i = 0; - assert(MPW_BITS >= SHIFT); while (i < sz && p < x->vl) { r |= (mpd)*p++ << b; b += MPW_BITS; -- 2.11.0