cc.h: Reorder the declarations.
[u/mdw/catacomb] / pgen.h
diff --git a/pgen.h b/pgen.h
index 421819a..a066e28 100644 (file)
--- a/pgen.h
+++ b/pgen.h
@@ -1,13 +1,13 @@
 /* -*-c-*-
  *
- * $Id: pgen.h,v 1.9 2004/04/08 01:36:15 mdw Exp $
+ * $Id$
  *
  * Prime generation glue
  *
  * (c) 1999 Straylight/Edgeware
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of Catacomb.
  *
  * it under the terms of the GNU Library General Public License as
  * published by the Free Software Foundation; either version 2 of the
  * License, or (at your option) any later version.
- * 
+ *
  * Catacomb is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU Library General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Library General Public
  * License along with Catacomb; if not, write to the Free
  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
@@ -145,7 +145,7 @@ typedef struct pgen_filterctx {
   pfilt f;                             /* The rapid prime filter */
 } pgen_filterctx;
 
-extern int pgen_filter(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+extern pgen_proc pgen_filter;
 
 /* --- @pgen_jump@ --- *
  *
@@ -158,7 +158,7 @@ typedef struct pgen_jumpctx {
   pfilt f;
 } pgen_jumpctx;
 
-extern int pgen_jump(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+extern pgen_proc pgen_jump;
 
 /* --- @pgen_test@ --- *
  *
@@ -166,46 +166,43 @@ extern int pgen_jump(int /*rq*/, pgen_event */*ev*/, void */*p*/);
  * @rabin@ context.
  */
 
-extern int pgen_test(int /*rq*/, pgen_event */*ev*/, void */*p*/);
-
-/*----- Safe prime functions ----------------------------------------------*/
-
-/* --- @pgen_safestep@ --- *
+extern pgen_proc pgen_test;
+
+/*----- Simultaneous primality checking -----------------------------------*/
+
+typedef struct pgen_simulprime {
+  mp *mul, *add;                       /* Arguments from the client */
+  unsigned f;                          /* Flags, set by client, changed */
+#define PGENF_KEEP 1u                  /*   Keep this prime's value */
+#define PGENF_JUMP 8u                  /*   Use jump table, not stepping */
+  pfilt p;                             /* This prime's filter */
+  rabin r;                             /* Rabin testing context */
+  union {
+    mpw step;                          /* The simple step to use */
+    pfilt *jump;                       /* The jump to move by */
+    mp *x;                             /* The result, if wanted */
+  } u;
+} pgen_simulprime;
+
+typedef struct pgen_simulctx {
+  pgen_simulprime *v;                  /* Vector of related primes */
+  unsigned n;                          /* Size of the vector */
+  mp *step;                            /* Basic stepping value */
+} pgen_simulctx;
+
+/* --- @pgen_simulstep@ --- *
  *
- * Steps two numbers, %$q$% and %$p = 2q + 1$%, such that neither has any
- * small factors.  %$p$% is put in the event block.
+ * Step a collection of numbers simultaneously.
  */
 
-typedef struct pgen_safestepctx {
-  pfilt q, p;
-} pgen_safestepctx;
-
-extern int pgen_safestep(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+extern pgen_proc pgen_simulstep;
 
-/* --- @pgen_safejump@ --- *
+/* --- @pgen_simultest@ --- *
  *
- * Jumps two numbers, %$q$% and %$p = 2q + 1$% such that neither has any
- * small factors.
+ * Test a collection of numbers simultaneously.
  */
 
-typedef struct pgen_safejumpctx {
-  pfilt q, jq;
-  pfilt p, jp;
-} pgen_safejumpctx;
-
-extern int pgen_safejump(int /*rq*/, pgen_event */*ev*/, void */*p*/);
-
-/* --- @pgen_safetest@ --- *
- *
- * Applies Rabin-Miller tests to %$p$% and %$(p - 1)/2$%.
- */
-
-typedef struct pgen_safetestctx {
-  pgen_safestepctx c;
-  rabin q, p;
-} pgen_safetestctx;
-
-extern int pgen_safetest(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+extern pgen_proc pgen_simultest;
 
 /*----- Miscellaneous steppers and testers --------------------------------*/
 
@@ -223,7 +220,7 @@ typedef struct pgen_gcdstepctx {
  * %$\gcd(p, r) \le max$%.
  */
 
-extern int pgen_gcdstep(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+extern pgen_proc pgen_gcdstep;
 
 /*----- Standard event handlers -------------------------------------------*/
 
@@ -232,21 +229,21 @@ extern int pgen_gcdstep(int /*rq*/, pgen_event */*ev*/, void */*p*/);
  * Displays a spinning baton to show progress.
  */
 
-extern int pgen_evspin(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+extern pgen_proc pgen_evspin;
 
 /* --- @pgen_ev@ --- *
  *
  * Traditional event handler, shows dots for each test.
  */
 
-extern int pgen_ev(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+extern pgen_proc pgen_ev;
 
 /* --- @pgen_subev@ --- *
  *
  * Subsidiary event handler, mainly for Lim-Lee searches and so on.
  */
 
-extern int pgen_subev(int /*rq*/, pgen_event */*ev*/, void */*p*/);
+extern pgen_proc pgen_subev;
 
 /*----- The main driver ---------------------------------------------------*/
 
@@ -264,7 +261,7 @@ extern int pgen_subev(int /*rq*/, pgen_event */*ev*/, void */*p*/);
  *             @pgen_proc *test@ = tester function to use
  *             @void *tctx@ = context argument for tester
  *
- * Returns:    If successful, @PGEN_DONE@; otherwise @PGEN_ABORT@.
+ * Returns:    The resulting value, or null.
  *
  * Use:                A generalized prime-number search skeleton.  Yes, that's a
  *             scary number of arguments.