Add support for left-to-right bitscanning, for use in modular
[u/mdw/catacomb] / mp.h
diff --git a/mp.h b/mp.h
index 12003d0..5bc465d 100644 (file)
--- a/mp.h
+++ b/mp.h
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: mp.h,v 1.8 2000/06/22 19:02:01 mdw Exp $
+ * $Id: mp.h,v 1.9 2000/07/29 17:03:31 mdw Exp $
  *
  * Simple multiprecision arithmetic
  *
 /*----- Revision history --------------------------------------------------* 
  *
  * $Log: mp.h,v $
+ * Revision 1.9  2000/07/29 17:03:31  mdw
+ * Add support for left-to-right bitscanning, for use in modular
+ * exponentiation.
+ *
  * Revision 1.8  2000/06/22 19:02:01  mdw
  * Add new functions.
  *
@@ -420,13 +424,36 @@ extern void mp_scan(mpscan */*sc*/, const mp */*m*/);
   MPSCAN_INITX(_sc, _mm->v, _mm->vl);                                  \
 } while (0)
 
+/* --- @mp_rscan@ --- *
+ *
+ * Arguments:  @mpscan *sc@ = pointer to bitscanner block
+ *             @const mp *m@ = pointer to a multiprecision integer
+ *
+ * Returns:    ---
+ *
+ * Use:                Initializes a reverse bitscanner on a multiprecision
+ *             integer.
+ */
+
+extern void mp_rscan(mpscan */*sc*/, const mp */*m*/);
+
+#define MP_RSCAN(sc, m) do {                                           \
+  const mp *_mm = (m);                                                 \
+  mpscan *_sc = (sc);                                                  \
+  MPSCAN_RINITX(_sc, _mm->v, _mm->vl);                                 \
+} while (0)
+
 /* --- Other bitscanning aliases --- */
 
 #define mp_step mpscan_step
 #define mp_bit mpscan_bit
+#define mp_rstep mpscan_rstep
+#define mp_rbit mpscan_rbit
 
 #define MP_STEP MPSCAN_STEP
 #define MP_BIT MPSCAN_BIT
+#define MP_RSTEP MPSCAN_RSTEP
+#define MP_RBIT MPSCAN_RBIT
 
 /*----- Loading and storing -----------------------------------------------*/