remove prebuild for fib_table

This commit is contained in:
jasonmoxham 2010-07-16 18:45:28 +00:00
parent 10e204c922
commit 3159c85ea2
4 changed files with 3 additions and 165 deletions

View File

@ -212,7 +212,7 @@ MPQ_OBJECTS = mpq/abs$U.lo mpq/aors$U.lo \
mpq/equal$U.lo mpq/set_z$U.lo mpq/set_d$U.lo \
mpq/set_f$U.lo mpq/swap$U.lo
MPN_OBJECTS = mpn/fib_table$U.lo
#MPN_OBJECTS = mpn/fib_table$U.lo
PRINTF_OBJECTS = \
printf/asprintf$U.lo printf/asprntffuns$U.lo \
@ -337,19 +337,6 @@ endif
EXTRA_DIST += dumbmp.c
mpn/fib_table.c: gen-fib$(EXEEXT_FOR_BUILD)
./gen-fib table $(BITS_PER_MP_LIMB) $(GMP_NAIL_BITS) >mpn/fib_table.c || (rm -f mpn/fib_table.c; exit 1)
BUILT_SOURCES += mpn/fib_table.c
gen-fib$(EXEEXT_FOR_BUILD): gen-fib$(U_FOR_BUILD).c dumbmp.c
$(CC_FOR_BUILD) `test -f 'gen-fib$(U_FOR_BUILD).c' || echo '$(srcdir)/'`gen-fib$(U_FOR_BUILD).c -o gen-fib$(EXEEXT_FOR_BUILD)
DISTCLEANFILES += gen-fib$(EXEEXT_FOR_BUILD)
EXTRA_DIST += gen-fib.c
gen-fib_.c: gen-fib.c
$(CPP_FOR_BUILD) `if test -f $(srcdir)/gen-fib.c; then echo $(srcdir)/gen-fib.c; else echo gen-fib.c; fi` | sed 's/^# \([0-9]\)/#line \1/' > gen-fib_.c || rm -f gen-fib_.c
mpn/perfsqr.h: gen-psqr$(EXEEXT_FOR_BUILD)
./gen-psqr $(BITS_PER_MP_LIMB) $(GMP_NAIL_BITS) >mpn/perfsqr.h || (rm -f mpn/perfsqr.h; exit 1)
BUILT_SOURCES += mpn/perfsqr.h

View File

@ -2321,7 +2321,7 @@ gmp_mpn_functions="$extra_functions \
add_err1_n add_err2_n sub_err1_n sub_err2_n \
fib2_ui mod_1 mod_34lsub1 mode1o pre_divrem_1 pre_mod_1 dump \
lgcd ngcd_matrix ngcd_step nhgcd2 \
mod_1_1 mod_1_2 mod_1_3 tdiv_q mp_bases \
mod_1_1 mod_1_2 mod_1_3 tdiv_q mp_bases fib_table \
mulmid_basecase mulmid mulmid_n toom42_mulmid mulmod_2expp1 mulmod_2expm1 \
mul mul_fft mul_n mul_basecase sqr_basecase random random2 pow_1 \
urandomb urandomm randomb rrandom invert dc_divappr_q_n \

147
gen-fib.c
View File

@ -1,147 +0,0 @@
/* Generate Fibonacci table data.
Copyright 2001, 2002, 2004 Free Software Foundation, Inc.
This file is part of the GNU MP Library.
The GNU MP Library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or (at your
option) any later version.
The GNU MP Library 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 Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the GNU MP Library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA. */
#include <stdio.h>
#include "dumbmp.c"
mpz_t *f;
int fnum, fib_limit, luc_limit;
void
generate (int numb_bits)
{
mpz_t limit, l;
int falloc, i;
mpz_init_set_ui (limit, 1L);
mpz_mul_2exp (limit, limit, numb_bits);
/* fib(2n) > 2^n, so use 2n as a limit for the table size */
falloc = 2 * numb_bits;
f = (mpz_t *) xmalloc (falloc * sizeof (*f));
mpz_init_set_ui (f[0], 1L); /* F[-1] */
mpz_init_set_ui (f[1], 0L); /* F[0] */
mpz_init (l);
for (i = 2; ; i++)
{
ASSERT (i < falloc);
/* F[i] = F[i-1] + F[i-2] */
mpz_init (f[i]);
mpz_add (f[i], f[i-1], f[i-2]);
if (mpz_cmp (f[i], limit) >= 0)
break;
fnum = i+1;
fib_limit = i-1;
/* L[i] = F[i]+2*F[i-1] */
mpz_add (l, f[i], f[i-1]);
mpz_add (l, l, f[i-1]);
if (mpz_cmp (l, limit) < 0)
luc_limit = i-1;
}
mpz_clear (limit);
}
void
header (int numb_bits)
{
printf ("/* This file generated by gen-fib.c - DO NOT EDIT. */\n");
printf ("\n");
printf ("#if GMP_NUMB_BITS != %d\n", numb_bits);
printf ("Error, error, this data is for %d bits\n", numb_bits);
printf ("#endif\n");
printf ("\n");
printf ("#define FIB_TABLE_LIMIT %d\n", fib_limit);
printf ("#define FIB_TABLE_LUCNUM_LIMIT %d\n", luc_limit);
}
void
table (int numb_bits)
{
int i;
printf ("/* This file generated by gen-fib.c - DO NOT EDIT. */\n");
printf ("\n");
printf ("#include \"mpir.h\"\n");
printf ("#include \"gmp-impl.h\"\n");
printf ("\n");
printf ("#if GMP_NUMB_BITS != %d\n", numb_bits);
printf ("Error, error, this data is for %d bits\n", numb_bits);
printf ("#endif\n");
printf ("\n");
printf ("const mp_limb_t\n");
printf ("__gmp_fib_table[FIB_TABLE_LIMIT+2] = {\n");
for (i = 0; i < fnum; i++)
{
printf (" CNST_LIMB (0x");
mpz_out_str (stdout, 16, f[i]);
printf ("), /* %d */\n", i-1);
}
printf ("};\n");
}
int
main (int argc, char *argv[])
{
int limb_bits, nail_bits, numb_bits;
if (argc != 4)
{
fprintf (stderr, "Usage: gen-bases <header|table> <limbbits> <nailbits>\n");
exit (1);
}
limb_bits = atoi (argv[2]);
nail_bits = atoi (argv[3]);
if (limb_bits <= 0
|| nail_bits < 0
|| nail_bits >= limb_bits)
{
fprintf (stderr, "Invalid limb/nail bits: %d %d\n",
limb_bits, nail_bits);
exit (1);
}
numb_bits = limb_bits - nail_bits;
generate (numb_bits);
if (strcmp (argv[1], "header") == 0)
header (numb_bits);
else if (strcmp (argv[1], "table") == 0)
table (numb_bits);
else
{
fprintf (stderr, "Invalid header/table choice: %s\n", argv[1]);
exit (1);
}
return 0;
}

View File

@ -27,7 +27,7 @@ INCLUDES = -D__GMP_WITHIN_GMP -I$(top_srcdir) \
OFILES = @mpn_objects@
noinst_LTLIBRARIES = libmpn.la
nodist_libmpn_la_SOURCES = fib_table.c
#nodist_libmpn_la_SOURCES = fib_table.c
libmpn_la_LIBADD = $(OFILES)
libmpn_la_DEPENDENCIES = $(OFILES)
@ -41,8 +41,6 @@ EXTRA_DIST = asm-defs.m4 cpp-ccas m4-ccas $(TARG_DIST)
# These are BUILT_SOURCES at the top-level, so normally they're built before
# recursing into this directory.
#
fib_table.c:
cd ..; $(MAKE) $(AM_MAKEFLAGS) mpn/fib_table.c
perfsqr.h:
cd ..; $(MAKE) $(AM_MAKEFLAGS) mpn/perfsqr.h