I added n_to_bit_start and after some misadventure with mistyping I got it
working.

One quick question: in this code block should the SWING_ON_PRIME be
indented?

LOOP_ON_SIEVE_BEGIN (prime, ...);
SH_SWING_A_PRIME (prime, ...);
LOOP_ON_SIEVE_END;

One thing I don't like about the patch is that most of the
LOOP_ON_SIEVE_BEGIN lines are now 90-100 characters
It's possible that I should pull out `mp_limb_t start =
sieve_n_to_bit_start(n);` in a number of places

One thing I do like is
7 files changed, 106 insertions(+), 250 deletions(-)
with all the addition in gmp-impl.h which is already HUGE


On Tue, Mar 17, 2020 at 11:10 AM Marco Bodrato <bodr...@mail.dm.unipi.it>
wrote:

> Ciao,
>
> Il 2020-03-16 04:36 Seth Troisi ha scritto:
> > Per Marco's comments in my prev_prime/next_prime patch
> > I moved some of the primesieve macros and functions to gmp-impl.h
>
>
> There are two reasons why I never moved those functions and macros to
> gmp-impl.h, two aspects of one problem: the interface is not clean.
>
> First: I'm not sure I like macros that open a loop and don't close it...
>
> Second: n_to_bit() is not injective, obviously.
> E.g. n_to_bit(7) = 1, n_to_bit(10) = 1 .
> This is not a problem when its value is used for n_to_bit (<end>), but
> generates confusion if n_to_bit(<start>) is used on a <start> value that
> is not carefully chosen...
>
>
> The first, is maybe just an opinion of mine, do you think those macros
> are reasonably clean?
>
> The second, should be healed somehow. The easier way probably is to
> write two different functions:
> static mp_limb_t
> n_to_bit_end (mp_limb_t n) { return ((n-5)|1)/3U; }
>
> static mp_limb_t
> n_to_bit_start (mp_limb_t n) { return (n-2-n%2)/3U; }
>
> > bit_to_n (renamed sieve_bit_to_n)
> > id_to_n (renamed sieve_id_to_n)
> > n_to_bit (renamed sieve_n_to_bit)
>
> Renaming is a good idea, IMO.
>
> > This allows the four (soon to be five) identical copies in
> > bin_uiui, oddfac_1, primorial_ui, and tests/devel/primes
> > to be cleaned up.
>
> Uhm I have (slightly) changed the macros. Not the interface.
>
> > It's not clear where this should be documented, if someone tells
>
> Niels' answer is perfect.
>
> Ĝis,
> m
>
diff -r bcca14c8a090 ChangeLog
--- a/ChangeLog	Thu Mar 05 00:43:26 2020 +0100
+++ b/ChangeLog	Wed Mar 25 00:16:13 2020 -0700
@@ -1,3 +1,7 @@
+2020-03-15 Seth Troisi <sethtro...@google.com>
+
+	* gmp-impl.h: Add primesieve macros (LOOP_ON_SIEVE_*)
+
 2020-02-12 Marco Bodrato <bodr...@mail.dm.unipi.it>
 
 	* mpz/cmp.c: Avoid overflow on int even for huge sizes.
diff -r bcca14c8a090 gmp-impl.h
--- a/gmp-impl.h	Thu Mar 05 00:43:26 2020 +0100
+++ b/gmp-impl.h	Wed Mar 25 00:16:13 2020 -0700
@@ -2078,6 +2078,83 @@
 __GMP_DECLSPEC mp_limb_t gmp_primesieve (mp_ptr, mp_limb_t);
 
 
+/*
+ * primesieve macros and functions
+ *
+ * These macros are used to iterate over primes found by gmp_primesieve
+ * which are stored in a compact bit format (excluding multiples of 2 and 3).
+ *
+ * See mpz/primorial_ui.c for a complete example.
+ * Generic use is
+ *   size = primesieve_size (end);
+ *   sieve = __GMP_ALLOCATE_FUNC_LIMBS (size);
+ *   primepi = gmp_primesieve (sieve, end);
+ *   LOOP_ON_SIEVE_BEGIN (<name of prime variable>,
+                          sieve_n_to_bit_start (start), sieve_n_to_bit_end (end),
+                          <offset in sieve>, sieve);
+ *   <DO SOMETHING WITH <name of prime variable>>
+ *   LOOP_ON_SIEVE_END;
+ *
+ * If the loop needs to be broken into different stages (up to sqrt(end), rest)
+ * LOOP_ON_SIEVE_CONTINUE and LOOP_ON_SIEVE_STOP can be used.
+ */
+static mp_limb_t
+sieve_bit_to_n (mp_limb_t bit) { return (bit*3+4)|1; }
+
+static mp_limb_t
+sieve_id_to_n  (mp_limb_t id)  { return id*3+1+(id&1); }
+
+/* n_to_bit_start (n) bit that corresponds to n
+ *         _start rounds up for numbers not part of sieve (e.g 6 => 2)
+ *   = (n-2-(n%2))/3U
+ */
+static mp_limb_t
+sieve_n_to_bit_start (mp_limb_t n) { return (n-2-(n&1))/3U; }
+
+/* n_to_bit_end (n) bit that corresponds to n (rounds down)
+ *         _end rounds down for numbers not part of sieve (e.g. 6 => 1)
+ *   =  ((n-1)&(-CNST_LIMB(2)))/3U-1
+ *   = ((n-1)&(-2))/3U-1
+ */
+static mp_limb_t
+sieve_n_to_bit_end (mp_limb_t n) { return ((n-5)|1)/3U; }
+
+static mp_size_t
+primesieve_size (mp_limb_t n) { return sieve_n_to_bit_end(n) / GMP_LIMB_BITS + 1; }
+
+
+#define LOOP_ON_SIEVE_CONTINUE(prime,end,sieve)                 \
+    __max_i = (end);                                            \
+                                                                \
+    do {                                                        \
+      ++__i;                                                    \
+      if (((sieve)[__index] & __mask) == 0)                     \
+        {                                                       \
+          mp_limb_t prime;                                      \
+          prime = sieve_id_to_n(__i)
+
+#define LOOP_ON_SIEVE_BEGIN(prime,start,end,off,sieve)          \
+  do {                                                          \
+    mp_limb_t __mask, __index, __max_i, __i;                    \
+                                                                \
+    __i = (start)-(off);                                        \
+    __index = __i / GMP_LIMB_BITS;                              \
+    __mask = CNST_LIMB(1) << (__i % GMP_LIMB_BITS);             \
+    __i += (off);                                               \
+                                                                \
+    LOOP_ON_SIEVE_CONTINUE(prime,end,sieve)
+
+#define LOOP_ON_SIEVE_STOP                                      \
+        }                                                       \
+      __mask = __mask << 1 | __mask >> (GMP_LIMB_BITS-1);       \
+      __index += __mask & 1;                                    \
+    }  while (__i <= __max_i)
+
+#define LOOP_ON_SIEVE_END                                       \
+    LOOP_ON_SIEVE_STOP;                                         \
+  } while (0)
+
+
 #ifndef MUL_TOOM22_THRESHOLD
 #define MUL_TOOM22_THRESHOLD             30
 #endif
diff -r bcca14c8a090 mpz/bin_uiui.c
--- a/mpz/bin_uiui.c	Thu Mar 05 00:43:26 2020 +0100
+++ b/mpz/bin_uiui.c	Wed Mar 25 00:16:13 2020 -0700
@@ -491,57 +491,6 @@
       (PR) *= (P);						\
   } while (0)
 
-#define LOOP_ON_SIEVE_CONTINUE(prime,end,sieve)			\
-    __max_i = (end);						\
-								\
-    do {							\
-      ++__i;							\
-      if (((sieve)[__index] & __mask) == 0)			\
-	{							\
-	  mp_limb_t prime;					\
-	  prime = id_to_n(__i)
-
-#define LOOP_ON_SIEVE_BEGIN(prime,start,end,off,sieve)		\
-  do {								\
-    mp_limb_t __mask, __index, __max_i, __i;			\
-								\
-    __i = (start)-(off);					\
-    __index = __i / GMP_LIMB_BITS;				\
-    __mask = CNST_LIMB(1) << (__i % GMP_LIMB_BITS);		\
-    __i += (off);						\
-								\
-    LOOP_ON_SIEVE_CONTINUE(prime,end,sieve)
-
-#define LOOP_ON_SIEVE_STOP					\
-	}							\
-      __mask = __mask << 1 | __mask >> (GMP_LIMB_BITS-1);	\
-      __index += __mask & 1;					\
-    }  while (__i <= __max_i)
-
-#define LOOP_ON_SIEVE_END					\
-    LOOP_ON_SIEVE_STOP;						\
-  } while (0)
-
-/*********************************************************/
-/* Section sieve: sieving functions and tools for primes */
-/*********************************************************/
-
-#if WANT_ASSERT
-static mp_limb_t
-bit_to_n (mp_limb_t bit) { return (bit*3+4)|1; }
-#endif
-
-/* id_to_n (x) = bit_to_n (x-1) = (id*3+1)|1*/
-static mp_limb_t
-id_to_n  (mp_limb_t id)  { return id*3+1+(id&1); }
-
-/* n_to_bit (n) = ((n-1)&(-CNST_LIMB(2)))/3U-1 */
-static mp_limb_t
-n_to_bit (mp_limb_t n) { return ((n-5)|1)/3U; }
-
-static mp_size_t
-primesieve_size (mp_limb_t n) { return n_to_bit(n) / GMP_LIMB_BITS + 1; }
-
 /*********************************************************/
 /* Section binomial: fast binomial implementation        */
 /*********************************************************/
@@ -622,27 +571,28 @@
       mp_limb_t s;
 
       s = limb_apprsqrt(n);
-      s = n_to_bit (s);
-      ASSERT (bit_to_n (s+1) * bit_to_n (s+1) > n);
-      ASSERT (s <= n_to_bit (n >> 1));
-      LOOP_ON_SIEVE_BEGIN (prime, n_to_bit (5), s, 0,sieve);
+      s = sieve_n_to_bit_end (s);
+      ASSERT (sieve_bit_to_n(s) >= 5);
+      ASSERT (sieve_bit_to_n (s+1) * sieve_bit_to_n (s+1) > n);
+      ASSERT (s <= sieve_n_to_bit_end (n >> 1));
+      LOOP_ON_SIEVE_BEGIN (prime, sieve_n_to_bit_start (5), s, 0, sieve);
       COUNT_A_PRIME (prime, n, k, prod, max_prod, factors, j);
       LOOP_ON_SIEVE_STOP;
 
       ASSERT (max_prod <= GMP_NUMB_MAX / 2);
       max_prod <<= 1;
 
-      LOOP_ON_SIEVE_CONTINUE (prime, n_to_bit (n >> 1),sieve);
+      LOOP_ON_SIEVE_CONTINUE (prime, sieve_n_to_bit_end (n >> 1), sieve);
       SH_COUNT_A_PRIME (prime, n, k, prod, max_prod, factors, j);
       LOOP_ON_SIEVE_END;
 
       max_prod >>= 1;
     }
 
-  /* Store primes from (n-k)+1 to n */
-  ASSERT (n_to_bit (n - k) < n_to_bit (n));
+  /* Store primes from (n-k) to n */
+  ASSERT (sieve_n_to_bit_start (n - k + 1) < sieve_n_to_bit_end (n));
 
-  LOOP_ON_SIEVE_BEGIN (prime, n_to_bit (n - k) + 1, n_to_bit (n), 0,sieve);
+  LOOP_ON_SIEVE_BEGIN (prime, sieve_n_to_bit_start (n - k + 1), sieve_n_to_bit_end (n), 0, sieve);
   FACTOR_LIST_STORE (prime, prod, max_prod, factors, j);
   LOOP_ON_SIEVE_END;
 
@@ -661,10 +611,6 @@
 
 #undef COUNT_A_PRIME
 #undef SH_COUNT_A_PRIME
-#undef LOOP_ON_SIEVE_END
-#undef LOOP_ON_SIEVE_STOP
-#undef LOOP_ON_SIEVE_BEGIN
-#undef LOOP_ON_SIEVE_CONTINUE
 
 /*********************************************************/
 /* End of implementation of Goetgheluck's algorithm      */
diff -r bcca14c8a090 mpz/oddfac_1.c
--- a/mpz/oddfac_1.c	Thu Mar 05 00:43:26 2020 +0100
+++ b/mpz/oddfac_1.c	Wed Mar 25 00:16:13 2020 -0700
@@ -61,59 +61,6 @@
       (PR) *= (P);						\
   } while (0)
 
-#define LOOP_ON_SIEVE_CONTINUE(prime,end,sieve)			\
-    __max_i = (end);						\
-								\
-    do {							\
-      ++__i;							\
-      if (((sieve)[__index] & __mask) == 0)			\
-	{							\
-	  mp_limb_t prime;					\
-	  prime = id_to_n(__i)
-
-#define LOOP_ON_SIEVE_BEGIN(prime,start,end,off,sieve)		\
-  do {								\
-    mp_limb_t __mask, __index, __max_i, __i;			\
-								\
-    __i = (start)-(off);					\
-    __index = __i / GMP_LIMB_BITS;				\
-    __mask = CNST_LIMB(1) << (__i % GMP_LIMB_BITS);		\
-    __i += (off);						\
-								\
-    LOOP_ON_SIEVE_CONTINUE(prime,end,sieve)
-
-#define LOOP_ON_SIEVE_STOP					\
-	}							\
-      __mask = __mask << 1 | __mask >> (GMP_LIMB_BITS-1);	\
-      __index += __mask & 1;					\
-    }  while (__i <= __max_i)
-
-#define LOOP_ON_SIEVE_END					\
-    LOOP_ON_SIEVE_STOP;						\
-  } while (0)
-
-/*********************************************************/
-/* Section sieve: sieving functions and tools for primes */
-/*********************************************************/
-
-#if WANT_ASSERT
-static mp_limb_t
-bit_to_n (mp_limb_t bit) { return (bit*3+4)|1; }
-#endif
-
-/* id_to_n (x) = bit_to_n (x-1) = (id*3+1)|1*/
-static mp_limb_t
-id_to_n  (mp_limb_t id)  { return id*3+1+(id&1); }
-
-/* n_to_bit (n) = ((n-1)&(-CNST_LIMB(2)))/3U-1 */
-static mp_limb_t
-n_to_bit (mp_limb_t n) { return ((n-5)|1)/3U; }
-
-#if WANT_ASSERT
-static mp_size_t
-primesieve_size (mp_limb_t n) { return n_to_bit(n) / GMP_LIMB_BITS + 1; }
-#endif
-
 /*********************************************************/
 /* Section mswing: 2-multiswing factorial                */
 /*********************************************************/
@@ -210,11 +157,11 @@
     mp_limb_t s, l_max_prod;
 
     s = limb_apprsqrt(n);
-    ASSERT (s >= 5);
-    s = n_to_bit (s);
-    ASSERT (bit_to_n (s+1) * bit_to_n (s+1) > n);
-    ASSERT (s < n_to_bit (n / 3));
-    LOOP_ON_SIEVE_BEGIN (prime, n_to_bit (5), s, 0,sieve);
+    ASSERT (sieve_bit_to_n(s) >= 5);
+    s = sieve_n_to_bit_end (s);
+    ASSERT (sieve_bit_to_n (s+1) * sieve_bit_to_n (s+1) > n);
+    ASSERT (s < sieve_n_to_bit_end (n / 3));
+    LOOP_ON_SIEVE_BEGIN (prime, sieve_n_to_bit_start (5), s, 0, sieve);
     SWING_A_PRIME (prime, n, prod, max_prod, factors, j);
     LOOP_ON_SIEVE_STOP;
 
@@ -222,13 +169,13 @@
 
     l_max_prod = max_prod * 3;
 
-    LOOP_ON_SIEVE_CONTINUE (prime, n_to_bit (n/3), sieve);
+    LOOP_ON_SIEVE_CONTINUE (prime, sieve_n_to_bit_end (n/3), sieve);
     SH_SWING_A_PRIME (prime, n, prod, l_max_prod, factors, j);
     LOOP_ON_SIEVE_END;
   }
 
-  /* Store primes from (n+1)/2 to n */
-  LOOP_ON_SIEVE_BEGIN (prime, n_to_bit (n >> 1) + 1, n_to_bit (n), 0,sieve);
+  /* Store primes from n/2+1 to n */
+  LOOP_ON_SIEVE_BEGIN (prime, sieve_n_to_bit_start ((n >> 1) + 1), sieve_n_to_bit_end (n), 0, sieve);
   FACTOR_LIST_STORE (prime, prod, max_prod, factors, j);
   LOOP_ON_SIEVE_END;
 
@@ -247,10 +194,6 @@
 
 #undef SWING_A_PRIME
 #undef SH_SWING_A_PRIME
-#undef LOOP_ON_SIEVE_END
-#undef LOOP_ON_SIEVE_STOP
-#undef LOOP_ON_SIEVE_BEGIN
-#undef LOOP_ON_SIEVE_CONTINUE
 #undef FACTOR_LIST_APPEND
 
 /*********************************************************/
diff -r bcca14c8a090 mpz/primorial_ui.c
--- a/mpz/primorial_ui.c	Thu Mar 05 00:43:26 2020 +0100
+++ b/mpz/primorial_ui.c	Wed Mar 25 00:16:13 2020 -0700
@@ -48,59 +48,6 @@
       (PR) *= (P);						\
   } while (0)
 
-#define LOOP_ON_SIEVE_CONTINUE(prime,end,sieve)			\
-    __max_i = (end);						\
-								\
-    do {							\
-      ++__i;							\
-      if (((sieve)[__index] & __mask) == 0)			\
-	{							\
-	  mp_limb_t prime;					\
-	  prime = id_to_n(__i)
-
-#define LOOP_ON_SIEVE_BEGIN(prime,start,end,off,sieve)		\
-  do {								\
-    mp_limb_t __mask, __index, __max_i, __i;			\
-								\
-    __i = (start)-(off);					\
-    __index = __i / GMP_LIMB_BITS;				\
-    __mask = CNST_LIMB(1) << (__i % GMP_LIMB_BITS);		\
-    __i += (off);						\
-								\
-    LOOP_ON_SIEVE_CONTINUE(prime,end,sieve)
-
-#define LOOP_ON_SIEVE_STOP					\
-	}							\
-      __mask = __mask << 1 | __mask >> (GMP_LIMB_BITS-1);	\
-      __index += __mask & 1;					\
-    }  while (__i <= __max_i)
-
-#define LOOP_ON_SIEVE_END					\
-    LOOP_ON_SIEVE_STOP;						\
-  } while (0)
-
-/*********************************************************/
-/* Section sieve: sieving functions and tools for primes */
-/*********************************************************/
-
-#if 0
-static mp_limb_t
-bit_to_n (mp_limb_t bit) { return (bit*3+4)|1; }
-#endif
-
-/* id_to_n (x) = bit_to_n (x-1) = (id*3+1)|1*/
-static mp_limb_t
-id_to_n  (mp_limb_t id)  { return id*3+1+(id&1); }
-
-/* n_to_bit (n) = ((n-1)&(-CNST_LIMB(2)))/3U-1 */
-static mp_limb_t
-n_to_bit (mp_limb_t n) { return ((n-5)|1)/3U; }
-
-#if WANT_ASSERT
-static mp_size_t
-primesieve_size (mp_limb_t n) { return n_to_bit(n) / GMP_LIMB_BITS + 1; }
-#endif
-
 /*********************************************************/
 /* Section primorial: implementation                     */
 /*********************************************************/
@@ -141,7 +88,7 @@
 
 	max_prod = GMP_NUMB_MAX / n;
 
-	LOOP_ON_SIEVE_BEGIN (prime, n_to_bit(5), n_to_bit (n), 0, sieve);
+	LOOP_ON_SIEVE_BEGIN (prime, sieve_n_to_bit_start (5), sieve_n_to_bit_end (n), 0, sieve);
 	FACTOR_LIST_STORE (prime, prod, max_prod, factors, j);
 	LOOP_ON_SIEVE_END;
       }
diff -r bcca14c8a090 primesieve.c
--- a/primesieve.c	Thu Mar 05 00:43:26 2020 +0100
+++ b/primesieve.c	Wed Mar 25 00:16:13 2020 -0700
@@ -37,24 +37,6 @@
 
 #include "gmp-impl.h"
 
-#if 0
-static mp_limb_t
-bit_to_n (mp_limb_t bit) { return (bit*3+4)|1; }
-#endif
-
-/* id_to_n (x) = bit_to_n (x-1) = (id*3+1)|1*/
-static mp_limb_t
-id_to_n  (mp_limb_t id)  { return id*3+1+(id&1); }
-
-/* n_to_bit (n) = ((n-1)&(-CNST_LIMB(2)))/3U-1 */
-static mp_limb_t
-n_to_bit (mp_limb_t n) { return ((n-5)|1)/3U; }
-
-#if 0
-static mp_size_t
-primesieve_size (mp_limb_t n) { return n_to_bit(n) / GMP_LIMB_BITS + 1; }
-#endif
-
 #if GMP_LIMB_BITS > 61
 #define SIEVE_SEED CNST_LIMB(0x3294C9E069128480)
 #if GMP_LIMB_BITS == 64
@@ -249,7 +231,7 @@
 
   ASSERT (n > 4);
 
-  bits  = n_to_bit(n);
+  bits  = sieve_n_to_bit_end(n);
   limbs = bits / GMP_LIMB_BITS;
 
   if (limbs != 0)
@@ -264,7 +246,7 @@
 
     ASSERT (i < GMP_LIMB_BITS);
 
-    if (n_to_bit (SEED_LIMIT + 1) < GMP_LIMB_BITS)
+    if (sieve_n_to_bit_end (SEED_LIMIT + 1) < GMP_LIMB_BITS)
       i = 0;
     mask = CNST_LIMB(1) << i;
     index = 0;
@@ -276,7 +258,7 @@
 	  mp_limb_t lmask;
 	  unsigned  maskrot;
 
-	  step = id_to_n(i);
+	  step = sieve_id_to_n(i);
 /*	  lindex = n_to_bit(id_to_n(i)*id_to_n(i)); */
 	  lindex = i*(step+1)-1+(-(i&1)&(i+1));
 /*	  lindex = i*(step+1+(i&1))-1+(i&1); */
@@ -334,7 +316,7 @@
 	mp_limb_t lmask;
 	unsigned  maskrot;
 
-	step = id_to_n(i);
+	step = sieve_id_to_n(i);
 
 /*	lindex = n_to_bit(id_to_n(i)*id_to_n(i)); */
 	lindex = i*(step+1)-1+(-(i&1)&(i+1));
@@ -401,13 +383,13 @@
 
   ASSERT (n > 4);
 
-  bits = n_to_bit(n);
+  bits = sieve_n_to_bit_end(n);
   size = bits / GMP_LIMB_BITS + 1;
 
   if (size > BLOCK_SIZE * 2) {
     mp_size_t off;
     off = BLOCK_SIZE + (size % BLOCK_SIZE);
-    first_block_primesieve (bit_array, id_to_n (off * GMP_LIMB_BITS));
+    first_block_primesieve (bit_array, sieve_id_to_n (off * GMP_LIMB_BITS));
     do {
       block_resieve (bit_array + off, BLOCK_SIZE, off * GMP_LIMB_BITS, bit_array);
     } while ((off += BLOCK_SIZE) < size);
diff -r bcca14c8a090 tests/devel/primes.c
--- a/tests/devel/primes.c	Thu Mar 05 00:43:26 2020 +0100
+++ b/tests/devel/primes.c	Wed Mar 25 00:16:13 2020 -0700
@@ -57,48 +57,6 @@
 #define BLOCK_SIZE 2048
 #endif
 
-/*********************************************************/
-/* Section sieve: sieving functions and tools for primes */
-/*********************************************************/
-
-static mp_size_t
-primesieve_size (mp_limb_t n) { return n_to_bit(n) / GMP_LIMB_BITS + 1; }
-
-/*************************************************************/
-/* Section macros: common macros, for swing/fac/bin (&sieve) */
-/*************************************************************/
-
-#define LOOP_ON_SIEVE_CONTINUE(prime,end,sieve)			\
-    __max_i = (end);						\
-								\
-    do {							\
-      ++__i;							\
-      if (((sieve)[__index] & __mask) == 0)			\
-	{							\
-          mp_limb_t prime;					\
-	  prime = id_to_n(__i)
-
-#define LOOP_ON_SIEVE_BEGIN(prime,start,end,off,sieve)		\
-  do {								\
-    mp_limb_t __mask, __index, __max_i, __i;			\
-								\
-    __i = (start)-(off);					\
-    __index = __i / GMP_LIMB_BITS;				\
-    __mask = CNST_LIMB(1) << (__i % GMP_LIMB_BITS);		\
-    __i += (off);						\
-								\
-    LOOP_ON_SIEVE_CONTINUE(prime,end,sieve)
-
-#define LOOP_ON_SIEVE_STOP					\
-	}							\
-      __mask = __mask << 1 | __mask >> (GMP_LIMB_BITS-1);	\
-      __index += __mask & 1;					\
-    }  while (__i <= __max_i)
-
-#define LOOP_ON_SIEVE_END					\
-    LOOP_ON_SIEVE_STOP;						\
-  } while (0)
-
 mpz_t g;
 
 int something_wrong (mpz_t er, int exp)
@@ -148,8 +106,7 @@
 	  TRACE (printf ("off =%li\n", off),3);
 	  block_resieve (sieve, BLOCK_SIZE, off, primes);
 	  TRACE (printf ("LOOP =%li - %li\n", id_to_n (off+1), id_to_n (off + BLOCK_SIZE * GMP_LIMB_BITS)),3);
-	  LOOP_ON_SIEVE_BEGIN (prime, off, off + BLOCK_SIZE * GMP_LIMB_BITS - 1,
-			       off, sieve);
+	  LOOP_ON_SIEVE_BEGIN (prime, off, off + BLOCK_SIZE * GMP_LIMB_BITS - 1, off, sieve);
 
 	  do {
 	    *(g->_mp_d) = begin;
_______________________________________________
gmp-devel mailing list
gmp-devel@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-devel

Reply via email to