progs/perftest.c: Use from Glibc syscall numbers.
[catacomb] / math / mpreduce.c
index b148dd5..0fd4b45 100644 (file)
@@ -47,7 +47,7 @@ DA_DECL(instr_v, mpreduce_instr);
  *
  * Suppose %$x = x' + z 2^k$%, where %$k \ge n$%; then
  * %$x \equiv x' + d z 2^{k-n} \pmod p$%.  We can use this to trim the
- * representation of %$x$%; each time, we reduce %$x$% by a mutliple of
+ * representation of %$x$%; each time, we reduce %$x$% by a multiple of
  * %$2^{k-n} p$%.  We can do this in two passes: firstly by taking whole
  * words off the top, and then (if necessary) by trimming the top word.
  * Finally, if %$p \le x < 2^n$% then %$0 \le x - p < p$% and we're done.
@@ -210,7 +210,7 @@ int mpreduce_create(mpreduce *r, mp *p)
    * a perfect power of two, and %$d = 0$%, so again there is nothing to do.
    *
    * In the remaining case, we have decomposed @x@ as %$2^{n-1} + d$%, for
-   * some positive %$d%, which is unfortuante: if we're asked to reduce
+   * some positive %$d%, which is unfortunate: if we're asked to reduce
    * %$2^n$%, say, we'll end up with %$-d$% (or would do, if we weren't
    * sticking to unsigned arithmetic for good performance).  So instead, we
    * rewrite this as %$2^n - 2^{n-1} + d$% and everything will be good.
@@ -295,7 +295,7 @@ void mpreduce_destroy(mpreduce *r)
 
 /* --- @mpreduce_dump@ --- *
  *
- * Arguments:  @mpreduce *r@ = structure to dump
+ * Arguments:  @const mpreduce *r@ = structure to dump
  *             @FILE *fp@ = file to dump on
  *
  * Returns:    ---
@@ -303,7 +303,7 @@ void mpreduce_destroy(mpreduce *r)
  * Use:                Dumps a reduction context.
  */
 
-void mpreduce_dump(mpreduce *r, FILE *fp)
+void mpreduce_dump(const mpreduce *r, FILE *fp)
 {
   size_t i;
   static const char *opname[] = { "add", "addshift", "sub", "subshift" };
@@ -331,7 +331,7 @@ void mpreduce_dump(mpreduce *r, FILE *fp)
 
 /* --- @mpreduce_do@ --- *
  *
- * Arguments:  @mpreduce *r@ = reduction context
+ * Arguments:  @const mpreduce *r@ = reduction context
  *             @mp *d@ = destination
  *             @mp *x@ = source
  *
@@ -353,7 +353,7 @@ static void run(const mpreduce_instr *i, const mpreduce_instr *il,
   }
 }
 
-mp *mpreduce_do(mpreduce *r, mp *d, mp *x)
+mp *mpreduce_do(const mpreduce *r, mp *d, mp *x)
 {
   mpw *v, *vl;
   const mpreduce_instr *il;
@@ -410,7 +410,7 @@ mp *mpreduce_do(mpreduce *r, mp *d, mp *x)
 
 /* --- @mpreduce_exp@ --- *
  *
- * Arguments:  @mpreduce *mr@ = pointer to reduction context
+ * Arguments:  @const mpreduce *mr@ = pointer to reduction context
  *             @mp *d@ = fake destination
  *             @mp *a@ = base
  *             @mp *e@ = exponent
@@ -418,7 +418,7 @@ mp *mpreduce_do(mpreduce *r, mp *d, mp *x)
  * Returns:    Result, %$a^e \bmod m$%.
  */
 
-mp *mpreduce_exp(mpreduce *mr, mp *d, mp *a, mp *e)
+mp *mpreduce_exp(const mpreduce *mr, mp *d, mp *a, mp *e)
 {
   mp *x = MP_ONE;
   mp *spare = (e->f & MP_BURN) ? MP_NEWSEC : MP_NEW;
@@ -443,11 +443,8 @@ mp *mpreduce_exp(mpreduce *mr, mp *d, mp *a, mp *e)
 
 /*----- Test rig ----------------------------------------------------------*/
 
-
 #ifdef TEST_RIG
 
-#define MP(x) mp_readstring(MP_NEW, #x, 0, 0)
-
 static int vreduce(dstr *v)
 {
   mp *d = *(mp **)v[0].buf;