/* -*-c-*-
*
- * $Id: mp-io.c,v 1.1 1999/11/17 18:02:16 mdw Exp $
+ * $Id: mp-io.c,v 1.4 2000/06/17 11:45:09 mdw Exp $
*
* Loading and storing of multiprecision integers
*
/*----- Revision history --------------------------------------------------*
*
* $Log: mp-io.c,v $
+ * Revision 1.4 2000/06/17 11:45:09 mdw
+ * Major memory management overhaul. Added arena support. Use the secure
+ * arena for secret integers. Replace and improve the MP management macros
+ * (e.g., replace MP_MODIFY by MP_DEST).
+ *
+ * Revision 1.3 1999/11/21 22:13:02 mdw
+ * Add mp version of MPX_BITS.
+ *
+ * Revision 1.2 1999/11/19 13:19:06 mdw
+ * Set flags on results correctly.
+ *
* Revision 1.1 1999/11/17 18:02:16 mdw
* New multiprecision integer arithmetic suite.
*
return (sz);
}
+/* --- @mp_bits@ --- *
+ *
+ * Arguments: @const mp *m@ = a multiprecision integer
+ *
+ * Returns: The number of bits required to represent @m@.
+ *
+ * Use: Calculates the external storage required for a multiprecision
+ * integer.
+ */
+
+unsigned long mp_bits(const mp *m)
+{
+ unsigned long bits;
+ MPX_BITS(bits, m->v, m->vl);
+ return (bits);
+}
+
/* --- @mp_loadl@ --- *
*
* Arguments: @mp *d@ = destination
mp *mp_loadl(mp *d, const void *pv, size_t sz)
{
- MP_MODIFY(d, MPW_RQ(sz));
+ MP_DEST(d, MPW_RQ(sz), MP_UNDEF);
mpx_loadl(d->v, d->vl, pv, sz);
+ d->f &= ~(MP_UNDEF | MP_NEG);
mp_shrink(d);
return (d);
}
mp *mp_loadb(mp *d, const void *pv, size_t sz)
{
- MP_MODIFY(d, MPW_RQ(sz));
+ MP_DEST(d, MPW_RQ(sz), MP_UNDEF);
mpx_loadb(d->v, d->vl, pv, sz);
+ d->f &= ~(MP_UNDEF | MP_NEG);
mp_shrink(d);
return (d);
}