mp.c: Assert about the Python limb size statically.
[catacomb-python] / mp.c
diff --git a/mp.c b/mp.c
index a664627..b646846 100644 (file)
--- 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;