diff options
author | Torbjorn Granlund <tege@gmplib.org> | 2013-03-21 23:03:07 +0100 |
---|---|---|
committer | Torbjorn Granlund <tege@gmplib.org> | 2013-03-21 23:03:07 +0100 |
commit | 572bc93638aa09e48685b87b0bd20e5a58f84ca1 (patch) | |
tree | dbaab3b37b57e6b36a87efe7f3f9c2629de8bece | |
parent | 0374a3ae8b02f0710c74e056e145cbffe4b77dad (diff) | |
download | gmp-572bc93638aa09e48685b87b0bd20e5a58f84ca1.tar.gz |
Move veriables out from generated file, make them 'const'.
-rw-r--r-- | gen-trialdivtab.c | 18 | ||||
-rw-r--r-- | mpn/generic/trialdiv.c | 16 |
2 files changed, 26 insertions, 8 deletions
diff --git a/gen-trialdivtab.c b/gen-trialdivtab.c index d87265ec4..ccb4ce44e 100644 --- a/gen-trialdivtab.c +++ b/gen-trialdivtab.c @@ -2,7 +2,7 @@ Contributed to the GNU project by Torbjorn Granlund. -Copyright 2009, 2012 Free Software Foundation, Inc. +Copyright 2009, 2012, 2013 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -98,7 +98,9 @@ main (int argc, char *argv[]) omitted_p = 3; interval_end = 0; - printf ("static struct gmp_primes_dtab gmp_primes_dtab[] = {\n"); +/* printf ("static struct gmp_primes_dtab gmp_primes_dtab[] = {\n"); */ + + printf ("#ifdef WANT_dtab\n"); for (t = start_p; t <= end_p; t += 2) { @@ -120,7 +122,7 @@ main (int argc, char *argv[]) if (! isprime (p)) continue; - printf (" P(%d,", (int) p); + printf (" P(%d,", (int) p); mpz_invert_ui_2exp (inv, p, limb_bits); printf ("CNST_LIMB(0x"); mpz_out_str (stdout, 16, inv); printf ("),"); @@ -138,10 +140,12 @@ main (int argc, char *argv[]) } interval_end = t; } - printf (" P(0,0,0)\n};\n"); + printf ("#define SMALLEST_OMITTED_PRIME %d\n", (int) omitted_p); + printf ("#endif\n"); + printf ("#ifdef WANT_ptab\n"); - printf ("static struct gmp_primes_ptab gmp_primes_ptab[] = {\n"); +/* printf ("static struct gmp_primes_ptab gmp_primes_ptab[] = {\n"); */ endtok = ""; @@ -193,9 +197,9 @@ main (int argc, char *argv[]) interval_end = t; np++; } - printf ("\n};\n"); - printf ("#define SMALLEST_OMITTED_PRIME %d\n", (int) omitted_p); + printf ("\n"); + printf ("#endif\n"); return 0; } diff --git a/mpn/generic/trialdiv.c b/mpn/generic/trialdiv.c index e61bc69fd..ced90f1fd 100644 --- a/mpn/generic/trialdiv.c +++ b/mpn/generic/trialdiv.c @@ -6,7 +6,7 @@ SAFE TO REACH IT THROUGH DOCUMENTED INTERFACES. IN FACT, IT IS ALMOST GUARANTEED THAT IT WILL CHANGE OR DISAPPEAR IN A FUTURE GNU MP RELEASE. -Copyright 2009, 2010, 2012 Free Software Foundation, Inc. +Copyright 2009, 2010, 2012, 2013 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -58,9 +58,23 @@ struct gmp_primes_ptab { unsigned int np :8; /* number of primes related to this entry */ }; + +static const struct gmp_primes_dtab gmp_primes_dtab[] = +{ +#define WANT_dtab #define P(p,inv,lim) {inv,lim} +#include "trialdivtab.h" +#undef WANT_dtab +#undef P + {0,0} +}; +static const struct gmp_primes_ptab gmp_primes_ptab[] = +{ +#define WANT_ptab #include "trialdivtab.h" +#undef WANT_ptab +}; #define PTAB_LINES (sizeof (gmp_primes_ptab) / sizeof (gmp_primes_ptab[0])) |