summaryrefslogtreecommitdiff
path: root/gen-psqr.c
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2012-02-26 17:18:00 +0100
committerNiels Möller <nisse@lysator.liu.se>2012-02-26 17:18:00 +0100
commitccf5b317ceb5509f17a75d234d568a6290aad6bd (patch)
treefe1c08f957dfa121840e519ad236228e0670eaf9 /gen-psqr.c
parent70266154bd2bce9f72eb54aebd6e47251f5e04b6 (diff)
downloadgmp-ccf5b317ceb5509f17a75d234d568a6290aad6bd.tar.gz
Added mini-gmp. Use it for bootstrap. Deleted dumbmp.c.
Diffstat (limited to 'gen-psqr.c')
-rw-r--r--gen-psqr.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/gen-psqr.c b/gen-psqr.c
index 9c33d7a68..e43da6a1a 100644
--- a/gen-psqr.c
+++ b/gen-psqr.c
@@ -20,7 +20,7 @@ along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
#include <stdio.h>
#include <stdlib.h>
-#include "dumbmp.c"
+#include "bootstrap.c"
/* The aim of this program is to choose either mpn_mod_34lsub1 or mpn_mod_1
@@ -152,9 +152,9 @@ f_cmp_fraction (const void *parg, const void *qarg)
accordingly. */
#define COLLAPSE_ELEMENT(array, idx, narray) \
do { \
- mem_copyi ((char *) &(array)[idx], \
- (char *) &(array)[idx+1], \
- ((narray)-((idx)+1)) * sizeof (array[0])); \
+ memmove (&(array)[idx], \
+ &(array)[idx+1], \
+ ((narray)-((idx)+1)) * sizeof (array[0])); \
(narray)--; \
} while (0)
@@ -173,7 +173,7 @@ mul_2exp_mod (int n, int p, int m)
int
neg_mod (int n, int m)
{
- ASSERT (n >= 0 && n < m);
+ assert (n >= 0 && n < m);
return (n == 0 ? 0 : m-n);
}
@@ -202,7 +202,7 @@ generate_sq_res_0x100 (int limb_bits)
int i, res;
nsq_res_0x100 = (0x100 + limb_bits - 1) / limb_bits;
- sq_res_0x100 = (mpz_t *) xmalloc (nsq_res_0x100 * sizeof (*sq_res_0x100));
+ sq_res_0x100 = xmalloc (nsq_res_0x100 * sizeof (*sq_res_0x100));
for (i = 0; i < nsq_res_0x100; i++)
mpz_init_set_ui (sq_res_0x100[i], 0L);
@@ -233,9 +233,8 @@ generate_mod (int limb_bits, int nail_bits)
/* no more than limb_bits many factors in a one limb modulus (and of
course in reality nothing like that many) */
factor_alloc = limb_bits;
- factor = (struct factor_t *) xmalloc (factor_alloc * sizeof (*factor));
- rawfactor = (struct rawfactor_t *)
- xmalloc (factor_alloc * sizeof (*rawfactor));
+ factor = xmalloc (factor_alloc * sizeof (*factor));
+ rawfactor = xmalloc (factor_alloc * sizeof (*rawfactor));
if (numb_bits % 4 != 0)
{
@@ -301,7 +300,7 @@ generate_mod (int limb_bits, int nail_bits)
}
while (mpz_sgn (r) == 0);
- ASSERT (nrawfactor < factor_alloc);
+ assert (nrawfactor < factor_alloc);
rawfactor[nrawfactor].divisor = i;
rawfactor[nrawfactor].multiplicity = multiplicity;
nrawfactor++;
@@ -341,7 +340,7 @@ generate_mod (int limb_bits, int nail_bits)
break;
mpz_set (pp, new_pp);
- ASSERT (nrawfactor < factor_alloc);
+ assert (nrawfactor < factor_alloc);
rawfactor[nrawfactor].divisor = i;
rawfactor[nrawfactor].multiplicity = 1;
nrawfactor++;
@@ -377,7 +376,7 @@ generate_mod (int limb_bits, int nail_bits)
for (i = 0; i < nrawfactor; i++)
{
int j;
- ASSERT (nfactor < factor_alloc);
+ assert (nfactor < factor_alloc);
factor[nfactor].divisor = 1;
for (j = 0; j < rawfactor[i].multiplicity; j++)
factor[nfactor].divisor *= rawfactor[i].divisor;