From 191d37d3c0fb71d14fa07c67bee148d8e1e8abdc Mon Sep 17 00:00:00 2001 From: markm Date: Sun, 20 Oct 1996 09:23:44 +0000 Subject: Remove the old libgmp. Version 2.0.2 is about to hit prime time. --- gnu/lib/libgmp/config/mt-linux | 1 - gnu/lib/libgmp/config/mt-m88110 | 1 - gnu/lib/libgmp/config/mt-sprc8-gcc | 1 - gnu/lib/libgmp/config/mt-supspc-gcc | 1 - gnu/lib/libgmp/demos/factorize.c | 233 ------------- gnu/lib/libgmp/doc/Makefile | 7 - gnu/lib/libgmp/mpbsd/Makefile.in | 84 ----- gnu/lib/libgmp/mpbsd/configure.in | 20 -- gnu/lib/libgmp/mpbsd/itom.c | 54 --- gnu/lib/libgmp/mpbsd/mdiv.c | 39 --- gnu/lib/libgmp/mpbsd/mfree.c | 36 -- gnu/lib/libgmp/mpbsd/min.c | 89 ----- gnu/lib/libgmp/mpbsd/mout.c | 96 ------ gnu/lib/libgmp/mpbsd/move.c | 46 --- gnu/lib/libgmp/mpbsd/mtox.c | 81 ----- gnu/lib/libgmp/mpbsd/realloc.c | 44 --- gnu/lib/libgmp/mpbsd/sdiv.c | 77 ----- gnu/lib/libgmp/mpbsd/xtom.c | 110 ------ gnu/lib/libgmp/mpf/Makefile.in | 115 ------- gnu/lib/libgmp/mpf/abs.c | 56 --- gnu/lib/libgmp/mpf/add.c | 180 ---------- gnu/lib/libgmp/mpf/add_ui.c | 151 -------- gnu/lib/libgmp/mpf/clear.c | 35 -- gnu/lib/libgmp/mpf/cmp.c | 114 ------- gnu/lib/libgmp/mpf/cmp_si.c | 98 ------ gnu/lib/libgmp/mpf/cmp_ui.c | 80 ----- gnu/lib/libgmp/mpf/configure.in | 12 - gnu/lib/libgmp/mpf/div.c | 144 -------- gnu/lib/libgmp/mpf/div_2exp.c | 79 ----- gnu/lib/libgmp/mpf/div_ui.c | 91 ----- gnu/lib/libgmp/mpf/dump.c | 43 --- gnu/lib/libgmp/mpf/eq.c | 121 ------- gnu/lib/libgmp/mpf/get_d.c | 54 --- gnu/lib/libgmp/mpf/get_prc.c | 34 -- gnu/lib/libgmp/mpf/get_str.c | 500 --------------------------- gnu/lib/libgmp/mpf/init.c | 38 --- gnu/lib/libgmp/mpf/init2.c | 41 --- gnu/lib/libgmp/mpf/inp_str.c | 89 ----- gnu/lib/libgmp/mpf/iset.c | 59 ---- gnu/lib/libgmp/mpf/iset_d.c | 39 --- gnu/lib/libgmp/mpf/iset_si.c | 55 --- gnu/lib/libgmp/mpf/iset_str.c | 40 --- gnu/lib/libgmp/mpf/iset_ui.c | 40 --- gnu/lib/libgmp/mpf/mul.c | 94 ----- gnu/lib/libgmp/mpf/mul_2exp.c | 89 ----- gnu/lib/libgmp/mpf/mul_ui.c | 74 ---- gnu/lib/libgmp/mpf/neg.c | 59 ---- gnu/lib/libgmp/mpf/out_str.c | 89 ----- gnu/lib/libgmp/mpf/random2.c | 65 ---- gnu/lib/libgmp/mpf/reldiff.c | 52 --- gnu/lib/libgmp/mpf/set.c | 53 --- gnu/lib/libgmp/mpf/set_d.c | 47 --- gnu/lib/libgmp/mpf/set_dfl_prec.c | 40 --- gnu/lib/libgmp/mpf/set_prc.c | 57 ---- gnu/lib/libgmp/mpf/set_prc_raw.c | 39 --- gnu/lib/libgmp/mpf/set_q.c | 170 --------- gnu/lib/libgmp/mpf/set_si.c | 51 --- gnu/lib/libgmp/mpf/set_str.c | 302 ---------------- gnu/lib/libgmp/mpf/set_ui.c | 45 --- gnu/lib/libgmp/mpf/set_z.c | 54 --- gnu/lib/libgmp/mpf/size.c | 35 -- gnu/lib/libgmp/mpf/sqrt.c | 75 ---- gnu/lib/libgmp/mpf/sqrt_ui.c | 61 ---- gnu/lib/libgmp/mpf/sub.c | 402 ---------------------- gnu/lib/libgmp/mpf/sub_ui.c | 49 --- gnu/lib/libgmp/mpf/tests/Makefile.in | 75 ---- gnu/lib/libgmp/mpf/tests/configure.in | 11 - gnu/lib/libgmp/mpf/tests/ref.c | 203 ----------- gnu/lib/libgmp/mpf/tests/reuse.c | 186 ---------- gnu/lib/libgmp/mpf/tests/t-add.c | 117 ------- gnu/lib/libgmp/mpf/tests/t-conv.c | 120 ------- gnu/lib/libgmp/mpf/tests/t-dm2exp.c | 101 ------ gnu/lib/libgmp/mpf/tests/t-muldiv.c | 161 --------- gnu/lib/libgmp/mpf/tests/t-sqrt.c | 103 ------ gnu/lib/libgmp/mpf/tests/t-sub.c | 122 ------- gnu/lib/libgmp/mpf/ui_div.c | 131 ------- gnu/lib/libgmp/mpf/ui_sub.c | 334 ------------------ gnu/lib/libgmp/mpn/Makefile.in | 92 ----- gnu/lib/libgmp/mpn/README | 15 - gnu/lib/libgmp/mpn/bsd.h | 5 - gnu/lib/libgmp/mpn/config/t-oldgas | 1 - gnu/lib/libgmp/mpn/config/t-ppc-aix | 1 - gnu/lib/libgmp/mpn/config/t-pwr-aix | 1 - gnu/lib/libgmp/mpn/configure.in | 178 ---------- gnu/lib/libgmp/mpn/generic/add_n.c | 62 ---- gnu/lib/libgmp/mpn/generic/addmul_1.c | 65 ---- gnu/lib/libgmp/mpn/generic/bdivmod.c | 129 ------- gnu/lib/libgmp/mpn/generic/cmp.c | 56 --- gnu/lib/libgmp/mpn/generic/divmod_1.c | 208 ----------- gnu/lib/libgmp/mpn/generic/divrem.c | 245 ------------- gnu/lib/libgmp/mpn/generic/divrem_1.c | 58 ---- gnu/lib/libgmp/mpn/generic/dump.c | 20 -- gnu/lib/libgmp/mpn/generic/gcd.c | 402 ---------------------- gnu/lib/libgmp/mpn/generic/gcd_1.c | 73 ---- gnu/lib/libgmp/mpn/generic/gcdext.c | 441 ------------------------ gnu/lib/libgmp/mpn/generic/get_str.c | 211 ------------ gnu/lib/libgmp/mpn/generic/gmp-mparam.h | 27 -- gnu/lib/libgmp/mpn/generic/hamdist.c | 88 ----- gnu/lib/libgmp/mpn/generic/inlines.c | 3 - gnu/lib/libgmp/mpn/generic/lshift.c | 87 ----- gnu/lib/libgmp/mpn/generic/mod_1.c | 197 ----------- gnu/lib/libgmp/mpn/generic/mul.c | 152 --------- gnu/lib/libgmp/mpn/generic/mul_1.c | 59 ---- gnu/lib/libgmp/mpn/generic/mul_n.c | 401 ---------------------- gnu/lib/libgmp/mpn/generic/perfsqr.c | 138 -------- gnu/lib/libgmp/mpn/generic/popcount.c | 87 ----- gnu/lib/libgmp/mpn/generic/pre_mod_1.c | 69 ---- gnu/lib/libgmp/mpn/generic/random2.c | 93 ----- gnu/lib/libgmp/mpn/generic/rshift.c | 88 ----- gnu/lib/libgmp/mpn/generic/scan0.c | 62 ---- gnu/lib/libgmp/mpn/generic/scan1.c | 62 ---- gnu/lib/libgmp/mpn/generic/set_str.c | 154 --------- gnu/lib/libgmp/mpn/generic/sqrtrem.c | 498 --------------------------- gnu/lib/libgmp/mpn/generic/sub_n.c | 62 ---- gnu/lib/libgmp/mpn/generic/submul_1.c | 65 ---- gnu/lib/libgmp/mpn/generic/udiv_w_sdiv.c | 125 ------- gnu/lib/libgmp/mpn/mp_bases.c | 549 ------------------------------ gnu/lib/libgmp/mpn/tests/add_n.c | 211 ------------ gnu/lib/libgmp/mpn/tests/addmul_1.c | 223 ------------ gnu/lib/libgmp/mpn/tests/divmod_1.c | 120 ------- gnu/lib/libgmp/mpn/tests/divrem.c | 129 ------- gnu/lib/libgmp/mpn/tests/lshift.c | 226 ------------ gnu/lib/libgmp/mpn/tests/mul_1.c | 212 ------------ gnu/lib/libgmp/mpn/tests/rshift.c | 227 ------------ gnu/lib/libgmp/mpn/tests/sub_n.c | 211 ------------ gnu/lib/libgmp/mpn/tests/submul_1.c | 218 ------------ gnu/lib/libgmp/mpn/tests/tst-addsub.c | 164 --------- gnu/lib/libgmp/mpn/x86/add_n.S | 106 ------ gnu/lib/libgmp/mpn/x86/addmul_1.S | 76 ----- gnu/lib/libgmp/mpn/x86/lshift.S | 85 ----- gnu/lib/libgmp/mpn/x86/mul_1.S | 75 ---- gnu/lib/libgmp/mpn/x86/pentium/README | 26 -- gnu/lib/libgmp/mpn/x86/pentium/add_n.S | 130 ------- gnu/lib/libgmp/mpn/x86/pentium/addmul_1.S | 83 ----- gnu/lib/libgmp/mpn/x86/pentium/lshift.S | 217 ------------ gnu/lib/libgmp/mpn/x86/pentium/mul_1.S | 79 ----- gnu/lib/libgmp/mpn/x86/pentium/rshift.S | 217 ------------ gnu/lib/libgmp/mpn/x86/pentium/sub_n.S | 130 ------- gnu/lib/libgmp/mpn/x86/pentium/submul_1.S | 83 ----- gnu/lib/libgmp/mpn/x86/rshift.S | 87 ----- gnu/lib/libgmp/mpn/x86/sub_n.S | 106 ------ gnu/lib/libgmp/mpn/x86/submul_1.S | 76 ----- gnu/lib/libgmp/mpn/x86/syntax.h | 62 ---- gnu/lib/libgmp/mpq/Makefile.in | 81 ----- gnu/lib/libgmp/mpq/add.c | 85 ----- gnu/lib/libgmp/mpq/canonicalize.c | 53 --- gnu/lib/libgmp/mpq/clear.c | 37 -- gnu/lib/libgmp/mpq/cmp.c | 120 ------- gnu/lib/libgmp/mpq/cmp_ui.c | 84 ----- gnu/lib/libgmp/mpq/configure.in | 12 - gnu/lib/libgmp/mpq/div.c | 93 ----- gnu/lib/libgmp/mpq/equal.c | 43 --- gnu/lib/libgmp/mpq/get_d.c | 151 -------- gnu/lib/libgmp/mpq/get_den.c | 41 --- gnu/lib/libgmp/mpq/get_num.c | 42 --- gnu/lib/libgmp/mpq/init.c | 40 --- gnu/lib/libgmp/mpq/inv.c | 75 ---- gnu/lib/libgmp/mpq/mul.c | 79 ----- gnu/lib/libgmp/mpq/neg.c | 36 -- gnu/lib/libgmp/mpq/set.c | 49 --- gnu/lib/libgmp/mpq/set_den.c | 42 --- gnu/lib/libgmp/mpq/set_num.c | 42 --- gnu/lib/libgmp/mpq/set_si.c | 54 --- gnu/lib/libgmp/mpq/set_ui.c | 50 --- gnu/lib/libgmp/mpq/set_z.c | 46 --- gnu/lib/libgmp/mpq/sub.c | 85 ----- gnu/lib/libgmp/mpq/tests/Makefile.in | 48 --- gnu/lib/libgmp/mpq/tests/configure.in | 11 - gnu/lib/libgmp/mpq/tests/t-cmp.c | 109 ------ gnu/lib/libgmp/mpq/tests/t-cmp_ui.c | 102 ------ gnu/lib/libgmp/mpq/tests/t-get_d.c | 88 ----- gnu/lib/libgmp/mpz/Makefile.in | 180 ---------- gnu/lib/libgmp/mpz/abs.c | 51 --- gnu/lib/libgmp/mpz/add.c | 120 ------- gnu/lib/libgmp/mpz/add_ui.c | 84 ----- gnu/lib/libgmp/mpz/and.c | 278 --------------- gnu/lib/libgmp/mpz/array_init.c | 48 --- gnu/lib/libgmp/mpz/cdiv_q.c | 51 --- gnu/lib/libgmp/mpz/cdiv_q_ui.c | 64 ---- gnu/lib/libgmp/mpz/cdiv_qr.c | 62 ---- gnu/lib/libgmp/mpz/cdiv_qr_ui.c | 68 ---- gnu/lib/libgmp/mpz/cdiv_r.c | 59 ---- gnu/lib/libgmp/mpz/cdiv_r_ui.c | 54 --- gnu/lib/libgmp/mpz/cdiv_ui.c | 50 --- gnu/lib/libgmp/mpz/clear.c | 35 -- gnu/lib/libgmp/mpz/clrbit.c | 114 ------- gnu/lib/libgmp/mpz/cmp.c | 75 ---- gnu/lib/libgmp/mpz/cmp_si.c | 66 ---- gnu/lib/libgmp/mpz/cmp_ui.c | 56 --- gnu/lib/libgmp/mpz/com.c | 93 ----- gnu/lib/libgmp/mpz/configure.in | 12 - gnu/lib/libgmp/mpz/divexact.c | 112 ------ gnu/lib/libgmp/mpz/dmincl.c | 201 ----------- gnu/lib/libgmp/mpz/fac_ui.c | 157 --------- gnu/lib/libgmp/mpz/fdiv_q.c | 51 --- gnu/lib/libgmp/mpz/fdiv_q_2exp.c | 94 ----- gnu/lib/libgmp/mpz/fdiv_q_ui.c | 62 ---- gnu/lib/libgmp/mpz/fdiv_qr.c | 62 ---- gnu/lib/libgmp/mpz/fdiv_qr_ui.c | 66 ---- gnu/lib/libgmp/mpz/fdiv_r.c | 58 ---- gnu/lib/libgmp/mpz/fdiv_r_2exp.c | 88 ----- gnu/lib/libgmp/mpz/fdiv_r_ui.c | 52 --- gnu/lib/libgmp/mpz/fdiv_ui.c | 48 --- gnu/lib/libgmp/mpz/gcd.c | 178 ---------- gnu/lib/libgmp/mpz/gcd_ui.c | 64 ---- gnu/lib/libgmp/mpz/gcdext.c | 88 ----- gnu/lib/libgmp/mpz/get_d.c | 54 --- gnu/lib/libgmp/mpz/get_si.c | 43 --- gnu/lib/libgmp/mpz/get_str.c | 118 ------- gnu/lib/libgmp/mpz/get_ui.c | 37 -- gnu/lib/libgmp/mpz/getlimbn.c | 38 --- gnu/lib/libgmp/mpz/hamdist.c | 62 ---- gnu/lib/libgmp/mpz/init.c | 36 -- gnu/lib/libgmp/mpz/inp_raw.c | 101 ------ gnu/lib/libgmp/mpz/inp_str.c | 138 -------- gnu/lib/libgmp/mpz/invert.c | 43 --- gnu/lib/libgmp/mpz/ior.c | 243 ------------- gnu/lib/libgmp/mpz/iset.c | 49 --- gnu/lib/libgmp/mpz/iset_d.c | 39 --- gnu/lib/libgmp/mpz/iset_si.c | 49 --- gnu/lib/libgmp/mpz/iset_str.c | 44 --- gnu/lib/libgmp/mpz/iset_ui.c | 39 --- gnu/lib/libgmp/mpz/jacobi.c | 53 --- gnu/lib/libgmp/mpz/legendre.c | 184 ---------- gnu/lib/libgmp/mpz/mod.c | 63 ---- gnu/lib/libgmp/mpz/mul.c | 127 ------- gnu/lib/libgmp/mpz/mul_2exp.c | 76 ----- gnu/lib/libgmp/mpz/mul_ui.c | 64 ---- gnu/lib/libgmp/mpz/neg.c | 53 --- gnu/lib/libgmp/mpz/out_raw.c | 89 ----- gnu/lib/libgmp/mpz/out_str.c | 108 ------ gnu/lib/libgmp/mpz/perfsqr.c | 41 --- gnu/lib/libgmp/mpz/popcount.c | 42 --- gnu/lib/libgmp/mpz/pow_ui.c | 129 ------- gnu/lib/libgmp/mpz/powm.c | 276 --------------- gnu/lib/libgmp/mpz/powm_ui.c | 234 ------------- gnu/lib/libgmp/mpz/pprime_p.c | 115 ------- gnu/lib/libgmp/mpz/random.c | 56 --- gnu/lib/libgmp/mpz/random2.c | 48 --- gnu/lib/libgmp/mpz/realloc.c | 52 --- gnu/lib/libgmp/mpz/scan0.c | 35 -- gnu/lib/libgmp/mpz/scan1.c | 35 -- gnu/lib/libgmp/mpz/set.c | 48 --- gnu/lib/libgmp/mpz/set_d.c | 93 ----- gnu/lib/libgmp/mpz/set_f.c | 64 ---- gnu/lib/libgmp/mpz/set_q.c | 36 -- gnu/lib/libgmp/mpz/set_si.c | 48 --- gnu/lib/libgmp/mpz/set_str.c | 132 ------- gnu/lib/libgmp/mpz/set_ui.c | 43 --- gnu/lib/libgmp/mpz/setbit.c | 113 ------ gnu/lib/libgmp/mpz/size.c | 35 -- gnu/lib/libgmp/mpz/sizeinbase.c | 60 ---- gnu/lib/libgmp/mpz/sqrt.c | 85 ----- gnu/lib/libgmp/mpz/sqrtrem.c | 107 ------ gnu/lib/libgmp/mpz/sub.c | 120 ------- gnu/lib/libgmp/mpz/sub_ui.c | 84 ----- gnu/lib/libgmp/mpz/tdiv_q.c | 133 -------- gnu/lib/libgmp/mpz/tdiv_q_2exp.c | 68 ---- gnu/lib/libgmp/mpz/tdiv_q_ui.c | 63 ---- gnu/lib/libgmp/mpz/tdiv_qr.c | 39 --- gnu/lib/libgmp/mpz/tdiv_qr_ui.c | 78 ----- gnu/lib/libgmp/mpz/tdiv_r.c | 37 -- gnu/lib/libgmp/mpz/tdiv_r_2exp.c | 79 ----- gnu/lib/libgmp/mpz/tdiv_r_ui.c | 64 ---- gnu/lib/libgmp/mpz/tests/Makefile.in | 126 ------- gnu/lib/libgmp/mpz/tests/configure.in | 11 - gnu/lib/libgmp/mpz/tests/convert.c | 80 ----- gnu/lib/libgmp/mpz/tests/dive.c | 87 ----- gnu/lib/libgmp/mpz/tests/io-binary.c | 76 ----- gnu/lib/libgmp/mpz/tests/io.c | 86 ----- gnu/lib/libgmp/mpz/tests/logic.c | 103 ------ gnu/lib/libgmp/mpz/tests/reuse.c | 135 -------- gnu/lib/libgmp/mpz/tests/t-fdiv.c | 118 ------- gnu/lib/libgmp/mpz/tests/t-fdiv_ui.c | 117 ------- gnu/lib/libgmp/mpz/tests/t-gcd.c | 132 ------- gnu/lib/libgmp/mpz/tests/t-gcd2.c | 137 -------- gnu/lib/libgmp/mpz/tests/t-mul.c | 261 -------------- gnu/lib/libgmp/mpz/tests/t-powm.c | 125 ------- gnu/lib/libgmp/mpz/tests/t-powm_ui.c | 120 ------- gnu/lib/libgmp/mpz/tests/t-sqrtrem.c | 98 ------ gnu/lib/libgmp/mpz/tests/t-tdiv.c | 118 ------- gnu/lib/libgmp/mpz/tests/t-tdiv_ui.c | 117 ------- gnu/lib/libgmp/mpz/ui_pow_ui.c | 111 ------ gnu/lib/libgmp/tests/Makefile | 66 ---- gnu/lib/libgmp/tests/Makefile.GNU | 64 ---- gnu/lib/libgmp/tests/tst-convert.c | 80 ----- gnu/lib/libgmp/tests/tst-dm.c | 117 ------- gnu/lib/libgmp/tests/tst-dm_ui.c | 116 ------- gnu/lib/libgmp/tests/tst-gcd.c | 131 ------- gnu/lib/libgmp/tests/tst-mdm.c | 117 ------- gnu/lib/libgmp/tests/tst-mdm_ui.c | 116 ------- gnu/lib/libgmp/tests/tst-mul.c | 261 -------------- gnu/lib/libgmp/tests/tst-pow_ui.c | 120 ------- gnu/lib/libgmp/tests/tst-sqrtrem.c | 97 ------ gnu/lib/libgmp/tests/urandom.h | 17 - 295 files changed, 28803 deletions(-) delete mode 100644 gnu/lib/libgmp/config/mt-linux delete mode 100644 gnu/lib/libgmp/config/mt-m88110 delete mode 100644 gnu/lib/libgmp/config/mt-sprc8-gcc delete mode 100644 gnu/lib/libgmp/config/mt-supspc-gcc delete mode 100644 gnu/lib/libgmp/demos/factorize.c delete mode 100644 gnu/lib/libgmp/doc/Makefile delete mode 100644 gnu/lib/libgmp/mpbsd/Makefile.in delete mode 100644 gnu/lib/libgmp/mpbsd/configure.in delete mode 100644 gnu/lib/libgmp/mpbsd/itom.c delete mode 100644 gnu/lib/libgmp/mpbsd/mdiv.c delete mode 100644 gnu/lib/libgmp/mpbsd/mfree.c delete mode 100644 gnu/lib/libgmp/mpbsd/min.c delete mode 100644 gnu/lib/libgmp/mpbsd/mout.c delete mode 100644 gnu/lib/libgmp/mpbsd/move.c delete mode 100644 gnu/lib/libgmp/mpbsd/mtox.c delete mode 100644 gnu/lib/libgmp/mpbsd/realloc.c delete mode 100644 gnu/lib/libgmp/mpbsd/sdiv.c delete mode 100644 gnu/lib/libgmp/mpbsd/xtom.c delete mode 100644 gnu/lib/libgmp/mpf/Makefile.in delete mode 100644 gnu/lib/libgmp/mpf/abs.c delete mode 100644 gnu/lib/libgmp/mpf/add.c delete mode 100644 gnu/lib/libgmp/mpf/add_ui.c delete mode 100644 gnu/lib/libgmp/mpf/clear.c delete mode 100644 gnu/lib/libgmp/mpf/cmp.c delete mode 100644 gnu/lib/libgmp/mpf/cmp_si.c delete mode 100644 gnu/lib/libgmp/mpf/cmp_ui.c delete mode 100644 gnu/lib/libgmp/mpf/configure.in delete mode 100644 gnu/lib/libgmp/mpf/div.c delete mode 100644 gnu/lib/libgmp/mpf/div_2exp.c delete mode 100644 gnu/lib/libgmp/mpf/div_ui.c delete mode 100644 gnu/lib/libgmp/mpf/dump.c delete mode 100644 gnu/lib/libgmp/mpf/eq.c delete mode 100644 gnu/lib/libgmp/mpf/get_d.c delete mode 100644 gnu/lib/libgmp/mpf/get_prc.c delete mode 100644 gnu/lib/libgmp/mpf/get_str.c delete mode 100644 gnu/lib/libgmp/mpf/init.c delete mode 100644 gnu/lib/libgmp/mpf/init2.c delete mode 100644 gnu/lib/libgmp/mpf/inp_str.c delete mode 100644 gnu/lib/libgmp/mpf/iset.c delete mode 100644 gnu/lib/libgmp/mpf/iset_d.c delete mode 100644 gnu/lib/libgmp/mpf/iset_si.c delete mode 100644 gnu/lib/libgmp/mpf/iset_str.c delete mode 100644 gnu/lib/libgmp/mpf/iset_ui.c delete mode 100644 gnu/lib/libgmp/mpf/mul.c delete mode 100644 gnu/lib/libgmp/mpf/mul_2exp.c delete mode 100644 gnu/lib/libgmp/mpf/mul_ui.c delete mode 100644 gnu/lib/libgmp/mpf/neg.c delete mode 100644 gnu/lib/libgmp/mpf/out_str.c delete mode 100644 gnu/lib/libgmp/mpf/random2.c delete mode 100644 gnu/lib/libgmp/mpf/reldiff.c delete mode 100644 gnu/lib/libgmp/mpf/set.c delete mode 100644 gnu/lib/libgmp/mpf/set_d.c delete mode 100644 gnu/lib/libgmp/mpf/set_dfl_prec.c delete mode 100644 gnu/lib/libgmp/mpf/set_prc.c delete mode 100644 gnu/lib/libgmp/mpf/set_prc_raw.c delete mode 100644 gnu/lib/libgmp/mpf/set_q.c delete mode 100644 gnu/lib/libgmp/mpf/set_si.c delete mode 100644 gnu/lib/libgmp/mpf/set_str.c delete mode 100644 gnu/lib/libgmp/mpf/set_ui.c delete mode 100644 gnu/lib/libgmp/mpf/set_z.c delete mode 100644 gnu/lib/libgmp/mpf/size.c delete mode 100644 gnu/lib/libgmp/mpf/sqrt.c delete mode 100644 gnu/lib/libgmp/mpf/sqrt_ui.c delete mode 100644 gnu/lib/libgmp/mpf/sub.c delete mode 100644 gnu/lib/libgmp/mpf/sub_ui.c delete mode 100644 gnu/lib/libgmp/mpf/tests/Makefile.in delete mode 100644 gnu/lib/libgmp/mpf/tests/configure.in delete mode 100644 gnu/lib/libgmp/mpf/tests/ref.c delete mode 100644 gnu/lib/libgmp/mpf/tests/reuse.c delete mode 100644 gnu/lib/libgmp/mpf/tests/t-add.c delete mode 100644 gnu/lib/libgmp/mpf/tests/t-conv.c delete mode 100644 gnu/lib/libgmp/mpf/tests/t-dm2exp.c delete mode 100644 gnu/lib/libgmp/mpf/tests/t-muldiv.c delete mode 100644 gnu/lib/libgmp/mpf/tests/t-sqrt.c delete mode 100644 gnu/lib/libgmp/mpf/tests/t-sub.c delete mode 100644 gnu/lib/libgmp/mpf/ui_div.c delete mode 100644 gnu/lib/libgmp/mpf/ui_sub.c delete mode 100644 gnu/lib/libgmp/mpn/Makefile.in delete mode 100644 gnu/lib/libgmp/mpn/README delete mode 100644 gnu/lib/libgmp/mpn/bsd.h delete mode 100644 gnu/lib/libgmp/mpn/config/t-oldgas delete mode 100644 gnu/lib/libgmp/mpn/config/t-ppc-aix delete mode 100644 gnu/lib/libgmp/mpn/config/t-pwr-aix delete mode 100644 gnu/lib/libgmp/mpn/configure.in delete mode 100644 gnu/lib/libgmp/mpn/generic/add_n.c delete mode 100644 gnu/lib/libgmp/mpn/generic/addmul_1.c delete mode 100644 gnu/lib/libgmp/mpn/generic/bdivmod.c delete mode 100644 gnu/lib/libgmp/mpn/generic/cmp.c delete mode 100644 gnu/lib/libgmp/mpn/generic/divmod_1.c delete mode 100644 gnu/lib/libgmp/mpn/generic/divrem.c delete mode 100644 gnu/lib/libgmp/mpn/generic/divrem_1.c delete mode 100644 gnu/lib/libgmp/mpn/generic/dump.c delete mode 100644 gnu/lib/libgmp/mpn/generic/gcd.c delete mode 100644 gnu/lib/libgmp/mpn/generic/gcd_1.c delete mode 100644 gnu/lib/libgmp/mpn/generic/gcdext.c delete mode 100644 gnu/lib/libgmp/mpn/generic/get_str.c delete mode 100644 gnu/lib/libgmp/mpn/generic/gmp-mparam.h delete mode 100644 gnu/lib/libgmp/mpn/generic/hamdist.c delete mode 100644 gnu/lib/libgmp/mpn/generic/inlines.c delete mode 100644 gnu/lib/libgmp/mpn/generic/lshift.c delete mode 100644 gnu/lib/libgmp/mpn/generic/mod_1.c delete mode 100644 gnu/lib/libgmp/mpn/generic/mul.c delete mode 100644 gnu/lib/libgmp/mpn/generic/mul_1.c delete mode 100644 gnu/lib/libgmp/mpn/generic/mul_n.c delete mode 100644 gnu/lib/libgmp/mpn/generic/perfsqr.c delete mode 100644 gnu/lib/libgmp/mpn/generic/popcount.c delete mode 100644 gnu/lib/libgmp/mpn/generic/pre_mod_1.c delete mode 100644 gnu/lib/libgmp/mpn/generic/random2.c delete mode 100644 gnu/lib/libgmp/mpn/generic/rshift.c delete mode 100644 gnu/lib/libgmp/mpn/generic/scan0.c delete mode 100644 gnu/lib/libgmp/mpn/generic/scan1.c delete mode 100644 gnu/lib/libgmp/mpn/generic/set_str.c delete mode 100644 gnu/lib/libgmp/mpn/generic/sqrtrem.c delete mode 100644 gnu/lib/libgmp/mpn/generic/sub_n.c delete mode 100644 gnu/lib/libgmp/mpn/generic/submul_1.c delete mode 100644 gnu/lib/libgmp/mpn/generic/udiv_w_sdiv.c delete mode 100644 gnu/lib/libgmp/mpn/mp_bases.c delete mode 100644 gnu/lib/libgmp/mpn/tests/add_n.c delete mode 100644 gnu/lib/libgmp/mpn/tests/addmul_1.c delete mode 100644 gnu/lib/libgmp/mpn/tests/divmod_1.c delete mode 100644 gnu/lib/libgmp/mpn/tests/divrem.c delete mode 100644 gnu/lib/libgmp/mpn/tests/lshift.c delete mode 100644 gnu/lib/libgmp/mpn/tests/mul_1.c delete mode 100644 gnu/lib/libgmp/mpn/tests/rshift.c delete mode 100644 gnu/lib/libgmp/mpn/tests/sub_n.c delete mode 100644 gnu/lib/libgmp/mpn/tests/submul_1.c delete mode 100644 gnu/lib/libgmp/mpn/tests/tst-addsub.c delete mode 100644 gnu/lib/libgmp/mpn/x86/add_n.S delete mode 100644 gnu/lib/libgmp/mpn/x86/addmul_1.S delete mode 100644 gnu/lib/libgmp/mpn/x86/lshift.S delete mode 100644 gnu/lib/libgmp/mpn/x86/mul_1.S delete mode 100644 gnu/lib/libgmp/mpn/x86/pentium/README delete mode 100644 gnu/lib/libgmp/mpn/x86/pentium/add_n.S delete mode 100644 gnu/lib/libgmp/mpn/x86/pentium/addmul_1.S delete mode 100644 gnu/lib/libgmp/mpn/x86/pentium/lshift.S delete mode 100644 gnu/lib/libgmp/mpn/x86/pentium/mul_1.S delete mode 100644 gnu/lib/libgmp/mpn/x86/pentium/rshift.S delete mode 100644 gnu/lib/libgmp/mpn/x86/pentium/sub_n.S delete mode 100644 gnu/lib/libgmp/mpn/x86/pentium/submul_1.S delete mode 100644 gnu/lib/libgmp/mpn/x86/rshift.S delete mode 100644 gnu/lib/libgmp/mpn/x86/sub_n.S delete mode 100644 gnu/lib/libgmp/mpn/x86/submul_1.S delete mode 100644 gnu/lib/libgmp/mpn/x86/syntax.h delete mode 100644 gnu/lib/libgmp/mpq/Makefile.in delete mode 100644 gnu/lib/libgmp/mpq/add.c delete mode 100644 gnu/lib/libgmp/mpq/canonicalize.c delete mode 100644 gnu/lib/libgmp/mpq/clear.c delete mode 100644 gnu/lib/libgmp/mpq/cmp.c delete mode 100644 gnu/lib/libgmp/mpq/cmp_ui.c delete mode 100644 gnu/lib/libgmp/mpq/configure.in delete mode 100644 gnu/lib/libgmp/mpq/div.c delete mode 100644 gnu/lib/libgmp/mpq/equal.c delete mode 100644 gnu/lib/libgmp/mpq/get_d.c delete mode 100644 gnu/lib/libgmp/mpq/get_den.c delete mode 100644 gnu/lib/libgmp/mpq/get_num.c delete mode 100644 gnu/lib/libgmp/mpq/init.c delete mode 100644 gnu/lib/libgmp/mpq/inv.c delete mode 100644 gnu/lib/libgmp/mpq/mul.c delete mode 100644 gnu/lib/libgmp/mpq/neg.c delete mode 100644 gnu/lib/libgmp/mpq/set.c delete mode 100644 gnu/lib/libgmp/mpq/set_den.c delete mode 100644 gnu/lib/libgmp/mpq/set_num.c delete mode 100644 gnu/lib/libgmp/mpq/set_si.c delete mode 100644 gnu/lib/libgmp/mpq/set_ui.c delete mode 100644 gnu/lib/libgmp/mpq/set_z.c delete mode 100644 gnu/lib/libgmp/mpq/sub.c delete mode 100644 gnu/lib/libgmp/mpq/tests/Makefile.in delete mode 100644 gnu/lib/libgmp/mpq/tests/configure.in delete mode 100644 gnu/lib/libgmp/mpq/tests/t-cmp.c delete mode 100644 gnu/lib/libgmp/mpq/tests/t-cmp_ui.c delete mode 100644 gnu/lib/libgmp/mpq/tests/t-get_d.c delete mode 100644 gnu/lib/libgmp/mpz/Makefile.in delete mode 100644 gnu/lib/libgmp/mpz/abs.c delete mode 100644 gnu/lib/libgmp/mpz/add.c delete mode 100644 gnu/lib/libgmp/mpz/add_ui.c delete mode 100644 gnu/lib/libgmp/mpz/and.c delete mode 100644 gnu/lib/libgmp/mpz/array_init.c delete mode 100644 gnu/lib/libgmp/mpz/cdiv_q.c delete mode 100644 gnu/lib/libgmp/mpz/cdiv_q_ui.c delete mode 100644 gnu/lib/libgmp/mpz/cdiv_qr.c delete mode 100644 gnu/lib/libgmp/mpz/cdiv_qr_ui.c delete mode 100644 gnu/lib/libgmp/mpz/cdiv_r.c delete mode 100644 gnu/lib/libgmp/mpz/cdiv_r_ui.c delete mode 100644 gnu/lib/libgmp/mpz/cdiv_ui.c delete mode 100644 gnu/lib/libgmp/mpz/clear.c delete mode 100644 gnu/lib/libgmp/mpz/clrbit.c delete mode 100644 gnu/lib/libgmp/mpz/cmp.c delete mode 100644 gnu/lib/libgmp/mpz/cmp_si.c delete mode 100644 gnu/lib/libgmp/mpz/cmp_ui.c delete mode 100644 gnu/lib/libgmp/mpz/com.c delete mode 100644 gnu/lib/libgmp/mpz/configure.in delete mode 100644 gnu/lib/libgmp/mpz/divexact.c delete mode 100644 gnu/lib/libgmp/mpz/dmincl.c delete mode 100644 gnu/lib/libgmp/mpz/fac_ui.c delete mode 100644 gnu/lib/libgmp/mpz/fdiv_q.c delete mode 100644 gnu/lib/libgmp/mpz/fdiv_q_2exp.c delete mode 100644 gnu/lib/libgmp/mpz/fdiv_q_ui.c delete mode 100644 gnu/lib/libgmp/mpz/fdiv_qr.c delete mode 100644 gnu/lib/libgmp/mpz/fdiv_qr_ui.c delete mode 100644 gnu/lib/libgmp/mpz/fdiv_r.c delete mode 100644 gnu/lib/libgmp/mpz/fdiv_r_2exp.c delete mode 100644 gnu/lib/libgmp/mpz/fdiv_r_ui.c delete mode 100644 gnu/lib/libgmp/mpz/fdiv_ui.c delete mode 100644 gnu/lib/libgmp/mpz/gcd.c delete mode 100644 gnu/lib/libgmp/mpz/gcd_ui.c delete mode 100644 gnu/lib/libgmp/mpz/gcdext.c delete mode 100644 gnu/lib/libgmp/mpz/get_d.c delete mode 100644 gnu/lib/libgmp/mpz/get_si.c delete mode 100644 gnu/lib/libgmp/mpz/get_str.c delete mode 100644 gnu/lib/libgmp/mpz/get_ui.c delete mode 100644 gnu/lib/libgmp/mpz/getlimbn.c delete mode 100644 gnu/lib/libgmp/mpz/hamdist.c delete mode 100644 gnu/lib/libgmp/mpz/init.c delete mode 100644 gnu/lib/libgmp/mpz/inp_raw.c delete mode 100644 gnu/lib/libgmp/mpz/inp_str.c delete mode 100644 gnu/lib/libgmp/mpz/invert.c delete mode 100644 gnu/lib/libgmp/mpz/ior.c delete mode 100644 gnu/lib/libgmp/mpz/iset.c delete mode 100644 gnu/lib/libgmp/mpz/iset_d.c delete mode 100644 gnu/lib/libgmp/mpz/iset_si.c delete mode 100644 gnu/lib/libgmp/mpz/iset_str.c delete mode 100644 gnu/lib/libgmp/mpz/iset_ui.c delete mode 100644 gnu/lib/libgmp/mpz/jacobi.c delete mode 100644 gnu/lib/libgmp/mpz/legendre.c delete mode 100644 gnu/lib/libgmp/mpz/mod.c delete mode 100644 gnu/lib/libgmp/mpz/mul.c delete mode 100644 gnu/lib/libgmp/mpz/mul_2exp.c delete mode 100644 gnu/lib/libgmp/mpz/mul_ui.c delete mode 100644 gnu/lib/libgmp/mpz/neg.c delete mode 100644 gnu/lib/libgmp/mpz/out_raw.c delete mode 100644 gnu/lib/libgmp/mpz/out_str.c delete mode 100644 gnu/lib/libgmp/mpz/perfsqr.c delete mode 100644 gnu/lib/libgmp/mpz/popcount.c delete mode 100644 gnu/lib/libgmp/mpz/pow_ui.c delete mode 100644 gnu/lib/libgmp/mpz/powm.c delete mode 100644 gnu/lib/libgmp/mpz/powm_ui.c delete mode 100644 gnu/lib/libgmp/mpz/pprime_p.c delete mode 100644 gnu/lib/libgmp/mpz/random.c delete mode 100644 gnu/lib/libgmp/mpz/random2.c delete mode 100644 gnu/lib/libgmp/mpz/realloc.c delete mode 100644 gnu/lib/libgmp/mpz/scan0.c delete mode 100644 gnu/lib/libgmp/mpz/scan1.c delete mode 100644 gnu/lib/libgmp/mpz/set.c delete mode 100644 gnu/lib/libgmp/mpz/set_d.c delete mode 100644 gnu/lib/libgmp/mpz/set_f.c delete mode 100644 gnu/lib/libgmp/mpz/set_q.c delete mode 100644 gnu/lib/libgmp/mpz/set_si.c delete mode 100644 gnu/lib/libgmp/mpz/set_str.c delete mode 100644 gnu/lib/libgmp/mpz/set_ui.c delete mode 100644 gnu/lib/libgmp/mpz/setbit.c delete mode 100644 gnu/lib/libgmp/mpz/size.c delete mode 100644 gnu/lib/libgmp/mpz/sizeinbase.c delete mode 100644 gnu/lib/libgmp/mpz/sqrt.c delete mode 100644 gnu/lib/libgmp/mpz/sqrtrem.c delete mode 100644 gnu/lib/libgmp/mpz/sub.c delete mode 100644 gnu/lib/libgmp/mpz/sub_ui.c delete mode 100644 gnu/lib/libgmp/mpz/tdiv_q.c delete mode 100644 gnu/lib/libgmp/mpz/tdiv_q_2exp.c delete mode 100644 gnu/lib/libgmp/mpz/tdiv_q_ui.c delete mode 100644 gnu/lib/libgmp/mpz/tdiv_qr.c delete mode 100644 gnu/lib/libgmp/mpz/tdiv_qr_ui.c delete mode 100644 gnu/lib/libgmp/mpz/tdiv_r.c delete mode 100644 gnu/lib/libgmp/mpz/tdiv_r_2exp.c delete mode 100644 gnu/lib/libgmp/mpz/tdiv_r_ui.c delete mode 100644 gnu/lib/libgmp/mpz/tests/Makefile.in delete mode 100644 gnu/lib/libgmp/mpz/tests/configure.in delete mode 100644 gnu/lib/libgmp/mpz/tests/convert.c delete mode 100644 gnu/lib/libgmp/mpz/tests/dive.c delete mode 100644 gnu/lib/libgmp/mpz/tests/io-binary.c delete mode 100644 gnu/lib/libgmp/mpz/tests/io.c delete mode 100644 gnu/lib/libgmp/mpz/tests/logic.c delete mode 100644 gnu/lib/libgmp/mpz/tests/reuse.c delete mode 100644 gnu/lib/libgmp/mpz/tests/t-fdiv.c delete mode 100644 gnu/lib/libgmp/mpz/tests/t-fdiv_ui.c delete mode 100644 gnu/lib/libgmp/mpz/tests/t-gcd.c delete mode 100644 gnu/lib/libgmp/mpz/tests/t-gcd2.c delete mode 100644 gnu/lib/libgmp/mpz/tests/t-mul.c delete mode 100644 gnu/lib/libgmp/mpz/tests/t-powm.c delete mode 100644 gnu/lib/libgmp/mpz/tests/t-powm_ui.c delete mode 100644 gnu/lib/libgmp/mpz/tests/t-sqrtrem.c delete mode 100644 gnu/lib/libgmp/mpz/tests/t-tdiv.c delete mode 100644 gnu/lib/libgmp/mpz/tests/t-tdiv_ui.c delete mode 100644 gnu/lib/libgmp/mpz/ui_pow_ui.c delete mode 100644 gnu/lib/libgmp/tests/Makefile delete mode 100644 gnu/lib/libgmp/tests/Makefile.GNU delete mode 100644 gnu/lib/libgmp/tests/tst-convert.c delete mode 100644 gnu/lib/libgmp/tests/tst-dm.c delete mode 100644 gnu/lib/libgmp/tests/tst-dm_ui.c delete mode 100644 gnu/lib/libgmp/tests/tst-gcd.c delete mode 100644 gnu/lib/libgmp/tests/tst-mdm.c delete mode 100644 gnu/lib/libgmp/tests/tst-mdm_ui.c delete mode 100644 gnu/lib/libgmp/tests/tst-mul.c delete mode 100644 gnu/lib/libgmp/tests/tst-pow_ui.c delete mode 100644 gnu/lib/libgmp/tests/tst-sqrtrem.c delete mode 100644 gnu/lib/libgmp/tests/urandom.h (limited to 'gnu') diff --git a/gnu/lib/libgmp/config/mt-linux b/gnu/lib/libgmp/config/mt-linux deleted file mode 100644 index 476d8b5..0000000 --- a/gnu/lib/libgmp/config/mt-linux +++ /dev/null @@ -1 +0,0 @@ -AR_FLAGS = qc diff --git a/gnu/lib/libgmp/config/mt-m88110 b/gnu/lib/libgmp/config/mt-m88110 deleted file mode 100644 index 071f8fa..0000000 --- a/gnu/lib/libgmp/config/mt-m88110 +++ /dev/null @@ -1 +0,0 @@ -XCFLAGS = -m88110 diff --git a/gnu/lib/libgmp/config/mt-sprc8-gcc b/gnu/lib/libgmp/config/mt-sprc8-gcc deleted file mode 100644 index bc706a9..0000000 --- a/gnu/lib/libgmp/config/mt-sprc8-gcc +++ /dev/null @@ -1 +0,0 @@ -XCFLAGS = -mv8 diff --git a/gnu/lib/libgmp/config/mt-supspc-gcc b/gnu/lib/libgmp/config/mt-supspc-gcc deleted file mode 100644 index 92a0924..0000000 --- a/gnu/lib/libgmp/config/mt-supspc-gcc +++ /dev/null @@ -1 +0,0 @@ -XCFLAGS = -mv8 -DSUPERSPARC diff --git a/gnu/lib/libgmp/demos/factorize.c b/gnu/lib/libgmp/demos/factorize.c deleted file mode 100644 index 4a965d3..0000000 --- a/gnu/lib/libgmp/demos/factorize.c +++ /dev/null @@ -1,233 +0,0 @@ -/* Factoring with Pollard's rho method. - - Copyright (C) 1995 Free Software Foundation, Inc. - -This program is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 2, or (at your option) any -later version. - -This program 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 -General Public License for more details. - -You should have received a copy of the GNU General Public License along -with this program; see the file COPYING. If not, write to the Free Software -Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#include -#include "gmp.h" - -int flag_mersenne = 0; - -static unsigned add[] = {4, 2, 4, 2, 4, 6, 2, 6}; - -factor_using_division (t, limit) - mpz_t t; - unsigned int limit; -{ - mpz_t q, r; - unsigned long int f; - int i, ai; - unsigned *addv = add; - - mpz_init (q); - mpz_init (r); - - if (mpz_probab_prime_p (t, 50)) - goto ready; - - for (;;) - { - mpz_tdiv_qr_ui (q, r, t, 2); - if (mpz_cmp_ui (r, 0) != 0) - break; - mpz_set (t, q); - printf ("2 "); - fflush (stdout); - if (mpz_probab_prime_p (t, 50)) - goto ready; - } - - for (;;) - { - mpz_tdiv_qr_ui (q, r, t, 3); - if (mpz_cmp_ui (r, 0) != 0) - break; - mpz_set (t, q); - printf ("3 "); - fflush (stdout); - if (mpz_probab_prime_p (t, 50)) - goto ready; - } - - for (;;) - { - mpz_tdiv_qr_ui (q, r, t, 5); - if (mpz_cmp_ui (r, 0) != 0) - break; - mpz_set (t, q); - printf ("5 "); - fflush (stdout); - if (mpz_probab_prime_p (t, 50)) - goto ready; - } - - f = 7; - ai = 0; - for (;;) - { - mpz_tdiv_qr_ui (q, r, t, f); - if (mpz_cmp_ui (r, 0) != 0) - { - f += addv[ai]; - if (f > limit) - goto ret; - ai = (ai + 1) & 7; - } - else - { - mpz_set (t, q); - printf ("%lu ", f); - fflush (stdout); - if (mpz_probab_prime_p (t, 50)) - goto ready; - } - } - - ready: - mpz_out_str (stdout, 10, t); - fflush (stdout); - mpz_set_ui (t, 1); - fputc (' ', stdout); - ret: - mpz_clear (q); - mpz_clear (r); -} - -void -factor_using_pollard_rho (m, a_int, x0, p) - mpz_t m; - long a_int; - long x0; - unsigned long p; -{ - mpz_t x, y, q; - mpz_t a; - mpz_t d; - mpz_t tmp; - mpz_t n; - int i = 1; - int j = 1; - - mpz_init_set (n, m); - - mpz_init (d); - mpz_init_set_ui (q, 1); - mpz_init (tmp); - - mpz_init_set_si (a, a_int); - mpz_init_set_si (x, x0); - mpz_init_set_si (y, x0); - - while (mpz_cmp_ui (n, 1) != 0) - { - if (flag_mersenne) - { - mpz_powm_ui (x, x, p, n); mpz_add (x, x, a); - mpz_powm_ui (y, y, p, n); mpz_add (y, y, a); - mpz_powm_ui (y, y, p, n); mpz_add (y, y, a); - } - else - { - mpz_mul (x, x, x); mpz_add (x, x, a); mpz_mod (x, x, n); - mpz_mul (y, y, y); mpz_add (y, y, a); mpz_mod (y, y, n); - mpz_mul (y, y, y); mpz_add (y, y, a); mpz_mod (y, y, n); - } - - if (mpz_cmp (x, y) > 0) - mpz_sub (tmp, x, y); - else - mpz_sub (tmp, y, x); - mpz_mul (q, q, tmp); - mpz_mod (q, q, n); - - if (++i % j == 0) - { - j += 1; - mpz_gcd (d, q, n); - if (mpz_cmp_ui (d, 1) != 0) - { - if (!mpz_probab_prime_p (d, 50)) - factor_using_pollard_rho (d, (random () & 31) - 16, - (random () & 31), p); - else - { - mpz_out_str (stdout, 10, d); - fflush (stdout); - fputc (' ', stdout); - } - mpz_div (n, n, d); - if (mpz_probab_prime_p (n, 50)) - { - mpz_out_str (stdout, 10, n); - fflush (stdout); - fputc (' ', stdout); - break; - } - } - } - } - - mpz_clear (n); - mpz_clear (d); - mpz_clear (q); - mpz_clear (tmp); - mpz_clear (a); - mpz_clear (x); - mpz_clear (y); -} - -factor (t, a, x0, p) - mpz_t t; - long a; - long x0; - unsigned long p; -{ - factor_using_division (t, 1000000); - factor_using_pollard_rho (t, a, x0, p); -} - -main (argc, argv) - int argc; - char *argv[]; -{ - mpz_t t; - long x0, a; - unsigned long p; - int i; - - for (i = 1; i < argc; i++) - { - if (!strncmp (argv[i], "-Mp", 3)) - { - p = atoi (argv[i] + 3); - mpz_init_set_ui (t, 1); - mpz_mul_2exp (t, t, p); - mpz_sub_ui (t, t, 1); - flag_mersenne = 1; - } - else - { - p = 0; - mpz_init_set_str (t, argv[i], 0); - } - - a = -1; - x0 = 3; - - factor (t, a, x0, p); - puts (""); - } -} diff --git a/gnu/lib/libgmp/doc/Makefile b/gnu/lib/libgmp/doc/Makefile deleted file mode 100644 index 3d1f0fe..0000000 --- a/gnu/lib/libgmp/doc/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# $Id$ - -INFO= gmp - -.PATH: ${.CURDIR}/.. - -.include diff --git a/gnu/lib/libgmp/mpbsd/Makefile.in b/gnu/lib/libgmp/mpbsd/Makefile.in deleted file mode 100644 index a517c1a..0000000 --- a/gnu/lib/libgmp/mpbsd/Makefile.in +++ /dev/null @@ -1,84 +0,0 @@ -# Makefile for GNU MP/mpbsd functions -# Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -# the Free Software Foundation; either version 2 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 Library General Public -# License for more details. - -# You should have received a copy of the GNU Library General Public License -# along with the GNU MP Library; see the file COPYING.LIB. If not, write to -# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA. - -srcdir = . - -CC = gcc - -# If you cross compile on a machine with the same sizes of the integral -# types ("int", "long int", "short int", and "char") define this as the -# local compiler. Otherwise, you need to look for the uses of LOCAL_CC below, -# and handle those cases manually. -LOCAL_CC = $(CC) -CFLAGS = -g -O -AR = ar -SHELL = /bin/sh - -#### host and target specific makefile fragments come in here. -### - -MPBSD_LINKS = add.c cmp.c gcd.c mul.c pow_ui.c powm.c sqrtrem.c sub.c -MPBSD_SRCS = itom.c mdiv.c mfree.c min.c mout.c move.c mtox.c sdiv.c xtom.c \ - realloc.c $(MPBSD_LINKS) - -MPBSD_OBJS = itom.o mdiv.o mfree.o min.o mout.o move.o mtox.o sdiv.o xtom.o \ - realloc.o add.o cmp.o gcd.o mul.o pow_ui.o powm.o sqrtrem.o sub.o - -INCLUDES = -I. -I.. -I$(srcdir)/../mpz -I../mpn -I$(srcdir)/.. - -libmpbsd.a: Makefile.in $(MPBSD_OBJS) - rm -f $@ - $(AR) cr $@ $(MPBSD_OBJS) - -.c.o: - $(CC) -c $(INCLUDES) -DBERKELEY_MP $(CFLAGS) $(XCFLAGS) $< - -check: - true - -clean mostlyclean: - rm -f *.o libmpbsd.a -distclean maintainer-clean: clean - rm -f Makefile config.status $(MPBSD_LINKS) - -Makefile: $(srcdir)/Makefile.in - $(SHELL) ./config.status - -H = $(srcdir)/../gmp.h $(srcdir)/../gmp-impl.h ../mpn/gmp-mparam.h -L = $(srcdir)/../longlong.h - -itom.o: $(srcdir)/itom.c ../mp.h $(H) -mdiv.o: $(srcdir)/mdiv.c ../mp.h $(H) $(L) $(srcdir)/../mpz/dmincl.c -mfree.o: $(srcdir)/mfree.c ../mp.h $(H) -min.o: $(srcdir)/min.c ../mp.h $(H) -mout.o: $(srcdir)/mout.c ../mp.h $(H) -move.o: $(srcdir)/move.c ../mp.h $(H) -mtox.o: $(srcdir)/mtox.c ../mp.h $(H) -sdiv.o: $(srcdir)/sdiv.c ../mp.h $(H) $(L) -xtom.o: $(srcdir)/xtom.c ../mp.h $(H) -add.o: $(srcdir)/../mpz/add.c $(H) -cmp.o: $(srcdir)/../mpz/cmp.c $(H) -gcd.o: $(srcdir)/../mpz/gcd.c $(H) $(L) -mul.o: $(srcdir)/../mpz/mul.c $(H) -pow_ui.o: $(srcdir)/../mpz/pow_ui.c $(H) $(L) -powm.o: $(srcdir)/../mpz/powm.c $(H) $(L) -realloc.o: $(srcdir)/realloc.c $(H) -sqrtrem.o: $(srcdir)/../mpz/sqrtrem.c $(H) -sub.o: $(srcdir)/../mpz/sub.c $(H) diff --git a/gnu/lib/libgmp/mpbsd/configure.in b/gnu/lib/libgmp/mpbsd/configure.in deleted file mode 100644 index ec22075..0000000 --- a/gnu/lib/libgmp/mpbsd/configure.in +++ /dev/null @@ -1,20 +0,0 @@ -# This file is a shell script fragment that supplies the information -# necessary for a configure script to process the program in -# this directory. For more information, look at ../configure. - -configdirs= -srctrigger=itom.c -srcname="GNU Multi-Precision library/mpbsd" - -# per-host: - -# per-target: - -mpzfiles="add.c cmp.c gcd.c mul.c pow_ui.c powm.c sqrtrem.c sub.c" - -for fn in $mpzfiles - do - rm -f $fn - files="$files ../mpz/$fn" - links="$links $fn" - done diff --git a/gnu/lib/libgmp/mpbsd/itom.c b/gnu/lib/libgmp/mpbsd/itom.c deleted file mode 100644 index 719a4dc..0000000 --- a/gnu/lib/libgmp/mpbsd/itom.c +++ /dev/null @@ -1,54 +0,0 @@ -/* itom -- BSD compatible allocate and initiate a MINT. - -Copyright (C) 1991, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" - -MINT * -#if __STDC__ -itom (signed short int n) -#else -itom (n) - short int n; -#endif -{ - MINT *x; - mp_ptr xp; - - x = (MINT *) (*_mp_allocate_func) (sizeof (MINT)); - x->_mp_alloc = 1; - x->_mp_d = xp = (mp_ptr) (*_mp_allocate_func) (BYTES_PER_MP_LIMB); - if (n > 0) - { - x->_mp_size = 1; - xp[0] = n; - } - else if (n < 0) - { - x->_mp_size = -1; - xp[0] = -n; - } - else - x->_mp_size = 0; - - return x; -} diff --git a/gnu/lib/libgmp/mpbsd/mdiv.c b/gnu/lib/libgmp/mpbsd/mdiv.c deleted file mode 100644 index 103c2c3..0000000 --- a/gnu/lib/libgmp/mpbsd/mdiv.c +++ /dev/null @@ -1,39 +0,0 @@ -/* mdiv -- BSD compatible divide producing both remainder and quotient. - -Copyright (C) 1991, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void -#if __STDC__ -mdiv (const MINT *num, const MINT *den, MINT *quot, MINT *rem) -#else -mdiv (num, den, quot, rem) - const MINT *num; - const MINT *den; - MINT *quot; - MINT *rem; -#endif - -#define COMPUTE_QUOTIENT -#include "dmincl.c" diff --git a/gnu/lib/libgmp/mpbsd/mfree.c b/gnu/lib/libgmp/mpbsd/mfree.c deleted file mode 100644 index ef931e3..0000000 --- a/gnu/lib/libgmp/mpbsd/mfree.c +++ /dev/null @@ -1,36 +0,0 @@ -/* mfree -- BSD compatible mfree. - -Copyright (C) 1991, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mfree (MINT *m) -#else -mfree (m) - MINT *m; -#endif -{ - (*_mp_free_func) (m->_mp_d, m->_mp_alloc * BYTES_PER_MP_LIMB); - (*_mp_free_func) (m, sizeof (MINT)); -} diff --git a/gnu/lib/libgmp/mpbsd/min.c b/gnu/lib/libgmp/mpbsd/min.c deleted file mode 100644 index 6edb171..0000000 --- a/gnu/lib/libgmp/mpbsd/min.c +++ /dev/null @@ -1,89 +0,0 @@ -/* min(MINT) -- Do decimal input from standard input and store result in - MINT. - -Copyright (C) 1991, 1994 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -min (MINT *dest) -#else -min (dest) - MINT *dest; -#endif -{ - char *str; - size_t alloc_size, str_size; - int c; - int negative; - mp_size_t dest_size; - - alloc_size = 100; - str = (char *) (*_mp_allocate_func) (alloc_size); - str_size = 0; - - /* Skip whitespace. */ - do - c = getc (stdin); - while (isspace (c)); - - negative = 0; - if (c == '-') - { - negative = 1; - c = getc (stdin); - } - - if (digit_value_in_base (c, 10) < 0) - return; /* error if no digits */ - - for (;;) - { - int dig; - if (str_size >= alloc_size) - { - size_t old_alloc_size = alloc_size; - alloc_size = alloc_size * 3 / 2; - str = (char *) (*_mp_reallocate_func) (str, old_alloc_size, alloc_size); - } - dig = digit_value_in_base (c, 10); - if (dig < 0) - break; - str[str_size++] = dig; - c = getc (stdin); - } - - ungetc (c, stdin); - - dest_size = str_size / __mp_bases[10].chars_per_limb + 1; - if (dest->_mp_alloc < dest_size) - _mp_realloc (dest, dest_size); - - dest_size = mpn_set_str (dest->_mp_d, (unsigned char *) str, str_size, 10); - dest->_mp_size = negative ? -dest_size : dest_size; - - (*_mp_free_func) (str, alloc_size); - return; -} diff --git a/gnu/lib/libgmp/mpbsd/mout.c b/gnu/lib/libgmp/mpbsd/mout.c deleted file mode 100644 index a6b62be..0000000 --- a/gnu/lib/libgmp/mpbsd/mout.c +++ /dev/null @@ -1,96 +0,0 @@ -/* mout(MINT) -- Do decimal output of MINT to standard output. - -Copyright (C) 1991, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mout (const MINT *x) -#else -mout (x) - const MINT *x; -#endif -{ - mp_ptr xp; - mp_size_t x_size = x->_mp_size; - unsigned char *str; - size_t str_size; - char *num_to_text; - int i; - TMP_DECL (marker); - - if (x_size == 0) - { - fputc ('0', stdout); - return; - } - if (x_size < 0) - { - fputc ('-', stdout); - x_size = -x_size; - } - - TMP_MARK (marker); - str_size = ((size_t) (x_size * BITS_PER_MP_LIMB - * __mp_bases[10].chars_per_bit_exactly)) + 3; - str = (unsigned char *) TMP_ALLOC (str_size); - - /* Move the number to convert into temporary space, since mpn_get_str - clobbers its argument + needs one extra high limb.... */ - xp = (mp_ptr) TMP_ALLOC ((x_size + 1) * BYTES_PER_MP_LIMB); - MPN_COPY (xp, x->_mp_d, x_size); - - str_size = mpn_get_str (str, 10, xp, x_size); - - /* mpn_get_str might make some leading zeros. Skip them. */ - while (*str == 0) - { - str_size--; - str++; - } - - /* Translate to printable chars. */ - for (i = 0; i < str_size; i++) - str[i] = "0123456789"[str[i]]; - str[str_size] = 0; - - str_size = strlen (str); - if (str_size % 10 != 0) - { - fwrite (str, 1, str_size % 10, stdout); - str += str_size % 10; - str_size -= str_size % 10; - if (str_size != 0) - fputc (' ', stdout); - } - for (i = 0; i < str_size; i += 10) - { - fwrite (str, 1, 10, stdout); - str += 10; - if (i + 10 < str_size) - fputc (' ', stdout); - } - fputc ('\n', stdout); - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpbsd/move.c b/gnu/lib/libgmp/mpbsd/move.c deleted file mode 100644 index 8256cc7..0000000 --- a/gnu/lib/libgmp/mpbsd/move.c +++ /dev/null @@ -1,46 +0,0 @@ -/* move -- BSD compatible assignment. - -Copyright (C) 1991, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -move (const MINT *u, MINT *w) -#else -move (u, w) - const MINT *u; - MINT *w; -#endif -{ - mp_size_t usize; - mp_size_t abs_usize; - - usize = u->_mp_size; - abs_usize = ABS (usize); - - if (w->_mp_alloc < abs_usize) - _mp_realloc (w, abs_usize); - - w->_mp_size = usize; - MPN_COPY (w->_mp_d, u->_mp_d, abs_usize); -} diff --git a/gnu/lib/libgmp/mpbsd/mtox.c b/gnu/lib/libgmp/mpbsd/mtox.c deleted file mode 100644 index 8baec2a..0000000 --- a/gnu/lib/libgmp/mpbsd/mtox.c +++ /dev/null @@ -1,81 +0,0 @@ -/* mtox -- Convert OPERAND to hexadecimal and return a malloc'ed string - with the result of the conversion. - -Copyright (C) 1991, 1994 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" - -char * -#if __STDC__ -mtox (const MINT *x) -#else -mtox (x) - const MINT *x; -#endif -{ - mp_ptr xp; - mp_size_t xsize = x->_mp_size; - mp_size_t xsign; - unsigned char *str, *s; - size_t str_size, i; - int zeros; - char *num_to_text; - TMP_DECL (marker); - - if (xsize == 0) - { - str = (unsigned char *) (*_mp_allocate_func) (2); - str[0] = '0'; - str[1] = 0; - return str; - } - xsign = xsize; - if (xsize < 0) - xsize = -xsize; - - TMP_MARK (marker); - str_size = ((size_t) (xsize * BITS_PER_MP_LIMB - * __mp_bases[16].chars_per_bit_exactly)) + 3; - str = (unsigned char *) (*_mp_allocate_func) (str_size); - s = str; - - if (xsign < 0) - *s++ = '-'; - - /* Move the number to convert into temporary space, since mpn_get_str - clobbers its argument + needs one extra high limb.... */ - xp = (mp_ptr) TMP_ALLOC ((xsize + 1) * BYTES_PER_MP_LIMB); - MPN_COPY (xp, x->_mp_d, xsize); - - str_size = mpn_get_str (s, 16, xp, xsize); - - /* mpn_get_str might make some leading zeros. Skip them. */ - for (zeros = 0; s[zeros] == 0; zeros++) - str_size--; - - /* Translate to printable chars and move string down. */ - for (i = 0; i < str_size; i++) - s[i] = "0123456789abcdef"[s[zeros + i]]; - s[str_size] = 0; - - return str; -} diff --git a/gnu/lib/libgmp/mpbsd/realloc.c b/gnu/lib/libgmp/mpbsd/realloc.c deleted file mode 100644 index 64bee76..0000000 --- a/gnu/lib/libgmp/mpbsd/realloc.c +++ /dev/null @@ -1,44 +0,0 @@ -/* _mp_realloc -- make the MINT* have NEW_SIZE digits allocated. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" - -void * -#if __STDC__ -_mp_realloc (MINT *m, mp_size_t new_size) -#else -_mp_realloc (m, new_size) - MINT *m; - mp_size_t new_size; -#endif -{ - /* Never allocate zero space. */ - if (new_size == 0) - new_size = 1; - - m->_mp_d = (mp_ptr) (*_mp_reallocate_func) (m->_mp_d, - m->_mp_alloc * BYTES_PER_MP_LIMB, - new_size * BYTES_PER_MP_LIMB); - m->_mp_alloc = new_size; - return (void *) m->_mp_d; -} diff --git a/gnu/lib/libgmp/mpbsd/sdiv.c b/gnu/lib/libgmp/mpbsd/sdiv.c deleted file mode 100644 index 6982e20..0000000 --- a/gnu/lib/libgmp/mpbsd/sdiv.c +++ /dev/null @@ -1,77 +0,0 @@ -/* sdiv -- Divide a MINT by a short integer. Produce a MINT quotient - and a short remainder. - -Copyright (C) 1991, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void -#if __STDC__ -sdiv (const MINT *dividend, signed short int divisor_short, MINT *quot, short *rem_ptr) -#else -sdiv (dividend, divisor_short, quot, rem_ptr) - const MINT *dividend; - short int divisor_short; - MINT *quot; - short *rem_ptr; -#endif -{ - mp_size_t sign_dividend; - signed long int sign_divisor; - mp_size_t dividend_size, quot_size; - mp_ptr dividend_ptr, quot_ptr; - mp_limb_t divisor_limb; - mp_limb_t remainder_limb; - - sign_dividend = dividend->_mp_size; - dividend_size = ABS (dividend->_mp_size); - - if (dividend_size == 0) - { - quot->_mp_size = 0; - *rem_ptr = 0; - return; - } - - sign_divisor = divisor_short; - divisor_limb = ABS (divisor_short); - - /* No need for temporary allocation and copying even if QUOT == DIVIDEND - as the divisor is just one limb, and thus no intermediate remainders - need to be stored. */ - - if (quot->_mp_alloc < dividend_size) - _mp_realloc (quot, dividend_size); - - quot_ptr = quot->_mp_d; - dividend_ptr = dividend->_mp_d; - - remainder_limb = mpn_divmod_1 (quot_ptr, - dividend_ptr, dividend_size, divisor_limb); - - *rem_ptr = sign_dividend >= 0 ? remainder_limb : -remainder_limb; - /* The quotient is DIVIDEND_SIZE limbs, but the most significant - might be zero. Set QUOT_SIZE properly. */ - quot_size = dividend_size - (quot_ptr[dividend_size - 1] == 0); - quot->_mp_size = (sign_divisor ^ sign_dividend) >= 0 ? quot_size : -quot_size; -} diff --git a/gnu/lib/libgmp/mpbsd/xtom.c b/gnu/lib/libgmp/mpbsd/xtom.c deleted file mode 100644 index 5a529e8..0000000 --- a/gnu/lib/libgmp/mpbsd/xtom.c +++ /dev/null @@ -1,110 +0,0 @@ -/* xtom -- convert a hexadecimal string to a MINT, and return a pointer to - the MINT. - -Copyright (C) 1991, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" - -static int -digit_value_in_base (c, base) - int c; - int base; -{ - int digit; - - if (isdigit (c)) - digit = c - '0'; - else if (islower (c)) - digit = c - 'a' + 10; - else if (isupper (c)) - digit = c - 'A' + 10; - else - return -1; - - if (digit < base) - return digit; - return -1; -} - -MINT * -#if __STDC__ -xtom (const char *str) -#else -xtom (str) - const char *str; -#endif -{ - size_t str_size; - char *s, *begs; - size_t i; - mp_size_t xsize; - int c; - int negative; - MINT *x = (MINT *) (*_mp_allocate_func) (sizeof (MINT)); - TMP_DECL (marker); - - /* Skip whitespace. */ - do - c = *str++; - while (isspace (c)); - - negative = 0; - if (c == '-') - { - negative = 1; - c = *str++; - } - - if (digit_value_in_base (c, 16) < 0) - return 0; /* error if no digits */ - - TMP_MARK (marker); - str_size = strlen (str - 1); - s = begs = (char *) TMP_ALLOC (str_size + 1); - - for (i = 0; i < str_size; i++) - { - if (!isspace (c)) - { - int dig = digit_value_in_base (c, 16); - if (dig < 0) - { - TMP_FREE (marker); - return 0; - } - *s++ = dig; - } - c = *str++; - } - - str_size = s - begs; - - xsize = str_size / __mp_bases[16].chars_per_limb + 1; - x->_mp_alloc = xsize; - x->_mp_d = (mp_ptr) (*_mp_allocate_func) (xsize * BYTES_PER_MP_LIMB); - - xsize = mpn_set_str (x->_mp_d, (unsigned char *) begs, str_size, 16); - x->_mp_size = negative ? -xsize : xsize; - - TMP_FREE (marker); - return x; -} diff --git a/gnu/lib/libgmp/mpf/Makefile.in b/gnu/lib/libgmp/mpf/Makefile.in deleted file mode 100644 index 598fa72..0000000 --- a/gnu/lib/libgmp/mpf/Makefile.in +++ /dev/null @@ -1,115 +0,0 @@ -# Makefile for GNU MP/mpf functions -# Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -# the Free Software Foundation; either version 2 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 Library General Public -# License for more details. - -# You should have received a copy of the GNU Library General Public License -# along with the GNU MP Library; see the file COPYING.LIB. If not, write to -# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA. - -srcdir = . - -CC = gcc - -CFLAGS = -g -O -AR = ar -AR_FLAGS = rc -SHELL = /bin/sh - -#### host and target specific makefile fragments come in here. -### - -MPF_SRCS = init.c init2.c set.c set_ui.c set_si.c set_str.c set_d.c set_z.c \ - iset.c iset_ui.c iset_si.c iset_str.c iset_d.c clear.c get_str.c \ - dump.c size.c eq.c reldiff.c sqrt.c random2.c inp_str.c out_str.c \ - add.c add_ui.c sub.c sub_ui.c ui_sub.c mul.c mul_ui.c div.c div_ui.c \ - cmp.c cmp_ui.c cmp_si.c mul_2exp.c div_2exp.c abs.c neg.c set_q.c get_d.c \ - set_dfl_prec.c set_prc.c set_prc_raw.c get_prc.c ui_div.c sqrt_ui.c -MPF_OBJS = init.o init2.o set.o set_ui.o set_si.o set_str.o set_d.o set_z.o \ - iset.o iset_ui.o iset_si.o iset_str.o iset_d.o clear.o get_str.o \ - dump.o size.o eq.o reldiff.o sqrt.o random2.o inp_str.o out_str.o \ - add.o add_ui.o sub.o sub_ui.o ui_sub.o mul.o mul_ui.o div.o div_ui.o \ - cmp.o cmp_ui.o cmp_si.o mul_2exp.o div_2exp.o abs.o neg.o set_q.o get_d.o \ - set_dfl_prec.o set_prc.o set_prc_raw.o get_prc.o ui_div.o sqrt_ui.o - -LATER_OBJS = inp_raw.o out_raw.o random.o pow_ui.o fac_ui.o - -INCLUDES = -I. -I.. -I../mpn -I$(srcdir)/.. - -libmpf.a: Makefile $(MPF_OBJS) - rm -f $@ - $(AR) $(AR_FLAGS) $@ $(MPF_OBJS) - -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(XCFLAGS) $< - -clean mostlyclean: - rm -f *.o libmpf.a - -cd tests; $(MAKE) $@ -distclean maintainer-clean: clean - rm -f Makefile config.status - -cd tests; $(MAKE) $@ - -Makefile: $(srcdir)/Makefile.in - $(SHELL) ./config.status - -H = $(srcdir)/../gmp.h $(srcdir)/../gmp-impl.h ../mpn/gmp-mparam.h - -abs.o: $(srcdir)/abs.c $(H) -add.o: $(srcdir)/add.c $(H) -add_ui.o: $(srcdir)/add_ui.c $(H) -clear.o: $(srcdir)/clear.c $(H) -cmp.o: $(srcdir)/cmp.c $(H) -cmp_si.o: $(srcdir)/cmp_si.c $(H) -cmp_ui.o: $(srcdir)/cmp_ui.c $(H) -eq.o: $(srcdir)/eq.c $(H) -div.o: $(srcdir)/div.c $(H) $(srcdir)/../longlong.h -div_2exp.o: $(srcdir)/div_2exp.c $(H) -div_ui.o: $(srcdir)/div_ui.c $(H) $(srcdir)/../longlong.h -dump.o: $(srcdir)/dump.c $(H) -get_d.o: $(srcdir)/get_d.c $(H) -get_prc.o: $(srcdir)/get_prc.c $(H) -get_str.o: $(srcdir)/get_str.c $(H) $(srcdir)/../longlong.h -init.o: $(srcdir)/init.c $(H) -init2.o: $(srcdir)/init2.c $(H) -inp_str.o: $(srcdir)/inp_str.c $(H) -iset.o: $(srcdir)/iset.c $(H) -iset_d.o: $(srcdir)/iset_d.c $(H) -iset_si.o: $(srcdir)/iset_si.c $(H) -iset_str.o: $(srcdir)/iset_str.c $(H) -iset_ui.o: $(srcdir)/iset_ui.c $(H) -mul.o: $(srcdir)/mul.c $(H) -mul_2exp.o: $(srcdir)/mul_2exp.c $(H) -mul_ui.o: $(srcdir)/mul_ui.c $(H) -neg.o: $(srcdir)/neg.c $(H) -out_str.o: $(srcdir)/out_str.c $(H) -random2.o: $(srcdir)/random2.c $(H) -reldiff.o: $(srcdir)/reldiff.c $(H) -set.o: $(srcdir)/set.c $(H) -set_d.o: $(srcdir)/set_d.c $(H) -set_dfl_prec.o: $(srcdir)/set_dfl_prec.c $(H) -set_prc.o: $(srcdir)/set_prc.c $(H) -set_prc_raw.o: $(srcdir)/set_prc_raw.c $(H) -set_q.o: $(srcdir)/set_q.c $(H) -set_si.o: $(srcdir)/set_si.c $(H) -set_str.o: $(srcdir)/set_str.c $(H) $(srcdir)/../longlong.h -set_ui.o: $(srcdir)/set_ui.c $(H) -set_z.o: $(srcdir)/set_z.c $(H) -size.o: $(srcdir)/size.c $(H) -sqrt.o: $(srcdir)/sqrt.c $(H) -sqrt_ui.o: $(srcdir)/sqrt_ui.c $(H) -sub.o: $(srcdir)/sub.c $(H) -sub_ui.o: $(srcdir)/sub_ui.c $(H) -ui_div.o: $(srcdir)/ui_div.c $(H) $(srcdir)/../longlong.h -ui_sub.o: $(srcdir)/ui_sub.c $(H) diff --git a/gnu/lib/libgmp/mpf/abs.c b/gnu/lib/libgmp/mpf/abs.c deleted file mode 100644 index 029007a..0000000 --- a/gnu/lib/libgmp/mpf/abs.c +++ /dev/null @@ -1,56 +0,0 @@ -/* mpf_abs -- Compute the absolute value of a float. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_abs (mpf_ptr r, mpf_srcptr u) -#else -mpf_abs (r, u) - mpf_ptr r; - mpf_srcptr u; -#endif -{ - mp_size_t size; - - size = ABS (u->_mp_size); - if (r != u) - { - mp_size_t prec; - mp_ptr rp, up; - - prec = r->_mp_prec + 1; /* lie not to lose precision in assignment */ - rp = r->_mp_d; - up = u->_mp_d; - - if (size > prec) - { - up += size - prec; - size = prec; - } - - MPN_COPY (rp, up, size); - r->_mp_exp = u->_mp_exp; - } - r->_mp_size = size; -} diff --git a/gnu/lib/libgmp/mpf/add.c b/gnu/lib/libgmp/mpf/add.c deleted file mode 100644 index 2db876f..0000000 --- a/gnu/lib/libgmp/mpf/add.c +++ /dev/null @@ -1,180 +0,0 @@ -/* mpf_add -- Add two floats. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_add (mpf_ptr r, mpf_srcptr u, mpf_srcptr v) -#else -mpf_add (r, u, v) - mpf_ptr r; - mpf_srcptr u; - mpf_srcptr v; -#endif -{ - mp_srcptr up, vp; - mp_ptr rp, tp; - mp_size_t usize, vsize, rsize; - mp_size_t prec; - mp_exp_t uexp; - mp_size_t ediff; - mp_limb_t cy; - int negate; - TMP_DECL (marker); - - usize = u->_mp_size; - vsize = v->_mp_size; - - /* Handle special cases that don't work in generic code below. */ - if (usize == 0) - { - mpf_set (r, v); - return; - } - if (vsize == 0) - { - mpf_set (r, u); - return; - } - - /* If signs of U and V are different, perform subtraction. */ - if ((usize ^ vsize) < 0) - { - __mpf_struct v_negated; - v_negated._mp_size = -vsize; - v_negated._mp_exp = v->_mp_exp; - v_negated._mp_d = v->_mp_d; - mpf_sub (r, u, &v_negated); - return; - } - - TMP_MARK (marker); - - /* Signs are now known to be the same. */ - negate = usize < 0; - - /* Make U be the operand with the largest exponent. */ - if (u->_mp_exp < v->_mp_exp) - { - mpf_srcptr t; - t = u; u = v; v = t; - usize = u->_mp_size; - vsize = v->_mp_size; - } - - usize = ABS (usize); - vsize = ABS (vsize); - up = u->_mp_d; - vp = v->_mp_d; - rp = r->_mp_d; - prec = r->_mp_prec; - uexp = u->_mp_exp; - ediff = u->_mp_exp - v->_mp_exp; - - /* If U extends beyond PREC, ignore the part that does. */ - if (usize > prec) - { - up += usize - prec; - usize = prec; - } - - /* If V extends beyond PREC, ignore the part that does. - Note that this may make vsize negative. */ - if (vsize + ediff > prec) - { - vp += vsize + ediff - prec; - vsize = prec - ediff; - } - -#if 0 - /* Locate the least significant non-zero limb in (the needed parts - of) U and V, to simplify the code below. */ - while (up[0] == 0) - up++, usize--; - while (vp[0] == 0) - vp++, vsize--; -#endif - - /* Allocate temp space for the result. Allocate - just vsize + ediff later??? */ - tp = (mp_ptr) TMP_ALLOC (prec * BYTES_PER_MP_LIMB); - - if (ediff >= prec) - { - /* V completely cancelled. */ - if (tp != up) - MPN_COPY (rp, up, usize); - rsize = usize; - } - else - { - /* uuuu | uuuu | uuuu | uuuu | uuuu */ - /* vvvvvvv | vv | vvvvv | v | vv */ - - if (usize > ediff) - { - /* U and V partially overlaps. */ - if (vsize + ediff <= usize) - { - /* uuuu */ - /* v */ - mp_size_t size; - size = usize - ediff - vsize; - MPN_COPY (tp, up, size); - cy = mpn_add (tp + size, up + size, usize - size, vp, vsize); - rsize = usize; - } - else - { - /* uuuu */ - /* vvvvv */ - mp_size_t size; - size = vsize + ediff - usize; - MPN_COPY (tp, vp, size); - cy = mpn_add (tp + size, up, usize, vp + size, usize - ediff); - rsize = vsize + ediff; - } - } - else - { - /* uuuu */ - /* vv */ - mp_size_t size; - size = vsize + ediff - usize; - MPN_COPY (tp, vp, vsize); - MPN_ZERO (tp + vsize, ediff - usize); - MPN_COPY (tp + size, up, usize); - cy = 0; - rsize = size + usize; - } - - MPN_COPY (rp, tp, rsize); - rp[rsize] = cy; - rsize += cy; - uexp += cy; - } - - r->_mp_size = negate ? -rsize : rsize; - r->_mp_exp = uexp; - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpf/add_ui.c b/gnu/lib/libgmp/mpf/add_ui.c deleted file mode 100644 index f181df4..0000000 --- a/gnu/lib/libgmp/mpf/add_ui.c +++ /dev/null @@ -1,151 +0,0 @@ -/* mpf_add_ui -- Add a float and an unsigned integer. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_add_ui (mpf_ptr sum, mpf_srcptr u, unsigned long int v) -#else -mpf_add_ui (sum, u, v) - mpf_ptr sum; - mpf_srcptr u; - unsigned long int v; -#endif -{ - mp_srcptr up = u->_mp_d; - mp_ptr sump = sum->_mp_d; - mp_size_t usize, sumsize; - mp_size_t prec = sum->_mp_prec; - mp_exp_t uexp = u->_mp_exp; - - usize = u->_mp_size; - if (usize <= 0) - { - if (usize == 0) - { - mpf_set_ui (sum, v); - return; - } - else - { - __mpf_struct u_negated; - u_negated._mp_size = -usize; - u_negated._mp_exp = u->_mp_exp; - u_negated._mp_d = u->_mp_d; - mpf_sub_ui (sum, &u_negated, v); - sum->_mp_size = -(sum->_mp_size); - return; - } - } - - if (v == 0) - { - sum_is_u: - if (u != sum) - { - sumsize = MIN (usize, prec + 1); - MPN_COPY (sum->_mp_d, up + usize - sumsize, sumsize); - sum->_mp_size = sumsize; - sum->_mp_exp = u->_mp_exp; - } - return; - } - - if (uexp > 0) - { - /* U >= 1. */ - if (uexp > prec) - { - /* U >> V, V is not part of final result. */ - goto sum_is_u; - } - else - { - /* U's "limb point" is somewhere between the first limb - and the PREC:th limb. - Both U and V are part of the final result. */ - if (uexp > usize) - { - /* uuuuuu0000. */ - /* + v. */ - /* We begin with moving U to the top of SUM, to handle - samevar(U,SUM). */ - MPN_COPY_DECR (sump + uexp - usize, up, usize); - sump[0] = v; - MPN_ZERO (sump + 1, uexp - usize - 1); -#if 0 /* What is this??? */ - if (sum == u) - MPN_COPY (sum->_mp_d, sump, uexp); -#endif - sum->_mp_size = uexp; - sum->_mp_exp = uexp; - } - else - { - /* uuuuuu.uuuu */ - /* + v. */ - mp_limb_t cy_limb; - if (usize > prec) - { - /* Ignore excess limbs in U. */ - up += usize - prec; - usize -= usize - prec; /* Eq. usize = prec */ - } - if (sump != up) - MPN_COPY (sump, up, usize - uexp); - cy_limb = mpn_add_1 (sump + usize - uexp, up + usize - uexp, - uexp, (mp_limb_t) v); - sump[usize] = cy_limb; - sum->_mp_size = usize + cy_limb; - sum->_mp_exp = uexp + cy_limb; - } - } - } - else - { - /* U < 1, so V > U for sure. */ - /* v. */ - /* .0000uuuu */ - if ((-uexp) >= prec) - { - sump[0] = v; - sum->_mp_size = 1; - sum->_mp_exp = 1; - } - else - { - if (usize + (-uexp) + 1 > prec) - { - /* Ignore excess limbs in U. */ - up += usize + (-uexp) + 1 - prec; - usize -= usize + (-uexp) + 1 - prec; - } - if (sump != up) - MPN_COPY (sump, up, usize); - MPN_ZERO (sump + usize, -uexp); - sump[usize + (-uexp)] = v; - sum->_mp_size = usize + (-uexp) + 1; - sum->_mp_exp = 1; - } - } -} diff --git a/gnu/lib/libgmp/mpf/clear.c b/gnu/lib/libgmp/mpf/clear.c deleted file mode 100644 index beaf4ee..0000000 --- a/gnu/lib/libgmp/mpf/clear.c +++ /dev/null @@ -1,35 +0,0 @@ -/* mpf_clear -- de-allocate the space occupied by the dynamic digit space of - an integer. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_clear (mpf_ptr m) -#else -mpf_clear (m) - mpf_ptr m; -#endif -{ - (*_mp_free_func) (m->_mp_d, (m->_mp_prec + 1) * BYTES_PER_MP_LIMB); -} diff --git a/gnu/lib/libgmp/mpf/cmp.c b/gnu/lib/libgmp/mpf/cmp.c deleted file mode 100644 index d440e11..0000000 --- a/gnu/lib/libgmp/mpf/cmp.c +++ /dev/null @@ -1,114 +0,0 @@ -/* mpf_cmp -- Compare two floats. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -int -#if __STDC__ -mpf_cmp (mpf_srcptr u, mpf_srcptr v) -#else -mpf_cmp (u, v) - mpf_srcptr u; - mpf_srcptr v; -#endif -{ - mp_srcptr up, vp; - mp_size_t usize, vsize; - mp_exp_t uexp, vexp; - int cmp; - int usign; - - uexp = u->_mp_exp; - vexp = v->_mp_exp; - - usize = u->_mp_size; - vsize = v->_mp_size; - - /* 1. Are the signs different? */ - if ((usize ^ vsize) >= 0) - { - /* U and V are both non-negative or both negative. */ - if (usize == 0) - /* vsize >= 0 */ - return -(vsize != 0); - if (vsize == 0) - /* usize >= 0 */ - return usize != 0; - /* Fall out. */ - } - else - { - /* Either U or V is negative, but not both. */ - return usize >= 0 ? 1 : -1; - } - - /* U and V have the same sign and are both non-zero. */ - - usign = usize >= 0 ? 1 : -1; - - /* 2. Are the exponents different? */ - if (uexp > vexp) - return usign; - if (uexp < vexp) - return -usign; - - usize = ABS (usize); - vsize = ABS (vsize); - - up = u->_mp_d; - vp = v->_mp_d; - -#define STRICT_MPF_NORMALIZATION 0 -#if ! STRICT_MPF_NORMALIZATION - /* Ignore zeroes at the low end of U and V. */ - while (up[0] == 0) - { - up++; - usize--; - } - while (vp[0] == 0) - { - vp++; - vsize--; - } -#endif - - if (usize > vsize) - { - cmp = mpn_cmp (up + usize - vsize, vp, vsize); - if (cmp == 0) - return usign; - } - else if (vsize > usize) - { - cmp = mpn_cmp (up, vp + vsize - usize, usize); - if (cmp == 0) - return -usign; - } - else - { - cmp = mpn_cmp (up, vp, usize); - if (cmp == 0) - return 0; - } - return cmp > 0 ? usign : -usign; -} diff --git a/gnu/lib/libgmp/mpf/cmp_si.c b/gnu/lib/libgmp/mpf/cmp_si.c deleted file mode 100644 index 01f9708..0000000 --- a/gnu/lib/libgmp/mpf/cmp_si.c +++ /dev/null @@ -1,98 +0,0 @@ -/* mpf_cmp_si -- Compare a float with a signed integer. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -int -#if __STDC__ -mpf_cmp_si (mpf_srcptr u, long int vslimb) -#else -mpf_cmp_si (u, vslimb) - mpf_srcptr u; - long int vslimb; -#endif -{ - mp_srcptr up; - mp_size_t usize; - mp_exp_t uexp; - int usign; - - uexp = u->_mp_exp; - usize = u->_mp_size; - - /* 1. Are the signs different? */ - if ((usize < 0) == (vslimb < 0)) /* don't use xor, type size may differ */ - { - /* U and V are both non-negative or both negative. */ - if (usize == 0) - /* vslimb >= 0 */ - return -(vslimb != 0); - if (vslimb == 0) - /* usize >= 0 */ - return usize != 0; - /* Fall out. */ - } - else - { - /* Either U or V is negative, but not both. */ - return usize >= 0 ? 1 : -1; - } - - /* U and V have the same sign and are both non-zero. */ - - usign = usize >= 0 ? 1 : -1; - - /* 2. Are the exponents different (V's exponent == 1)? */ - if (uexp > 1) - return usign; - if (uexp < 1) - return -usign; - - usize = ABS (usize); - vslimb = ABS (vslimb); - - up = u->_mp_d; - -#define STRICT_MPF_NORMALIZATION 0 -#if ! STRICT_MPF_NORMALIZATION - /* Ignore zeroes at the low end of U and V. */ - while (*up == 0) - { - up++; - usize--; - } -#endif - - /* 3. Now, if the number of limbs are different, we have a difference - since we have made sure the trailing limbs are not zero. */ - if (usize > 1) - return usign; - - /* 4. Compare the mantissas. */ - if (*up > vslimb) - return usign; - else if (*up < vslimb) - return -usign; - - /* Wow, we got zero even if we tried hard to avoid it. */ - return 0; -} diff --git a/gnu/lib/libgmp/mpf/cmp_ui.c b/gnu/lib/libgmp/mpf/cmp_ui.c deleted file mode 100644 index 3a4911b..0000000 --- a/gnu/lib/libgmp/mpf/cmp_ui.c +++ /dev/null @@ -1,80 +0,0 @@ -/* mpf_cmp_ui -- Compare a float with an unsigned integer. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -int -#if __STDC__ -mpf_cmp_ui (mpf_srcptr u, unsigned long int vlimb) -#else -mpf_cmp_ui (u, vlimb) - mpf_srcptr u; - unsigned long int vlimb; -#endif -{ - mp_srcptr up; - mp_size_t usize; - mp_exp_t uexp; - - uexp = u->_mp_exp; - usize = u->_mp_size; - - /* 1. Is U negative? */ - if (usize < 0) - return -1; - /* We rely on usize being non-negative in the code that follows. */ - - if (vlimb == 0) - return usize != 0; - - /* 2. Are the exponents different (V's exponent == 1)? */ - if (uexp > 1) - return 1; - if (uexp < 1) - return -1; - - up = u->_mp_d; - -#define STRICT_MPF_NORMALIZATION 0 -#if ! STRICT_MPF_NORMALIZATION - /* Ignore zeroes at the low end of U. */ - while (*up == 0) - { - up++; - usize--; - } -#endif - - /* 3. Now, if the number of limbs are different, we have a difference - since we have made sure the trailing limbs are not zero. */ - if (usize > 1) - return 1; - - /* 4. Compare the mantissas. */ - if (*up > vlimb) - return 1; - else if (*up < vlimb) - return -1; - - /* Wow, we got zero even if we tried hard to avoid it. */ - return 0; -} diff --git a/gnu/lib/libgmp/mpf/configure.in b/gnu/lib/libgmp/mpf/configure.in deleted file mode 100644 index b6ecf8b..0000000 --- a/gnu/lib/libgmp/mpf/configure.in +++ /dev/null @@ -1,12 +0,0 @@ -# This file is a shell script fragment that supplies the information -# necessary for a configure script to process the program in -# this directory. For more information, look at ../configure. - -configdirs=tests -srctrigger=add_ui.c -srcname="GNU Multi-Precision library/mpf" - -# per-host: - -# per-target: - diff --git a/gnu/lib/libgmp/mpf/div.c b/gnu/lib/libgmp/mpf/div.c deleted file mode 100644 index 9ba6922..0000000 --- a/gnu/lib/libgmp/mpf/div.c +++ /dev/null @@ -1,144 +0,0 @@ -/* mpf_div -- Divide two floats. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void -#if __STDC__ -mpf_div (mpf_ptr r, mpf_srcptr u, mpf_srcptr v) -#else -mpf_div (r, u, v) - mpf_ptr r; - mpf_srcptr u; - mpf_srcptr v; -#endif -{ - mp_srcptr up, vp; - mp_ptr rp, tp, rtp; - mp_size_t usize, vsize; - mp_size_t rsize, tsize; - mp_size_t sign_quotient; - mp_size_t prec; - unsigned normalization_steps; - mp_limb_t q_limb; - mp_exp_t rexp; - TMP_DECL (marker); - - usize = u->_mp_size; - vsize = v->_mp_size; - sign_quotient = usize ^ vsize; - usize = ABS (usize); - vsize = ABS (vsize); - prec = r->_mp_prec; - - if (vsize == 0) - vsize = 1 / vsize; /* divide by zero as directed */ - if (usize == 0) - { - r->_mp_size = 0; - r->_mp_exp = 0; - return; - } - - TMP_MARK (marker); - rexp = u->_mp_exp - v->_mp_exp; - - rp = r->_mp_d; - up = u->_mp_d; - vp = v->_mp_d; - - if (vsize > prec) - { - vp += vsize - prec; - vsize = prec; - } - - tsize = vsize + prec; - tp = (mp_ptr) TMP_ALLOC ((tsize + 1) * BYTES_PER_MP_LIMB); - - if (usize > tsize) - { - up += usize - tsize; - usize = tsize; - rtp = tp; - } - else - { - MPN_ZERO (tp, tsize - usize); - rtp = tp + (tsize - usize); - } - - count_leading_zeros (normalization_steps, vp[vsize - 1]); - - /* Normalize the divisor and the dividend. */ - if (normalization_steps != 0) - { - mp_ptr tmp; - mp_limb_t nlimb; - - /* Shift up the divisor setting the most significant bit of - the most significant limb. Use temporary storage not to clobber - the original contents of the divisor. */ - tmp = (mp_ptr) TMP_ALLOC (vsize * BYTES_PER_MP_LIMB); - mpn_lshift (tmp, vp, vsize, normalization_steps); - vp = tmp; - - /* Shift up the dividend, possibly introducing a new most - significant word. Move the shifted dividend in the remainder - at the same time. */ - nlimb = mpn_lshift (rtp, up, usize, normalization_steps); - if (nlimb != 0) - { - rtp[usize] = nlimb; - tsize++; - rexp++; - } - } - else - { - /* The divisor is already normalized, as required. - Copy it to temporary space if it overlaps with the quotient. */ - if (vp - rp <= tsize - vsize) - { - mp_ptr tmp = (mp_ptr) TMP_ALLOC (vsize * BYTES_PER_MP_LIMB); - MPN_COPY (tmp, vp, vsize); - vp = (mp_srcptr) tmp; - } - - /* Move the dividend to the remainder. */ - MPN_COPY (rtp, up, usize); - } - - q_limb = mpn_divmod (rp, tp, tsize, vp, vsize); - rsize = tsize - vsize; - if (q_limb) - { - rp[rsize] = q_limb; - rsize++; - rexp++; - } - - r->_mp_size = sign_quotient >= 0 ? rsize : -rsize; - r->_mp_exp = rexp; - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpf/div_2exp.c b/gnu/lib/libgmp/mpf/div_2exp.c deleted file mode 100644 index d729625..0000000 --- a/gnu/lib/libgmp/mpf/div_2exp.c +++ /dev/null @@ -1,79 +0,0 @@ -/* mpf_div_2exp -- Divide a float by 2^n. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_div_2exp (mpf_ptr r, mpf_srcptr u, unsigned long int exp) -#else -mpf_div_2exp (r, u, exp) - mpf_ptr r; - mpf_srcptr u; - unsigned long int exp; -#endif -{ - mp_srcptr up; - mp_ptr rp = r->_mp_d; - mp_size_t usize; - mp_size_t abs_usize; - mp_size_t prec = r->_mp_prec; - mp_exp_t uexp = u->_mp_exp; - - usize = u->_mp_size; - - if (usize == 0) - { - r->_mp_size = 0; - r->_mp_exp = 0; - return; - } - - abs_usize = ABS (usize); - up = u->_mp_d; - - if (abs_usize > prec) - { - up += abs_usize - prec; - abs_usize = prec; - } - - if (exp % BITS_PER_MP_LIMB == 0) - { - if (rp != up) - MPN_COPY (rp, up, abs_usize); - r->_mp_exp = uexp - exp / BITS_PER_MP_LIMB; - } - else - { - /* Use mpn_lshift since mpn_rshift operates upwards, and we therefore - would clobber part of U before using that part, when R == U. */ - mp_limb_t cy_limb; - cy_limb = mpn_lshift (rp, up, abs_usize, -exp % BITS_PER_MP_LIMB); - rp[abs_usize] = cy_limb; - cy_limb = cy_limb != 0; - - abs_usize += cy_limb; - r->_mp_exp = uexp - exp / BITS_PER_MP_LIMB - 1 + cy_limb; - } - r->_mp_size = usize >= 0 ? abs_usize : -abs_usize; -} diff --git a/gnu/lib/libgmp/mpf/div_ui.c b/gnu/lib/libgmp/mpf/div_ui.c deleted file mode 100644 index 050a6f0..0000000 --- a/gnu/lib/libgmp/mpf/div_ui.c +++ /dev/null @@ -1,91 +0,0 @@ -/* mpf_div_ui -- Divide a float with an unsigned integer. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void -#if __STDC__ -mpf_div_ui (mpf_ptr r, mpf_srcptr u, unsigned long int v) -#else -mpf_div_ui (r, u, v) - mpf_ptr r; - mpf_srcptr u; - unsigned long int v; -#endif -{ - mp_srcptr up; - mp_ptr rp, tp, rtp; - mp_size_t usize; - mp_size_t rsize, tsize; - mp_size_t sign_quotient; - mp_size_t prec; - mp_limb_t q_limb; - mp_exp_t rexp; - TMP_DECL (marker); - - usize = u->_mp_size; - sign_quotient = usize; - usize = ABS (usize); - prec = r->_mp_prec; - - if (v == 0) - v = 1 / v; /* divide by zero as directed */ - if (usize == 0) - { - r->_mp_size = 0; - r->_mp_exp = 0; - return; - } - - TMP_MARK (marker); - - rp = r->_mp_d; - up = u->_mp_d; - - tsize = 1 + prec; - tp = (mp_ptr) TMP_ALLOC ((tsize + 1) * BYTES_PER_MP_LIMB); - - if (usize > tsize) - { - up += usize - tsize; - usize = tsize; - rtp = tp; - } - else - { - MPN_ZERO (tp, tsize - usize); - rtp = tp + (tsize - usize); - } - - /* Move the dividend to the remainder. */ - MPN_COPY (rtp, up, usize); - - mpn_divmod_1 (rp, tp, tsize, (mp_limb_t) v); - q_limb = rp[tsize - 1]; - - rsize = tsize - (q_limb == 0); - rexp = u->_mp_exp - (q_limb == 0); - r->_mp_size = sign_quotient >= 0 ? rsize : -rsize; - r->_mp_exp = rexp; - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpf/dump.c b/gnu/lib/libgmp/mpf/dump.c deleted file mode 100644 index 46d5c05..0000000 --- a/gnu/lib/libgmp/mpf/dump.c +++ /dev/null @@ -1,43 +0,0 @@ -/* mpf_dump -- Dump a float to stdout. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_dump (mpf_srcptr u) -#else -mpf_dump (u) - mpf_srcptr u; -#endif -{ - mp_exp_t exp; - char *str; - - str = mpf_get_str (0, &exp, 10, 0, u); - if (str[0] == '-') - printf ("-0.%se%ld\n", str + 1, exp); - else - printf ("0.%se%ld\n", str, exp); - (*_mp_free_func) (str, 0);/* ??? broken alloc interface, pass what size ??? */ -} diff --git a/gnu/lib/libgmp/mpf/eq.c b/gnu/lib/libgmp/mpf/eq.c deleted file mode 100644 index e6630ad..0000000 --- a/gnu/lib/libgmp/mpf/eq.c +++ /dev/null @@ -1,121 +0,0 @@ -/* mpf_eq -- Compare two floats up to a specified bit #. - -Copyright (C) 1993, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -int -#if __STDC__ -mpf_eq (mpf_srcptr u, mpf_srcptr v, unsigned long int n_bits) -#else -mpf_eq (u, v, n_bits) - mpf_srcptr u; - mpf_srcptr v; - unsigned long int n_bits; -#endif -{ - mp_srcptr up, vp; - mp_size_t usize, vsize, size, i; - mp_exp_t uexp, vexp; - int usign; - - uexp = u->_mp_exp; - vexp = v->_mp_exp; - - usize = u->_mp_size; - vsize = v->_mp_size; - - /* 1. Are the signs different? */ - if ((usize ^ vsize) >= 0) - { - /* U and V are both non-negative or both negative. */ - if (usize == 0) - return vsize == 0; - if (vsize == 0) - return 0; - - /* Fall out. */ - } - else - { - /* Either U or V is negative, but not both. */ - return 0; - } - - /* U and V have the same sign and are both non-zero. */ - - usign = usize >= 0 ? 1 : -1; - - /* 2. Are the exponents different? */ - if (uexp > vexp) - return 0; /* ??? handle (uexp = vexp + 1) */ - if (vexp > uexp) - return 0; /* ??? handle (vexp = uexp + 1) */ - - usize = ABS (usize); - vsize = ABS (vsize); - - up = u->_mp_d; - vp = v->_mp_d; - - /* Ignore zeroes at the low end of U and V. */ - while (up[0] == 0) - { - up++; - usize--; - } - while (vp[0] == 0) - { - vp++; - vsize--; - } - - if (usize > vsize) - { - if (vsize * BITS_PER_MP_LIMB < n_bits) - return 0; /* surely too different */ - size = vsize; - } - else if (vsize > usize) - { - if (usize * BITS_PER_MP_LIMB < n_bits) - return 0; /* surely too different */ - size = usize; - } - else - { - size = usize; - } - - if (size > (n_bits + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB) - size = (n_bits + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB; - - up += usize - size; - vp += vsize - size; - - for (i = size - 1; i >= 0; i--) - { - if (up[i] != vp[i]) - return 0; - } - - return 1; -} diff --git a/gnu/lib/libgmp/mpf/get_d.c b/gnu/lib/libgmp/mpf/get_d.c deleted file mode 100644 index a10b366..0000000 --- a/gnu/lib/libgmp/mpf/get_d.c +++ /dev/null @@ -1,54 +0,0 @@ -/* double mpf_get_d (mpf_t src) -- Return the double approximation to SRC. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -double -#if __STDC__ -mpf_get_d (mpf_srcptr src) -#else -mpf_get_d (src) - mpf_srcptr src; -#endif -{ - double res; - mp_size_t size, i, n_limbs_to_use; - int negative; - mp_ptr qp; - - size = SIZ(src); - if (size == 0) - return 0.0; - - negative = size < 0; - size = ABS (size); - qp = PTR(src); - - res = qp[size - 1]; - n_limbs_to_use = MIN (LIMBS_PER_DOUBLE, size); - for (i = 2; i <= n_limbs_to_use; i++) - res = res * MP_BASE_AS_DOUBLE + qp[size - i]; - - res = __gmp_scale2 (res, (EXP(src) - n_limbs_to_use) * BITS_PER_MP_LIMB); - - return negative ? -res : res; -} diff --git a/gnu/lib/libgmp/mpf/get_prc.c b/gnu/lib/libgmp/mpf/get_prc.c deleted file mode 100644 index 7f7e41f..0000000 --- a/gnu/lib/libgmp/mpf/get_prc.c +++ /dev/null @@ -1,34 +0,0 @@ -/* mpf_get_prec(x) -- Return the precision in bits of x. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -unsigned long int -#if __STDC__ -mpf_get_prec (mpf_srcptr x) -#else -mpf_get_prec (x) - mpf_srcptr x; -#endif -{ - return (unsigned long int) x->_mp_prec * BITS_PER_MP_LIMB - BITS_PER_MP_LIMB; -} diff --git a/gnu/lib/libgmp/mpf/get_str.c b/gnu/lib/libgmp/mpf/get_str.c deleted file mode 100644 index bfee18d..0000000 --- a/gnu/lib/libgmp/mpf/get_str.c +++ /dev/null @@ -1,500 +0,0 @@ -/* mpf_get_str (digit_ptr, exp, base, n_digits, a) -- Convert the floating - point number A to a base BASE number and store N_DIGITS raw digits at - DIGIT_PTR, and the base BASE exponent in the word pointed to by EXP. For - example, the number 3.1416 would be returned as "31416" in DIGIT_PTR and - 1 in EXP. - -Copyright (C) 1993, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -/* - New algorithm for converting fractions (951019): - 0. Call the fraction to convert F. - 1. Compute [exp * log(2^BITS_PER_MP_LIMB)/log(B)], i.e., - [exp * BITS_PER_MP_LIMB * __mp_bases[B].chars_per_bit_exactly]. Exp is - the number of limbs between the limb point and the most significant - non-zero limb. Call this result n. - 2. Compute B^n. - 3. F*B^n will now be just below 1, which can be converted easily. (Just - multiply by B repeatedly, and see the digits fall out as integers.) - We should interrupt the conversion process of F*B^n as soon as the number - of digits requested have been generated. - - New algorithm for converting integers (951019): - 0. Call the integer to convert I. - 1. Compute [exp * log(2^BITS_PER_MP_LIMB)/log(B)], i.e., - [exp BITS_PER_MP_LIMB * __mp_bases[B].chars_per_bit_exactly]. Exp is - the number of limbs between the limb point and the least significant - non-zero limb. Call this result n. - 2. Compute B^n. - 3. I/B^n can be converted easily. (Just divide by B repeatedly. In GMP, - this is best done by calling mpn_get_str.) - Note that converting I/B^n could yield more digits than requested. For - efficiency, the variable n above should be set larger in such cases, to - kill all undesired digits in the division in step 3. -*/ - -char * -#if __STDC__ -mpf_get_str (char *digit_ptr, mp_exp_t *exp, int base, size_t n_digits, mpf_srcptr u) -#else -mpf_get_str (digit_ptr, exp, base, n_digits, u) - char *digit_ptr; - mp_exp_t *exp; - int base; - size_t n_digits; - mpf_srcptr u; -#endif -{ - mp_size_t usize; - mp_exp_t uexp; - unsigned char *str; - size_t str_size; - char *num_to_text; - long i; /* should be size_t */ - mp_ptr rp; - mp_limb_t big_base; - size_t digits_computed_so_far; - int dig_per_u; - mp_srcptr up; - unsigned char *tstr; - mp_exp_t exp_in_base; - TMP_DECL (marker); - - TMP_MARK (marker); - usize = u->_mp_size; - uexp = u->_mp_exp; - - if (base >= 0) - { - if (base == 0) - base = 10; - num_to_text = "0123456789abcdefghijklmnopqrstuvwxyz"; - } - else - { - base = -base; - num_to_text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - } - - /* Don't compute more digits than U can accurately represent. - Also, if 0 digits were requested, give *exactly* as many digits - as can be accurately represented. */ - { - size_t max_digits = (((u->_mp_prec - 1) * BITS_PER_MP_LIMB) - * __mp_bases[base].chars_per_bit_exactly); - if (n_digits == 0 || n_digits > max_digits) - n_digits = max_digits; - } - - if (digit_ptr == 0) - { - /* We didn't get a string from the user. Allocate one (and return - a pointer to it) with space for `-' and terminating null. */ - digit_ptr = (char *) (*_mp_allocate_func) (n_digits + 2); - } - - if (usize == 0) - { - *exp = 0; - *digit_ptr = 0; - return digit_ptr; - } - - str = (unsigned char *) digit_ptr; - - /* Allocate temporary digit space. We can't put digits directly in the user - area, since we almost always generate more digits than requested. */ - tstr = (unsigned char *) TMP_ALLOC (n_digits + 3 * BITS_PER_MP_LIMB); - - if (usize < 0) - { - *digit_ptr = '-'; - str++; - usize = -usize; - } - - digits_computed_so_far = 0; - - if (uexp > usize) - { - /* The number has just an integral part. */ - mp_size_t rsize; - mp_size_t exp_in_limbs; - mp_size_t msize; - mp_ptr tp, xp, mp; - int cnt; - mp_limb_t cy; - mp_size_t start_str; - mp_size_t n_limbs; - - n_limbs = 2 + ((mp_size_t) (n_digits / __mp_bases[base].chars_per_bit_exactly) - / BITS_PER_MP_LIMB); - - /* Compute n such that [u/B^n] contains (somewhat) more than n_digits - digits. (We compute less than that only if that is an exact number, - i.e., exp is small enough.) */ - - exp_in_limbs = uexp; - - if (n_limbs >= exp_in_limbs) - { - /* The number is so small that we convert the entire number. */ - exp_in_base = 0; - rp = (mp_ptr) TMP_ALLOC (exp_in_limbs * BYTES_PER_MP_LIMB); - MPN_ZERO (rp, exp_in_limbs - usize); - MPN_COPY (rp + (exp_in_limbs - usize), u->_mp_d, usize); - rsize = exp_in_limbs; - } - else - { - exp_in_limbs -= n_limbs; - exp_in_base = (((exp_in_limbs * BITS_PER_MP_LIMB - 1)) - * __mp_bases[base].chars_per_bit_exactly); - - rsize = exp_in_limbs + 1; - rp = (mp_ptr) TMP_ALLOC (rsize * BYTES_PER_MP_LIMB); - tp = (mp_ptr) TMP_ALLOC (rsize * BYTES_PER_MP_LIMB); - - rp[0] = base; - rsize = 1; - - count_leading_zeros (cnt, exp_in_base); - for (i = BITS_PER_MP_LIMB - cnt - 2; i >= 0; i--) - { - mpn_mul_n (tp, rp, rp, rsize); - rsize = 2 * rsize; - rsize -= tp[rsize - 1] == 0; - xp = tp; tp = rp; rp = xp; - - if (((exp_in_base >> i) & 1) != 0) - { - cy = mpn_mul_1 (rp, rp, rsize, (mp_limb_t) base); - rp[rsize] = cy; - rsize += cy != 0; - } - } - - mp = u->_mp_d; - msize = usize; - - { - mp_ptr qp; - mp_limb_t qflag; - mp_size_t xtra; - if (msize < rsize) - { - mp_ptr tmp = (mp_ptr) TMP_ALLOC ((rsize+1)* BYTES_PER_MP_LIMB); - MPN_ZERO (tmp, rsize - msize); - MPN_COPY (tmp + rsize - msize, mp, msize); - mp = tmp; - msize = rsize; - } - else - { - mp_ptr tmp = (mp_ptr) TMP_ALLOC ((msize+1)* BYTES_PER_MP_LIMB); - MPN_COPY (tmp, mp, msize); - mp = tmp; - } - count_leading_zeros (cnt, rp[rsize - 1]); - cy = 0; - if (cnt != 0) - { - mpn_lshift (rp, rp, rsize, cnt); - cy = mpn_lshift (mp, mp, msize, cnt); - if (cy) - mp[msize++] = cy; - } - - { - mp_size_t qsize = n_limbs + (cy != 0); - qp = (mp_ptr) TMP_ALLOC ((qsize + 1) * BYTES_PER_MP_LIMB); - xtra = qsize - (msize - rsize); - qflag = mpn_divrem (qp, xtra, mp, msize, rp, rsize); - qp[qsize] = qflag; - rsize = qsize + qflag; - rp = qp; - } - } - } - - str_size = mpn_get_str (tstr, base, rp, rsize); - - if (str_size > n_digits + 3 * BITS_PER_MP_LIMB) - abort (); - - start_str = 0; - while (tstr[start_str] == 0) - start_str++; - - for (i = start_str; i < str_size; i++) - { - tstr[digits_computed_so_far++] = tstr[i]; - if (digits_computed_so_far > n_digits) - break; - } - exp_in_base = exp_in_base + str_size - start_str; - goto finish_up; - } - - exp_in_base = 0; - - if (uexp > 0) - { - /* The number has an integral part, convert that first. - If there is a fractional part too, it will be handled later. */ - mp_size_t start_str; - - rp = (mp_ptr) TMP_ALLOC (uexp * BYTES_PER_MP_LIMB); - up = u->_mp_d + usize - uexp; - MPN_COPY (rp, up, uexp); - - str_size = mpn_get_str (tstr, base, rp, uexp); - - start_str = 0; - while (tstr[start_str] == 0) - start_str++; - - for (i = start_str; i < str_size; i++) - { - tstr[digits_computed_so_far++] = tstr[i]; - if (digits_computed_so_far > n_digits) - { - exp_in_base = str_size - start_str; - goto finish_up; - } - } - - exp_in_base = str_size - start_str; - /* Modify somewhat and fall out to convert fraction... */ - usize -= uexp; - uexp = 0; - } - - if (usize <= 0) - goto finish_up; - - /* Convert the fraction. */ - { - mp_size_t rsize, msize; - mp_ptr rp, tp, xp, mp; - int cnt; - mp_limb_t cy; - mp_exp_t nexp; - - big_base = __mp_bases[base].big_base; - dig_per_u = __mp_bases[base].chars_per_limb; - - /* Hack for correctly (although not efficiently) converting to bases that - are powers of 2. If we deem it important, we could handle powers of 2 - by shifting and masking (just like mpn_get_str). */ - if (big_base < 10) /* logarithm of base when power of two */ - { - int logbase = big_base; - if (dig_per_u * logbase == BITS_PER_MP_LIMB) - dig_per_u--; - big_base = (mp_limb_t) 1 << (dig_per_u * logbase); - /* fall out to general code... */ - } - -#if 0 - if (0 && uexp == 0) - { - rp = (mp_ptr) TMP_ALLOC (usize * BYTES_PER_MP_LIMB); - up = u->_mp_d; - MPN_COPY (rp, up, usize); - rsize = usize; - nexp = 0; - } - else - {} -#endif - uexp = -uexp; - if (u->_mp_d[usize - 1] == 0) - cnt = 0; - else - count_leading_zeros (cnt, u->_mp_d[usize - 1]); - - nexp = ((uexp * BITS_PER_MP_LIMB) + cnt) - * __mp_bases[base].chars_per_bit_exactly; - - if (nexp == 0) - { - rp = (mp_ptr) TMP_ALLOC (usize * BYTES_PER_MP_LIMB); - up = u->_mp_d; - MPN_COPY (rp, up, usize); - rsize = usize; - } - else - { - rsize = uexp + 2; - rp = (mp_ptr) TMP_ALLOC (rsize * BYTES_PER_MP_LIMB); - tp = (mp_ptr) TMP_ALLOC (rsize * BYTES_PER_MP_LIMB); - - rp[0] = base; - rsize = 1; - - count_leading_zeros (cnt, nexp); - for (i = BITS_PER_MP_LIMB - cnt - 2; i >= 0; i--) - { - mpn_mul_n (tp, rp, rp, rsize); - rsize = 2 * rsize; - rsize -= tp[rsize - 1] == 0; - xp = tp; tp = rp; rp = xp; - - if (((nexp >> i) & 1) != 0) - { - cy = mpn_mul_1 (rp, rp, rsize, (mp_limb_t) base); - rp[rsize] = cy; - rsize += cy != 0; - } - } - - /* Did our multiplier (base^nexp) cancel with uexp? */ -#if 0 - if (uexp != rsize) - { - do - { - cy = mpn_mul_1 (rp, rp, rsize, big_base); - nexp += dig_per_u; - } - while (cy == 0); - rp[rsize++] = cy; - } -#endif - mp = u->_mp_d; - msize = usize; - - tp = (mp_ptr) TMP_ALLOC ((rsize + msize) * BYTES_PER_MP_LIMB); - if (rsize > msize) - cy = mpn_mul (tp, rp, rsize, mp, msize); - else - cy = mpn_mul (tp, mp, msize, rp, rsize); - rsize += msize; - rsize -= cy == 0; - rp = tp; - - /* If we already output digits (for an integral part) pad - leading zeros. */ - if (digits_computed_so_far != 0) - for (i = 0; i < nexp; i++) - tstr[digits_computed_so_far++] = 0; - } - - while (digits_computed_so_far <= n_digits) - { - /* For speed: skip trailing zeroes. */ - if (rp[0] == 0) - { - rp++; - rsize--; - if (rsize == 0) - { - n_digits = digits_computed_so_far; - break; - } - } - - cy = mpn_mul_1 (rp, rp, rsize, big_base); - if (digits_computed_so_far == 0 && cy == 0) - { - abort (); - nexp += dig_per_u; - continue; - } - /* Convert N1 from BIG_BASE to a string of digits in BASE - using single precision operations. */ - { - unsigned char *s = tstr + digits_computed_so_far + dig_per_u; - for (i = dig_per_u - 1; i >= 0; i--) - { - *--s = cy % base; - cy /= base; - } - } - digits_computed_so_far += dig_per_u; - } - if (exp_in_base == 0) - exp_in_base = -nexp; - } - - finish_up: - - /* We can have at most one leading 0. Remove it. */ - if (tstr[0] == 0) - { - tstr++; - digits_computed_so_far--; - exp_in_base--; - } - - /* We should normally have computed too many digits. Round the result - at the point indicated by n_digits. */ - if (digits_computed_so_far > n_digits) - { - /* Round the result. */ - if (tstr[n_digits] * 2 >= base) - { - digits_computed_so_far = n_digits; - for (i = n_digits - 1; i >= 0; i--) - { - unsigned int x; - x = ++(tstr[i]); - if (x < base) - goto rounded_ok; - digits_computed_so_far--; - } - tstr[0] = 1; - digits_computed_so_far = 1; - exp_in_base++; - rounded_ok:; - } - } - - /* We might have fewer digits than requested as a result of rounding above, - (i.e. 0.999999 => 1.0) or because we have a number that simply doesn't - need many digits in this base (i.e., 0.125 in base 10). */ - if (n_digits > digits_computed_so_far) - n_digits = digits_computed_so_far; - - /* Remove trailing 0. There can be many zeros. */ - while (n_digits != 0 && tstr[n_digits - 1] == 0) - n_digits--; - - /* Translate to ascii and null-terminate. */ - for (i = 0; i < n_digits; i++) - *str++ = num_to_text[tstr[i]]; - *str = 0; - *exp = exp_in_base; - TMP_FREE (marker); - return digit_ptr; -} - -#if COPY_THIS_TO_OTHER_PLACES - /* Use this expression in lots of places in the library instead of the - count_leading_zeros+expression that is used currently. This expression - is much more accurate and will save odles of memory. */ - rsize = ((mp_size_t) (exp_in_base / __mp_bases[base].chars_per_bit_exactly) - + BITS_PER_MP_LIMB) / BITS_PER_MP_LIMB; -#endif diff --git a/gnu/lib/libgmp/mpf/init.c b/gnu/lib/libgmp/mpf/init.c deleted file mode 100644 index 5370121..0000000 --- a/gnu/lib/libgmp/mpf/init.c +++ /dev/null @@ -1,38 +0,0 @@ -/* mpf_init() -- Make a new multiple precision number with value 0. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_init (mpf_ptr r) -#else -mpf_init (r) - mpf_ptr r; -#endif -{ - mp_size_t prec = __gmp_default_fp_limb_precision; - r->_mp_d = (mp_ptr) (*_mp_allocate_func) ((prec + 1) * BYTES_PER_MP_LIMB); - r->_mp_prec = prec; - r->_mp_size = 0; - r->_mp_exp = 0; -} diff --git a/gnu/lib/libgmp/mpf/init2.c b/gnu/lib/libgmp/mpf/init2.c deleted file mode 100644 index a3e5752..0000000 --- a/gnu/lib/libgmp/mpf/init2.c +++ /dev/null @@ -1,41 +0,0 @@ -/* mpf_init2() -- Make a new multiple precision number with value 0. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_init2 (mpf_ptr r, unsigned long int prec_in_bits) -#else -mpf_init2 (r, prec_in_bits) - mpf_ptr r; - unsigned long int prec_in_bits; -#endif -{ - mp_size_t prec; - - prec = (MAX (53, prec_in_bits) + 2 * BITS_PER_MP_LIMB - 1)/BITS_PER_MP_LIMB; - r->_mp_d = (mp_ptr) (*_mp_allocate_func) ((prec + 1) * BYTES_PER_MP_LIMB); - r->_mp_prec = prec; - r->_mp_size = 0; - r->_mp_exp = 0; -} diff --git a/gnu/lib/libgmp/mpf/inp_str.c b/gnu/lib/libgmp/mpf/inp_str.c deleted file mode 100644 index 1d3cd4c..0000000 --- a/gnu/lib/libgmp/mpf/inp_str.c +++ /dev/null @@ -1,89 +0,0 @@ -/* mpf_inp_str(dest_float, stream, base) -- Input a number in base - BASE from stdio stream STREAM and store the result in DEST_FLOAT. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include -#include "gmp.h" -#include "gmp-impl.h" - -size_t -#if __STDC__ -mpf_inp_str (mpf_ptr rop, FILE *stream, int base) -#else -mpf_inp_str (rop, stream, base) - mpf_ptr rop; - FILE *stream; - int base; -#endif -{ - char *str; - size_t alloc_size, str_size; - int c; - size_t retval; - size_t nread; - - if (stream == 0) - stream = stdin; - - alloc_size = 100; - str = (char *) (*_mp_allocate_func) (alloc_size); - str_size = 0; - nread = 0; - - /* Skip whitespace. */ - do - { - c = getc (stream); - nread++; - } - while (isspace (c)); - - for (;;) - { - if (str_size >= alloc_size) - { - size_t old_alloc_size = alloc_size; - alloc_size = alloc_size * 3 / 2; - str = (char *) (*_mp_reallocate_func) (str, old_alloc_size, alloc_size); - } - if (c == EOF || isspace (c)) - break; - str[str_size++] = c; - c = getc (stream); - } - ungetc (c, stream); - - if (str_size >= alloc_size) - { - size_t old_alloc_size = alloc_size; - alloc_size = alloc_size * 3 / 2; - str = (char *) (*_mp_reallocate_func) (str, old_alloc_size, alloc_size); - } - str[str_size] = 0; - - retval = mpf_set_str (rop, str, base); - if (retval == -1) - return 0; /* error */ - - (*_mp_free_func) (str, alloc_size); - return str_size + nread; -} diff --git a/gnu/lib/libgmp/mpf/iset.c b/gnu/lib/libgmp/mpf/iset.c deleted file mode 100644 index c2362e1..0000000 --- a/gnu/lib/libgmp/mpf/iset.c +++ /dev/null @@ -1,59 +0,0 @@ -/* mpf_init_set -- Initialize a float and assign it from another float. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_init_set (mpf_ptr r, mpf_srcptr s) -#else -mpf_init_set (r, s) - mpf_ptr r; - mpf_srcptr s; -#endif -{ - mp_ptr rp, sp; - mp_size_t ssize, size; - mp_size_t prec; - - prec = __gmp_default_fp_limb_precision; - r->_mp_d = (mp_ptr) (*_mp_allocate_func) ((prec + 1) * BYTES_PER_MP_LIMB); - r->_mp_prec = prec; - - prec++; /* lie not to lose precision in assignment */ - ssize = s->_mp_size; - size = ABS (ssize); - - rp = r->_mp_d; - sp = s->_mp_d; - - if (size > prec) - { - sp += size - prec; - size = prec; - } - - MPN_COPY (rp, sp, size); - - r->_mp_exp = s->_mp_exp; - r->_mp_size = ssize >= 0 ? size : -size; -} diff --git a/gnu/lib/libgmp/mpf/iset_d.c b/gnu/lib/libgmp/mpf/iset_d.c deleted file mode 100644 index d09e8b8..0000000 --- a/gnu/lib/libgmp/mpf/iset_d.c +++ /dev/null @@ -1,39 +0,0 @@ -/* mpf_init_set_d -- Initialize a float and assign it from a double. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_init_set_d (mpf_ptr r, double val) -#else -mpf_init_set_d (r, val) - mpf_ptr r; - double val; -#endif -{ - mp_size_t prec = __gmp_default_fp_limb_precision; - r->_mp_d = (mp_ptr) (*_mp_allocate_func) ((prec + 1) * BYTES_PER_MP_LIMB); - r->_mp_prec = prec; - - mpf_set_d (r, val); -} diff --git a/gnu/lib/libgmp/mpf/iset_si.c b/gnu/lib/libgmp/mpf/iset_si.c deleted file mode 100644 index e67eef4..0000000 --- a/gnu/lib/libgmp/mpf/iset_si.c +++ /dev/null @@ -1,55 +0,0 @@ -/* mpf_init_set_si() -- Initialize a float and assign it from a signed int. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_init_set_si (mpf_ptr r, long int val) -#else -mpf_init_set_si (r, val) - mpf_ptr r; - long int val; -#endif -{ - mp_size_t prec = __gmp_default_fp_limb_precision; - r->_mp_d = (mp_ptr) (*_mp_allocate_func) ((prec + 1) * BYTES_PER_MP_LIMB); - r->_mp_prec = prec; - - if (val > 0) - { - r->_mp_d[0] = val; - r->_mp_size = 1; - r->_mp_exp = 1; - } - else if (val < 0) - { - r->_mp_d[0] = -val; - r->_mp_size = -1; - r->_mp_exp = 1; - } - else - { - r->_mp_size = 0; - r->_mp_exp = 0; - } -} diff --git a/gnu/lib/libgmp/mpf/iset_str.c b/gnu/lib/libgmp/mpf/iset_str.c deleted file mode 100644 index 40bfe7c..0000000 --- a/gnu/lib/libgmp/mpf/iset_str.c +++ /dev/null @@ -1,40 +0,0 @@ -/* mpf_init_set_str -- Initialize a float and assign it from a string. - -Copyright (C) 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -int -#if __STDC__ -mpf_init_set_str (mpf_ptr r, const char *s, int base) -#else -mpf_init_set_str (r, s, base) - mpf_ptr r; - const char *s; - int base; -#endif -{ - mp_size_t prec = __gmp_default_fp_limb_precision; - r->_mp_d = (mp_ptr) (*_mp_allocate_func) ((prec + 1) * BYTES_PER_MP_LIMB); - r->_mp_prec = prec; - - return mpf_set_str (r, s, base); -} diff --git a/gnu/lib/libgmp/mpf/iset_ui.c b/gnu/lib/libgmp/mpf/iset_ui.c deleted file mode 100644 index c6c24af..0000000 --- a/gnu/lib/libgmp/mpf/iset_ui.c +++ /dev/null @@ -1,40 +0,0 @@ -/* mpf_init_set_ui() -- Initialize a float and assign it from an unsigned int. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_init_set_ui (mpf_ptr r, unsigned long int val) -#else -mpf_init_set_ui (r, val) - mpf_ptr r; - unsigned long int val; -#endif -{ - mp_size_t prec = __gmp_default_fp_limb_precision; - r->_mp_d = (mp_ptr) (*_mp_allocate_func) ((prec + 1) * BYTES_PER_MP_LIMB); - r->_mp_prec = prec; - r->_mp_d[0] = val; - r->_mp_size = val != 0; - r->_mp_exp = val != 0; -} diff --git a/gnu/lib/libgmp/mpf/mul.c b/gnu/lib/libgmp/mpf/mul.c deleted file mode 100644 index 8f1a2a9..0000000 --- a/gnu/lib/libgmp/mpf/mul.c +++ /dev/null @@ -1,94 +0,0 @@ -/* mpf_mul -- Multiply two floats. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_mul (mpf_ptr r, mpf_srcptr u, mpf_srcptr v) -#else -mpf_mul (r, u, v) - mpf_ptr r; - mpf_srcptr u; - mpf_srcptr v; -#endif -{ - mp_srcptr up, vp; - mp_size_t usize, vsize; - mp_size_t sign_product; - mp_size_t prec = r->_mp_prec; - TMP_DECL (marker); - - TMP_MARK (marker); - usize = u->_mp_size; - vsize = v->_mp_size; - sign_product = usize ^ vsize; - - usize = ABS (usize); - vsize = ABS (vsize); - - up = u->_mp_d; - vp = v->_mp_d; - if (usize > prec) - { - up += usize - prec; - usize = prec; - } - if (vsize > prec) - { - vp += vsize - prec; - vsize = prec; - } - - if (usize == 0 || vsize == 0) - { - r->_mp_size = 0; - r->_mp_exp = 0; /* ??? */ - } - else - { - mp_size_t rsize; - mp_limb_t cy_limb; - mp_ptr rp, tp; - mp_size_t adj; - - rsize = usize + vsize; - tp = (mp_ptr) TMP_ALLOC (rsize * BYTES_PER_MP_LIMB); - cy_limb = (usize >= vsize - ? mpn_mul (tp, up, usize, vp, vsize) - : mpn_mul (tp, vp, vsize, up, usize)); - - adj = cy_limb == 0; - rsize -= adj; - prec++; - if (rsize > prec) - { - tp += rsize - prec; - rsize = prec; - } - rp = r->_mp_d; - MPN_COPY (rp, tp, rsize); - r->_mp_exp = u->_mp_exp + v->_mp_exp - adj; - r->_mp_size = sign_product >= 0 ? rsize : -rsize; - } - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpf/mul_2exp.c b/gnu/lib/libgmp/mpf/mul_2exp.c deleted file mode 100644 index 0ed35a0..0000000 --- a/gnu/lib/libgmp/mpf/mul_2exp.c +++ /dev/null @@ -1,89 +0,0 @@ -/* mpf_mul_2exp -- Multiply a float by 2^n. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_mul_2exp (mpf_ptr r, mpf_srcptr u, unsigned long int exp) -#else -mpf_mul_2exp (r, u, exp) - mpf_ptr r; - mpf_srcptr u; - unsigned long int exp; -#endif -{ - mp_srcptr up; - mp_ptr rp = r->_mp_d; - mp_size_t usize; - mp_size_t abs_usize; - mp_size_t prec = r->_mp_prec; - mp_exp_t uexp = u->_mp_exp; - - usize = u->_mp_size; - - if (usize == 0) - { - r->_mp_size = 0; - r->_mp_exp = 0; - return; - } - - abs_usize = ABS (usize); - up = u->_mp_d; - - if (abs_usize > prec) - { - up += abs_usize - prec; - abs_usize = prec; - } - - if (exp % BITS_PER_MP_LIMB == 0) - { - if (rp != up) - MPN_COPY (rp, up, abs_usize); - r->_mp_size = usize >= 0 ? abs_usize : -abs_usize; - r->_mp_exp = uexp + exp / BITS_PER_MP_LIMB; - } - else - { - mp_limb_t cy_limb; - if (r != u) - { - cy_limb = mpn_lshift (rp, up, abs_usize, exp % BITS_PER_MP_LIMB); - rp[abs_usize] = cy_limb; - cy_limb = cy_limb != 0; - } - else - { - /* Use mpn_rshift since mpn_lshift operates downwards, and we - therefore would clobber part of U before using that part. */ - cy_limb = mpn_rshift (rp + 1, up, abs_usize, -exp % BITS_PER_MP_LIMB); - rp[0] = cy_limb; - cy_limb = rp[abs_usize] != 0; - } - - abs_usize += cy_limb; - r->_mp_size = usize >= 0 ? abs_usize : -abs_usize; - r->_mp_exp = uexp + exp / BITS_PER_MP_LIMB + cy_limb; - } -} diff --git a/gnu/lib/libgmp/mpf/mul_ui.c b/gnu/lib/libgmp/mpf/mul_ui.c deleted file mode 100644 index fc87cb5..0000000 --- a/gnu/lib/libgmp/mpf/mul_ui.c +++ /dev/null @@ -1,74 +0,0 @@ -/* mpf_mul_ui -- Multiply a float and an unsigned integer. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_mul_ui (mpf_ptr r, mpf_srcptr u, unsigned long int v) -#else -mpf_mul_ui (r, u, v) - mpf_ptr r; - mpf_srcptr u; - unsigned long int v; -#endif -{ - mp_srcptr up; - mp_size_t usize; - mp_size_t size; - mp_size_t prec = r->_mp_prec; - mp_limb_t cy_limb; - mp_ptr rp; - - usize = u->_mp_size; - size = ABS (usize); - - rp = r->_mp_d; - up = u->_mp_d; - if (size > prec) - { - up += size - prec; - size = prec; - } - -#if 0 - /* Since we can do it at almost no cost, remove zero limbs at low end of - result. */ - if (up[0] == 0) - up++, size--; -#endif - - if (size == 0 || v == 0) - { - r->_mp_size = 0; - r->_mp_exp = 0; /* ??? */ - } - else - { - cy_limb = mpn_mul_1 (rp, up, size, (mp_limb_t) v); - rp[size] = cy_limb; - cy_limb = cy_limb != 0; - r->_mp_exp = u->_mp_exp + cy_limb; - size += cy_limb; - r->_mp_size = usize >= 0 ? size : -size; - } -} diff --git a/gnu/lib/libgmp/mpf/neg.c b/gnu/lib/libgmp/mpf/neg.c deleted file mode 100644 index a4139fb..0000000 --- a/gnu/lib/libgmp/mpf/neg.c +++ /dev/null @@ -1,59 +0,0 @@ -/* mpf_neg -- Negate a float. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_neg (mpf_ptr r, mpf_srcptr u) -#else -mpf_neg (r, u) - mpf_ptr r; - mpf_srcptr u; -#endif -{ - mp_size_t size; - - size = -u->_mp_size; - if (r != u) - { - mp_size_t prec; - mp_size_t asize; - mp_ptr rp, up; - - prec = r->_mp_prec + 1; /* lie not to lose precision in assignment */ - asize = ABS (size); - rp = r->_mp_d; - up = u->_mp_d; - - if (asize > prec) - { - up += asize - prec; - asize = prec; - } - - MPN_COPY (rp, up, asize); - r->_mp_exp = u->_mp_exp; - size = size >= 0 ? asize : -asize; - } - r->_mp_size = size; -} diff --git a/gnu/lib/libgmp/mpf/out_str.c b/gnu/lib/libgmp/mpf/out_str.c deleted file mode 100644 index 2a7a954..0000000 --- a/gnu/lib/libgmp/mpf/out_str.c +++ /dev/null @@ -1,89 +0,0 @@ -/* mpf_out_str (stream, base, n_digits, op) -- Print N_DIGITS digits from - the float OP to STREAM in base BASE. Return the number of characters - written, or 0 if an error occurred. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" - -size_t -#if __STDC__ -mpf_out_str (FILE *stream, int base, size_t n_digits, mpf_srcptr op) -#else -mpf_out_str (stream, base, n_digits, op) - FILE *stream; - int base; - size_t n_digits; - mpf_srcptr op; -#endif -{ - char *str; - mp_exp_t exp; - size_t written; - TMP_DECL (marker); - - TMP_MARK (marker); - - if (base == 0) - base = 10; - if (n_digits == 0) - n_digits = (((op->_mp_prec - 1) * BITS_PER_MP_LIMB) - * __mp_bases[base].chars_per_bit_exactly); - - if (stream == 0) - stream = stdout; - - str = (char *) TMP_ALLOC (n_digits + 2); /* extra for minus sign and \0 */ - - mpf_get_str (str, &exp, base, n_digits, op); - n_digits = strlen (str); - - written = 0; - - /* Write sign */ - if (str[0] == '-') - { - str++; - fputc ('-', stream); - written = 1; - } - - fwrite ("0.", 1, 2, stream); - written += 2; - - /* Write mantissa */ - { - size_t fwret; - fwret = fwrite (str, 1, n_digits, stream); - written += fwret; - } - - /* Write exponent */ - { - int fpret; - fpret = fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), exp); - written += fpret; - } - - TMP_FREE (marker); - return ferror (stream) ? 0 : written; -} diff --git a/gnu/lib/libgmp/mpf/random2.c b/gnu/lib/libgmp/mpf/random2.c deleted file mode 100644 index 8e67b11..0000000 --- a/gnu/lib/libgmp/mpf/random2.c +++ /dev/null @@ -1,65 +0,0 @@ -/* mpf_random2 -- Generate a positive random mpf_t of specified size, with - long runs of consecutive ones and zeros in the binary representation. - Intended for testing of other MP routines. - -Copyright (C) 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -#if defined (__hpux) || defined (alpha__) || defined (__svr4__) || defined (__SVR4) -/* HPUX lacks random(). DEC OSF/1 1.2 random() returns a double. */ -long mrand48 (); -static inline long -random () -{ - return mrand48 (); -} -#else -long random (); -#endif - -void -#if __STDC__ -mpf_random2 (mpf_ptr x, mp_size_t size, mp_exp_t exp) -#else -mpf_random2 (x, size, exp) - mpf_ptr x; - mp_size_t size; - mp_exp_t exp; -#endif -{ - mp_size_t asize; - mp_size_t prec = x->_mp_prec; - - asize = ABS (size); - if (asize != 0) - { - if (asize > prec + 1) - asize = prec + 1; - - mpn_random2 (x->_mp_d, asize); - } - - if (exp != 0) - exp = random () % (2 * exp) - exp; - x->_mp_exp = asize == 0 ? 0 : exp; - x->_mp_size = size < 0 ? -asize : asize; -} diff --git a/gnu/lib/libgmp/mpf/reldiff.c b/gnu/lib/libgmp/mpf/reldiff.c deleted file mode 100644 index c846466..0000000 --- a/gnu/lib/libgmp/mpf/reldiff.c +++ /dev/null @@ -1,52 +0,0 @@ -/* mpf_reldiff -- Generate the relative difference of two floats. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_reldiff (mpf_t rdiff, mpf_srcptr x, mpf_srcptr y) -#else -mpf_reldiff (rdiff, x, y) - mpf_t rdiff; - mpf_srcptr x; - mpf_srcptr y; -#endif -{ - if (mpf_cmp_ui (x, 0) == 0) - { - mpf_set_ui (rdiff, (unsigned long int) (mpf_sgn (y) != 0)); - } - else - { - mpf_t d; - mp_limb_t tmp_limb[2]; - - d->_mp_prec = 1; - d->_mp_d = tmp_limb; - - mpf_sub (d, x, y); - mpf_abs (d, d); - mpf_div (rdiff, d, x); - } -} - diff --git a/gnu/lib/libgmp/mpf/set.c b/gnu/lib/libgmp/mpf/set.c deleted file mode 100644 index 5778b85..0000000 --- a/gnu/lib/libgmp/mpf/set.c +++ /dev/null @@ -1,53 +0,0 @@ -/* mpf_set -- Assign a float from another float. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_set (mpf_ptr r, mpf_srcptr u) -#else -mpf_set (r, u) - mpf_ptr r; - mpf_srcptr u; -#endif -{ - mp_ptr rp, up; - mp_size_t size, asize; - mp_size_t prec; - - prec = r->_mp_prec + 1; /* lie not to lose precision in assignment */ - size = u->_mp_size; - asize = ABS (size); - rp = r->_mp_d; - up = u->_mp_d; - - if (asize > prec) - { - up += asize - prec; - asize = prec; - } - - MPN_COPY (rp, up, asize); - r->_mp_exp = u->_mp_exp; - r->_mp_size = size >= 0 ? asize : -asize; -} diff --git a/gnu/lib/libgmp/mpf/set_d.c b/gnu/lib/libgmp/mpf/set_d.c deleted file mode 100644 index 43eb157..0000000 --- a/gnu/lib/libgmp/mpf/set_d.c +++ /dev/null @@ -1,47 +0,0 @@ -/* mpf_set_d -- Assign a float from a IEEE double. - -Copyright (C) 1993, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_set_d (mpf_ptr r, double d) -#else -mpf_set_d (r, d) - mpf_ptr r; - double d; -#endif -{ - int negative; - - if (d == 0) - { - SIZ(r) = 0; - EXP(r) = 0; - return; - } - negative = d < 0; - d = ABS (d); - - EXP(r) = __gmp_extract_double (PTR(r), d); - SIZ(r) = negative ? -LIMBS_PER_DOUBLE : LIMBS_PER_DOUBLE; -} diff --git a/gnu/lib/libgmp/mpf/set_dfl_prec.c b/gnu/lib/libgmp/mpf/set_dfl_prec.c deleted file mode 100644 index 55069e4..0000000 --- a/gnu/lib/libgmp/mpf/set_dfl_prec.c +++ /dev/null @@ -1,40 +0,0 @@ -/* mpf_set_default_prec -- - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -mp_size_t __gmp_default_fp_limb_precision - = (53 + 2 * BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB; - -void -#if __STDC__ -mpf_set_default_prec (unsigned long int prec_in_bits) -#else -mpf_set_default_prec (prec_in_bits) - unsigned long int prec_in_bits; -#endif -{ - mp_size_t prec; - - prec = (MAX (53, prec_in_bits) + 2 * BITS_PER_MP_LIMB - 1)/BITS_PER_MP_LIMB; - __gmp_default_fp_limb_precision = prec; -} diff --git a/gnu/lib/libgmp/mpf/set_prc.c b/gnu/lib/libgmp/mpf/set_prc.c deleted file mode 100644 index 10f2b06..0000000 --- a/gnu/lib/libgmp/mpf/set_prc.c +++ /dev/null @@ -1,57 +0,0 @@ -/* mpf_set_prec(x) -- Change the precision of x. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_set_prec (mpf_ptr x, unsigned long int prec_in_bits) -#else -mpf_set_prec (x, prec_in_bits) - mpf_ptr x; - unsigned long int prec_in_bits; -#endif -{ - mp_size_t prec; - mp_size_t size = ABS (x->_mp_size); - - prec = (MAX (53, prec_in_bits) + 2 * BITS_PER_MP_LIMB - 1)/BITS_PER_MP_LIMB; - - /* We want the most significant limbs, so move the limbs down if we are - about to truncate the value. */ - if (size > prec + 1) - { - mp_size_t offset = size - (prec + 1); - mp_ptr xp = x->_mp_d; - - MPN_COPY (xp, xp + offset, prec + 1); - } - - x->_mp_d = (mp_ptr) (*_mp_reallocate_func) - (x->_mp_d, - (x->_mp_prec + 1) * BYTES_PER_MP_LIMB, (prec + 1) * BYTES_PER_MP_LIMB); - x->_mp_prec = prec; - - /* If the precision decreased, truncate the number. */ - if (size > prec + 1) - x->_mp_size = x->_mp_size >= 0 ? (prec + 1) : -(prec + 1); -} diff --git a/gnu/lib/libgmp/mpf/set_prc_raw.c b/gnu/lib/libgmp/mpf/set_prc_raw.c deleted file mode 100644 index f55188a..0000000 --- a/gnu/lib/libgmp/mpf/set_prc_raw.c +++ /dev/null @@ -1,39 +0,0 @@ -/* mpf_set_prec_raw(x,bits) -- Change the precision of x without changing - allocation. For proper operation, the original precision need to be reset - sooner or later. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_set_prec_raw (mpf_ptr x, unsigned long int prec_in_bits) -#else -mpf_set_prec_raw (x, prec_in_bits) - mpf_ptr x; - unsigned long int prec_in_bits; -#endif -{ - mp_size_t prec; - prec = (MAX (53, prec_in_bits) + 2 * BITS_PER_MP_LIMB - 1)/BITS_PER_MP_LIMB; - x->_mp_prec = prec; -} diff --git a/gnu/lib/libgmp/mpf/set_q.c b/gnu/lib/libgmp/mpf/set_q.c deleted file mode 100644 index 69d81e3..0000000 --- a/gnu/lib/libgmp/mpf/set_q.c +++ /dev/null @@ -1,170 +0,0 @@ -/* mpf_set_q (mpf_t rop, mpq_t op) -- Convert the rational op to the float rop. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -/* Algorithm: - 1. Develop >= n bits of src.num / src.den, where n is the number of bits - in a double. This (partial) division will use all bits from the - denominator. - 2. Use the remainder to determine how to round the result. - 3. Assign the integral result to a temporary double. - 4. Scale the temporary double, and return the result. - - An alternative algorithm, that would be faster: - 0. Let n be somewhat larger than the number of significant bits in a double. - 1. Extract the most significant n bits of the denominator, and an equal - number of bits from the numerator. - 2. Interpret the extracted numbers as integers, call them a and b - respectively, and develop n bits of the fractions ((a + 1) / b) and - (a / (b + 1)) using mpn_divrem. - 3. If the computed values are identical UP TO THE POSITION WE CARE ABOUT, - we are done. If they are different, repeat the algorithm from step 1, - but first let n = n * 2. - 4. If we end up using all bits from the numerator and denominator, fall - back to the first algorithm above. - 5. Just to make life harder, The computation of a + 1 and b + 1 above - might give carry-out... Needs special handling. It might work to - subtract 1 in both cases instead. -*/ - -void -#if __STDC__ -mpf_set_q (mpf_t r, mpq_srcptr q) -#else -mpf_set_q (r, q) - mpf_t r; - mpq_srcptr q; -#endif -{ - mp_ptr np, dp; - mp_ptr rp; - mp_size_t nsize, dsize; - mp_size_t qsize, rsize; - mp_size_t sign_quotient; - unsigned normalization_steps; - mp_limb_t qlimb; - mp_ptr qp; - mp_size_t prec; - mp_exp_t exp; - TMP_DECL (marker); - - nsize = SIZ (&q->_mp_num); - dsize = SIZ (&q->_mp_den); - - if (nsize == 0) - { - SIZ (r) = 0; - EXP (r) = 0; - return; - } - - prec = PREC (r) + 1; - - TMP_MARK (marker); - - qp = PTR (r); - - sign_quotient = nsize ^ dsize; - nsize = ABS (nsize); - dsize = ABS (dsize); - np = PTR (&q->_mp_num); - dp = PTR (&q->_mp_den); - - exp = nsize - dsize; - - if (nsize > prec) - { - np += nsize - prec; - nsize = prec; - } - if (dsize > prec) - { - dp += dsize - prec; - dsize = prec; - } - - rsize = MAX (nsize, dsize); - rp = (mp_ptr) TMP_ALLOC ((rsize + 1) * BYTES_PER_MP_LIMB); - - count_leading_zeros (normalization_steps, dp[dsize - 1]); - - /* Normalize the denominator, i.e. make its most significant bit set by - shifting it NORMALIZATION_STEPS bits to the left. Also shift the - numerator the same number of steps (to keep the quotient the same!). */ - if (normalization_steps != 0) - { - mp_ptr tp; - mp_limb_t nlimb; - - /* Shift up the denominator setting the most significant bit of - the most significant limb. Use temporary storage not to clobber - the original contents of the denominator. */ - tp = (mp_ptr) TMP_ALLOC (dsize * BYTES_PER_MP_LIMB); - mpn_lshift (tp, dp, dsize, normalization_steps); - dp = tp; - - if (rsize != nsize) - { - MPN_ZERO (rp, rsize - nsize); - nlimb = mpn_lshift (rp + (rsize - nsize), - np, nsize, normalization_steps); - } - else - { - nlimb = mpn_lshift (rp, np, nsize, normalization_steps); - } - if (nlimb != 0) - { - rp[rsize] = nlimb; - rsize++; - exp++; - } - } - else - { - if (rsize != nsize) - { - MPN_ZERO (rp, rsize - nsize); - MPN_COPY (rp + (rsize - nsize), np, nsize); - } - else - { - MPN_COPY (rp, np, rsize); - } - } - - qlimb = mpn_divrem (qp, prec - 1 - (rsize - dsize), rp, rsize, dp, dsize); - qsize = prec - 1; - if (qlimb) - { - qp[qsize] = qlimb; - qsize++; - exp++; - } - - EXP (r) = exp; - SIZ (r) = qsize; - - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpf/set_si.c b/gnu/lib/libgmp/mpf/set_si.c deleted file mode 100644 index f9b4b55..0000000 --- a/gnu/lib/libgmp/mpf/set_si.c +++ /dev/null @@ -1,51 +0,0 @@ -/* mpf_set_si() -- Assign a float from a signed int. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_set_si (mpf_ptr x, long int val) -#else -mpf_set_si (x, val) - mpf_ptr x; - long int val; -#endif -{ - if (val > 0) - { - x->_mp_d[0] = val; - x->_mp_size = 1; - x->_mp_exp = 1; - } - else if (val < 0) - { - x->_mp_d[0] = -val; - x->_mp_size = -1; - x->_mp_exp = 1; - } - else - { - x->_mp_size = 0; - x->_mp_exp = 0; - } -} diff --git a/gnu/lib/libgmp/mpf/set_str.c b/gnu/lib/libgmp/mpf/set_str.c deleted file mode 100644 index 2ab9fae..0000000 --- a/gnu/lib/libgmp/mpf/set_str.c +++ /dev/null @@ -1,302 +0,0 @@ -/* mpf_set_str (dest, string, base) -- Convert the string STRING - in base BASE to a float in dest. If BASE is zero, the leading characters - of STRING is used to figure out the base. - -Copyright (C) 1993, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -long int strtol _PROTO ((const char *, char **ptr, int)); - -static int -digit_value_in_base (c, base) - int c; - int base; -{ - int digit; - - if (isdigit (c)) - digit = c - '0'; - else if (islower (c)) - digit = c - 'a' + 10; - else if (isupper (c)) - digit = c - 'A' + 10; - else - return -1; - - if (digit < base) - return digit; - return -1; -} - -int -#if __STDC__ -mpf_set_str (mpf_ptr x, const char *str, int base) -#else -mpf_set_str (x, str, base) - mpf_ptr x; - char *str; - int base; -#endif -{ - size_t str_size; - char *s, *begs; - size_t i; - mp_size_t xsize; - int c; - int negative; - char *dotpos = 0; - int expflag; - int decimal_exponent_flag; - TMP_DECL (marker); - - TMP_MARK (marker); - - c = *str; - - /* Skip whitespace. */ - while (isspace (c)) - c = *++str; - - negative = 0; - if (c == '-') - { - negative = 1; - c = *++str; - } - - decimal_exponent_flag = base < 0; - base = ABS (base); - - if (digit_value_in_base (c, base == 0 ? 10 : base) < 0) - return -1; /* error if no digits */ - - /* If BASE is 0, try to find out the base by looking at the initial - characters. */ - if (base == 0) - { - base = 10; -#if 0 - if (c == '0') - { - base = 8; - c = *++str; - if (c == 'x' || c == 'X') - base = 16; - } -#endif - } - - expflag = 0; - str_size = strlen (str); - for (i = 0; i < str_size; i++) - { - c = str[i]; - if (c == '@' || (base <= 10 && (c == 'e' || c == 'E'))) - { - expflag = 1; - str_size = i; - break; - } - - } - - s = begs = (char *) TMP_ALLOC (str_size + 1); - - for (i = 0; i < str_size; i++) - { - c = *str; - if (!isspace (c)) - { - int dig; - - if (c == '.') - { - if (dotpos != 0) - { - TMP_FREE (marker); - return -1; - } - dotpos = s; - } - else - { - dig = digit_value_in_base (c, base); - if (dig < 0) - { - TMP_FREE (marker); - return -1; - } - *s++ = dig; - } - } - c = *++str; - } - - str_size = s - begs; - - xsize = str_size / __mp_bases[base].chars_per_limb + 2; - { - long exp_in_base; - mp_size_t rsize, msize; - int cnt, i; - mp_ptr mp, xp, tp, rp; - mp_limb_t cy; - mp_exp_t exp_in_limbs; - mp_size_t prec = x->_mp_prec; - int divflag; - mp_size_t xxx = 0; - - mp = (mp_ptr) TMP_ALLOC (xsize * BYTES_PER_MP_LIMB); - msize = mpn_set_str (mp, (unsigned char *) begs, str_size, base); - - if (msize == 0) - { - x->_mp_size = 0; - x->_mp_exp = 0; - TMP_FREE (marker); - return 0; - } - - if (expflag != 0) - exp_in_base = strtol (str + 1, (char **) 0, - decimal_exponent_flag ? 10 : base); - else - exp_in_base = 0; - if (dotpos != 0) - exp_in_base -= s - dotpos; - divflag = exp_in_base < 0; - exp_in_base = ABS (exp_in_base); - - if (exp_in_base == 0) - { - MPN_COPY (x->_mp_d, mp, msize); - x->_mp_size = negative ? -msize : msize; - x->_mp_exp = msize; - TMP_FREE (marker); - return 0; - } - -#if 1 - rsize = (((mp_size_t) (exp_in_base / __mp_bases[base].chars_per_bit_exactly)) - / BITS_PER_MP_LIMB + 3); -#else - count_leading_zeros (cnt, (mp_limb_t) base); - rsize = exp_in_base - cnt * exp_in_base / BITS_PER_MP_LIMB + 1; -#endif - rp = (mp_ptr) TMP_ALLOC (rsize * BYTES_PER_MP_LIMB); - tp = (mp_ptr) TMP_ALLOC (rsize * BYTES_PER_MP_LIMB); - - rp[0] = base; - rsize = 1; - - count_leading_zeros (cnt, exp_in_base); - - for (i = BITS_PER_MP_LIMB - cnt - 2; i >= 0; i--) - { - mpn_mul_n (tp, rp, rp, rsize); - rsize = 2 * rsize; - rsize -= tp[rsize - 1] == 0; - xp = tp; tp = rp; rp = xp; - - if (((exp_in_base >> i) & 1) != 0) - { - cy = mpn_mul_1 (rp, rp, rsize, (mp_limb_t) base); - rp[rsize] = cy; - rsize += cy != 0; - } - } - - if (rsize > prec) - { - xxx += rsize - prec; - rp += rsize - prec; - rsize = prec; - } -#if 0 - if (msize > prec) - { - xxx -= msize - prec; - mp += msize - prec; - msize = prec; - } -#endif - if (divflag) - { - mp_ptr qp; - mp_limb_t qflag; - mp_size_t xtra; - if (msize <= rsize) - { - /* Allocate extra limb for current divrem sematics. */ - mp_ptr tmp = (mp_ptr) TMP_ALLOC ((rsize + 1) * BYTES_PER_MP_LIMB); - MPN_ZERO (tmp, rsize - msize); - MPN_COPY (tmp + rsize - msize, mp, msize); - mp = tmp; - xxx += rsize - msize; - msize = rsize; - } - count_leading_zeros (cnt, rp[rsize - 1]); - if (cnt != 0) - { - mpn_lshift (rp, rp, rsize, cnt); - cy = mpn_lshift (mp, mp, msize, cnt); - if (cy) - mp[msize++] = cy; - } - qp = (mp_ptr) TMP_ALLOC ((prec + 1) * BYTES_PER_MP_LIMB); - xtra = prec - (msize - rsize); - qflag = mpn_divrem (qp, xtra, mp, msize, rp, rsize); - qp[prec] = qflag; - tp = qp; - rsize = prec + qflag; - exp_in_limbs = rsize - xtra - xxx; - } - else - { - tp = (mp_ptr) TMP_ALLOC ((rsize + msize) * BYTES_PER_MP_LIMB); - if (rsize > msize) - mpn_mul (tp, rp, rsize, mp, msize); - else - mpn_mul (tp, mp, msize, rp, rsize); - rsize += msize; - rsize -= tp[rsize - 1] == 0; - exp_in_limbs = rsize + xxx; - - if (rsize > prec) - { - xxx = rsize - prec; - tp += rsize - prec; - rsize = prec; - exp_in_limbs += 0; - } - } - - MPN_COPY (x->_mp_d, tp, rsize); - x->_mp_size = negative ? -rsize : rsize; - x->_mp_exp = exp_in_limbs; - TMP_FREE (marker); - return 0; - } -} diff --git a/gnu/lib/libgmp/mpf/set_ui.c b/gnu/lib/libgmp/mpf/set_ui.c deleted file mode 100644 index ead0498..0000000 --- a/gnu/lib/libgmp/mpf/set_ui.c +++ /dev/null @@ -1,45 +0,0 @@ -/* mpf_set_ui() -- Assign a float from an unsigned int. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_set_ui (mpf_ptr x, unsigned long int val) -#else -mpf_set_ui (x, val) - mpf_ptr x; - unsigned long int val; -#endif -{ - if (val != 0) - { - x->_mp_d[0] = val; - x->_mp_size = 1; - x->_mp_exp = 1; - } - else - { - x->_mp_size = 0; - x->_mp_exp = 0; - } -} diff --git a/gnu/lib/libgmp/mpf/set_z.c b/gnu/lib/libgmp/mpf/set_z.c deleted file mode 100644 index 4fff86e..0000000 --- a/gnu/lib/libgmp/mpf/set_z.c +++ /dev/null @@ -1,54 +0,0 @@ -/* mpf_set_z -- Assign a float from an integer. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_set_z (mpf_ptr r, mpz_srcptr u) -#else -mpf_set_z (r, u) - mpf_ptr r; - mpz_srcptr u; -#endif -{ - mp_ptr rp, up; - mp_size_t size, asize; - mp_size_t prec; - - prec = PREC (r) + 1; - size = SIZ (u); - asize = ABS (size); - rp = PTR (r); - up = PTR (u); - - EXP (r) = asize; - - if (asize > prec) - { - up += asize - prec; - asize = prec; - } - - MPN_COPY (rp, up, asize); - SIZ (r) = size >= 0 ? asize : -asize; -} diff --git a/gnu/lib/libgmp/mpf/size.c b/gnu/lib/libgmp/mpf/size.c deleted file mode 100644 index 23a57ec..0000000 --- a/gnu/lib/libgmp/mpf/size.c +++ /dev/null @@ -1,35 +0,0 @@ -/* mpf_size(x) -- return the number of limbs currently used by the - value of the float X. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -size_t -#if __STDC__ -mpf_size (mpf_srcptr x) -#else -mpf_size (x) - mpf_srcptr x; -#endif -{ - return ABS (x->_mp_size); -} diff --git a/gnu/lib/libgmp/mpf/sqrt.c b/gnu/lib/libgmp/mpf/sqrt.c deleted file mode 100644 index 6d115e4..0000000 --- a/gnu/lib/libgmp/mpf/sqrt.c +++ /dev/null @@ -1,75 +0,0 @@ -/* mpf_sqrt -- Compute the square root of a float. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_sqrt (mpf_ptr r, mpf_srcptr u) -#else -mpf_sqrt (r, u) - mpf_ptr r; - mpf_srcptr u; -#endif -{ - mp_size_t usize; - mp_ptr up, tp; - mp_size_t prec; - mp_exp_t tsize, rexp; - TMP_DECL (marker); - - usize = u->_mp_size; - if (usize <= 0) - { - usize = 1 - 1 / (usize == 0); /* Divide by zero for negative OP. */ - r->_mp_size = usize; /* cheat flow by using usize here */ - r->_mp_exp = 0; - return; - } - - TMP_MARK (marker); - - prec = r->_mp_prec; - rexp = (u->_mp_exp + 1) >> 1; /* round towards -inf */ - tsize = 2 * prec + (u->_mp_exp & 1); - - up = u->_mp_d; - tp = (mp_ptr) TMP_ALLOC (tsize * BYTES_PER_MP_LIMB); - - if (usize > tsize) - { - up += usize - tsize; - usize = tsize; - MPN_COPY (tp, up, tsize); - } - else - { - MPN_ZERO (tp, tsize - usize); - MPN_COPY (tp + (tsize - usize), up, usize); - } - - mpn_sqrtrem (r->_mp_d, NULL, tp, tsize); - - r->_mp_size = (tsize + 1) / 2; - r->_mp_exp = rexp; - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpf/sqrt_ui.c b/gnu/lib/libgmp/mpf/sqrt_ui.c deleted file mode 100644 index 421aa021..0000000 --- a/gnu/lib/libgmp/mpf/sqrt_ui.c +++ /dev/null @@ -1,61 +0,0 @@ -/* mpf_sqrt_ui -- Compute the square root of an unsigned integer. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_sqrt_ui (mpf_ptr r, unsigned long int u) -#else -mpf_sqrt_ui (r, u) - mpf_ptr r; - unsigned long int u; -#endif -{ - mp_size_t rsize; - mp_ptr tp; - mp_size_t prec; - TMP_DECL (marker); - - if (u == 0) - { - r->_mp_size = 0; - r->_mp_exp = 0; - return; - } - - TMP_MARK (marker); - - prec = r->_mp_prec; - rsize = 2 * prec + 1; - - tp = (mp_ptr) TMP_ALLOC (rsize * BYTES_PER_MP_LIMB); - - MPN_ZERO (tp, rsize - 1); - tp[rsize - 1] = u; - - mpn_sqrtrem (r->_mp_d, NULL, tp, rsize); - - r->_mp_size = prec + 1; - r->_mp_exp = 1; - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpf/sub.c b/gnu/lib/libgmp/mpf/sub.c deleted file mode 100644 index b871982..0000000 --- a/gnu/lib/libgmp/mpf/sub.c +++ /dev/null @@ -1,402 +0,0 @@ -/* mpf_sub -- Subtract two floats. - -Copyright (C) 1993, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_sub (mpf_ptr r, mpf_srcptr u, mpf_srcptr v) -#else -mpf_sub (r, u, v) - mpf_ptr r; - mpf_srcptr u; - mpf_srcptr v; -#endif -{ - mp_srcptr up, vp; - mp_ptr rp, tp; - mp_size_t usize, vsize, rsize; - mp_size_t prec; - mp_exp_t exp; - mp_size_t ediff; - int negate; - TMP_DECL (marker); - - usize = u->_mp_size; - vsize = v->_mp_size; - - /* Handle special cases that don't work in generic code below. */ - if (usize == 0) - { - mpf_neg (r, v); - return; - } - if (vsize == 0) - { - mpf_set (r, u); - return; - } - - /* If signs of U and V are different, perform addition. */ - if ((usize ^ vsize) < 0) - { - __mpf_struct v_negated; - v_negated._mp_size = -vsize; - v_negated._mp_exp = v->_mp_exp; - v_negated._mp_d = v->_mp_d; - mpf_add (r, u, &v_negated); - return; - } - - TMP_MARK (marker); - - /* Signs are now known to be the same. */ - negate = usize < 0; - - /* Make U be the operand with the largest exponent. */ - if (u->_mp_exp < v->_mp_exp) - { - mpf_srcptr t; - t = u; u = v; v = t; - negate ^= 1; - usize = u->_mp_size; - vsize = v->_mp_size; - } - - usize = ABS (usize); - vsize = ABS (vsize); - up = u->_mp_d; - vp = v->_mp_d; - rp = r->_mp_d; - prec = r->_mp_prec + 1; - exp = u->_mp_exp; - ediff = u->_mp_exp - v->_mp_exp; - - /* If ediff is 0 or 1, we might have a situation where the operands are - extremely close. We need to scan the operands from the most significant - end ignore the initial parts that are equal. */ - if (ediff <= 1) - { - if (ediff == 0) - { - /* Skip leading limbs in U and V that are equal. */ - if (up[usize - 1] == vp[vsize - 1]) - { - /* This loop normally exits immediately. Optimize for that. */ - do - { - usize--; - vsize--; - exp--; - - if (usize == 0) - { - rsize = vsize; - tp = (mp_ptr) vp; - negate ^= 1; - goto normalize; - } - if (vsize == 0) - { - rsize = usize; - tp = (mp_ptr) up; - goto normalize; - } - } - while (up[usize - 1] == vp[vsize - 1]); - } - - if (up[usize - 1] < vp[vsize - 1]) - { - /* For simplicity, swap U and V. Note that since the loop above - wouldn't have exited unless up[usize - 1] and vp[vsize - 1] - were non-equal, this if-statement catches all cases where U - is smaller than V. */ - { mp_srcptr tp = up; up = vp; vp = tp; } - { mp_size_t tsize = usize; usize = vsize; vsize = tsize; } - negate ^= 1; - /* negating ediff not necessary since it is 0. */ - } - - /* Check for - x+1 00000000 ... - x ffffffff ... */ - if (up[usize - 1] != vp[vsize - 1] + 1) - goto general_case; - usize--; - vsize--; - exp--; - } - else /* ediff == 1 */ - { - /* Check for - 1 00000000 ... - 0 ffffffff ... */ - - if (up[usize - 1] != 1 || vp[vsize - 1] != ~(mp_limb_t) 0 - || (usize >= 2 && up[usize - 2] != 0)) - goto general_case; - - usize--; - exp--; - } - - /* Skip sequences of 00000000/ffffffff */ - while (vsize != 0 && usize != 0 && up[usize - 1] == 0 - && vp[vsize - 1] == ~(mp_limb_t) 0) - { - usize--; - vsize--; - exp--; - } - - if (usize == 0) - { - while (vsize != 0 && vp[vsize - 1] == ~(mp_limb_t) 0) - { - vsize--; - exp--; - } - } - - if (usize > prec - 1) - { - up += usize - (prec - 1); - usize = prec - 1; - } - if (vsize > prec - 1) - { - vp += vsize - (prec - 1); - vsize = prec - 1; - } - - tp = (mp_ptr) TMP_ALLOC (prec * BYTES_PER_MP_LIMB); - { - mp_limb_t cy_limb; - if (vsize == 0) - { - mp_size_t size, i; - size = usize; - for (i = 0; i < size; i++) - tp[i] = up[i]; - tp[size] = 1; - rsize = size + 1; - exp++; - goto normalize; - } - if (usize == 0) - { - mp_size_t size, i; - size = vsize; - for (i = 0; i < size; i++) - tp[i] = ~vp[i]; - cy_limb = 1 - mpn_add_1 (tp, tp, vsize, (mp_limb_t) 1); - rsize = vsize; - if (cy_limb == 0) - { - tp[rsize] = 1; - rsize++; - exp++; - } - goto normalize; - } - if (usize >= vsize) - { - /* uuuu */ - /* vv */ - mp_size_t size; - size = usize - vsize; - MPN_COPY (tp, up, size); - cy_limb = mpn_sub_n (tp + size, up + size, vp, vsize); - rsize = usize; - } - else /* (usize < vsize) */ - { - /* uuuu */ - /* vvvvvvv */ - mp_size_t size, i; - size = vsize - usize; - for (i = 0; i < size; i++) - tp[i] = ~vp[i]; - cy_limb = mpn_sub_n (tp + size, up, vp + size, usize); - cy_limb+= mpn_sub_1 (tp + size, tp + size, usize, (mp_limb_t) 1); - cy_limb-= mpn_add_1 (tp, tp, vsize, (mp_limb_t) 1); - rsize = vsize; - } - if (cy_limb == 0) - { - tp[rsize] = 1; - rsize++; - exp++; - } - goto normalize; - } - } - -general_case: - /* If U extends beyond PREC, ignore the part that does. */ - if (usize > prec) - { - up += usize - prec; - usize = prec; - } - - /* If V extends beyond PREC, ignore the part that does. - Note that this may make vsize negative. */ - if (vsize + ediff > prec) - { - vp += vsize + ediff - prec; - vsize = prec - ediff; - } - - /* Allocate temp space for the result. Allocate - just vsize + ediff later??? */ - tp = (mp_ptr) TMP_ALLOC (prec * BYTES_PER_MP_LIMB); - - if (ediff >= prec) - { - /* V completely cancelled. */ - if (tp != up) - MPN_COPY (rp, up, usize); - rsize = usize; - } - else - { - /* Locate the least significant non-zero limb in (the needed - parts of) U and V, to simplify the code below. */ - for (;;) - { - if (vsize == 0) - { - MPN_COPY (rp, up, usize); - rsize = usize; - goto done; - } - if (vp[0] != 0) - break; - vp++, vsize--; - } - for (;;) - { - if (usize == 0) - { - MPN_COPY (rp, vp, vsize); - rsize = vsize; - negate ^= 1; - goto done; - } - if (up[0] != 0) - break; - up++, usize--; - } - - /* uuuu | uuuu | uuuu | uuuu | uuuu */ - /* vvvvvvv | vv | vvvvv | v | vv */ - - if (usize > ediff) - { - /* U and V partially overlaps. */ - if (ediff == 0) - { - /* Have to compare the leading limbs of u and v - to determine whether to compute u - v or v - u. */ - if (usize >= vsize) - { - /* uuuu */ - /* vv */ - mp_size_t size; - size = usize - vsize; - MPN_COPY (tp, up, size); - mpn_sub_n (tp + size, up + size, vp, vsize); - rsize = usize; - } - else /* (usize < vsize) */ - { - /* uuuu */ - /* vvvvvvv */ - mp_size_t size, i; - size = vsize - usize; - tp[0] = -vp[0]; - for (i = 1; i < size; i++) - tp[i] = ~vp[i]; - mpn_sub_n (tp + size, up, vp + size, usize); - mpn_sub_1 (tp + size, tp + size, usize, (mp_limb_t) 1); - rsize = vsize; - } - } - else - { - if (vsize + ediff <= usize) - { - /* uuuu */ - /* v */ - mp_size_t size; - size = usize - ediff - vsize; - MPN_COPY (tp, up, size); - mpn_sub (tp + size, up + size, usize - size, vp, vsize); - rsize = usize; - } - else - { - /* uuuu */ - /* vvvvv */ - mp_size_t size, i; - size = vsize + ediff - usize; - tp[0] = -vp[0]; - for (i = 1; i < size; i++) - tp[i] = ~vp[i]; - mpn_sub (tp + size, up, usize, vp + size, usize - ediff); - mpn_sub_1 (tp + size, tp + size, usize, (mp_limb_t) 1); - rsize = vsize + ediff; - } - } - } - else - { - /* uuuu */ - /* vv */ - mp_size_t size, i; - size = vsize + ediff - usize; - tp[0] = -vp[0]; - for (i = 1; i < vsize; i++) - tp[i] = ~vp[i]; - for (i = vsize; i < size; i++) - tp[i] = ~(mp_limb_t) 0; - mpn_sub_1 (tp + size, up, usize, (mp_limb_t) 1); - rsize = size + usize; - } - - normalize: - /* Full normalize. Optimize later. */ - while (rsize != 0 && tp[rsize - 1] == 0) - { - rsize--; - exp--; - } - MPN_COPY (rp, tp, rsize); - } - - done: - r->_mp_size = negate ? -rsize : rsize; - r->_mp_exp = exp; - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpf/sub_ui.c b/gnu/lib/libgmp/mpf/sub_ui.c deleted file mode 100644 index 7806213..0000000 --- a/gnu/lib/libgmp/mpf/sub_ui.c +++ /dev/null @@ -1,49 +0,0 @@ -/* mpf_sub_ui -- Subtract an unsigned integer from a float. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_sub_ui (mpf_ptr sum, mpf_srcptr u, unsigned long int v) -#else -mpf_sub_ui (sum, u, v) - mpf_ptr sum; - mpf_srcptr u; - unsigned long int v; -#endif -{ - __mpf_struct vv; - mp_limb_t vl; - - if (v == 0) - { - mpf_set (sum, u); - return; - } - - vl = v; - vv._mp_size = 1; - vv._mp_d = &vl; - vv._mp_exp = 1; - mpf_sub (sum, u, &vv); -} diff --git a/gnu/lib/libgmp/mpf/tests/Makefile.in b/gnu/lib/libgmp/mpf/tests/Makefile.in deleted file mode 100644 index e108b9e..0000000 --- a/gnu/lib/libgmp/mpf/tests/Makefile.in +++ /dev/null @@ -1,75 +0,0 @@ -# Makefile for mpf/tests for GNU MP - -srcdir = . - -CC = gcc - -TEST_LIBS = ../../libgmp.a -INCLUDES = -I../../mpn -I$(srcdir)/../.. -CFLAGS = -g -O - -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(XCFLAGS) $< - -TEST_SRCS = t-add.c t-sub.c t-conv.c t-sqrt.c t-muldiv.c t-dm2exp.c t-reuse.c ref.c -TEST_OBJS = t-add.o t-sub.o t-conv.o t-sqrt.o t-muldiv.o t-dm2exp.c reuse.o -TESTS = t-add t-sub t-conv t-sqrt t-muldiv t-dm2exp reuse - -check: Makefile st-add st-sub st-conv st-sqrt st-muldiv st-dm2exp st-reuse - @echo "The tests passed." - -st-add: t-add - ./t-add - touch $@ -st-sub: t-sub - ./t-sub - touch $@ -st-conv: t-conv - ./t-conv - touch $@ -st-sqrt: t-sqrt - ./t-sqrt - touch $@ -st-muldiv: t-muldiv - ./t-muldiv - touch $@ -st-dm2exp: t-dm2exp - ./t-dm2exp - touch $@ -st-reuse: reuse - ./reuse - touch $@ - -H = $(srcdir)/../../gmp.h $(srcdir)/../../gmp-impl.h \ - $(srcdir)/../../urandom.h ../../mpn/gmp-mparam.h - -t-add: t-add.o ref.o $(TEST_LIBS) - $(CC) -o $@ $@.o ref.o $(TEST_LIBS) $(CFLAGS) -t-sub: t-sub.o ref.o $(TEST_LIBS) - $(CC) -o $@ $@.o ref.o $(TEST_LIBS) $(CFLAGS) -t-conv: t-conv.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -t-sqrt: t-sqrt.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -t-muldiv: t-muldiv.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -t-dm2exp: t-dm2exp.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -reuse: reuse.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) - -t-add.o: $(srcdir)/t-add.c -t-sub.o: $(srcdir)/t-sub.c -t-conv.o: $(srcdir)/t-conv.c -t-sqrt.o: $(srcdir)/t-sqrt.c -t-muldiv.o: $(srcdir)/t-muldiv.c -t-dm2exp.o: $(srcdir)/t-dm2exp.c -reuse.o: $(srcdir)/reuse.c - -clean mostlyclean: - rm -f *.o st-* $(TESTS) -distclean maintainer-clean: clean - rm -f Makefile config.status - -Makefile: $(srcdir)/Makefile.in - $(SHELL) ./config.status diff --git a/gnu/lib/libgmp/mpf/tests/configure.in b/gnu/lib/libgmp/mpf/tests/configure.in deleted file mode 100644 index 319219c..0000000 --- a/gnu/lib/libgmp/mpf/tests/configure.in +++ /dev/null @@ -1,11 +0,0 @@ -# This file is a shell script that supplies the information necessary -# to tailor a template configure script into the configure script -# appropriate for this directory. For more information, check any -# existing configure script. - -srctrigger=t-add.c -srcname="gmp/mpf/tests" - -# per-host: - -# per-target: diff --git a/gnu/lib/libgmp/mpf/tests/ref.c b/gnu/lib/libgmp/mpf/tests/ref.c deleted file mode 100644 index b2c3e6c..0000000 --- a/gnu/lib/libgmp/mpf/tests/ref.c +++ /dev/null @@ -1,203 +0,0 @@ -/* Reference floating point routines. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -#if __STDC__ -void ref_mpf_add (mpf_t, const mpf_t, const mpf_t); -void ref_mpf_sub (mpf_t, const mpf_t, const mpf_t); -#else -void ref_mpf_add (); -void ref_mpf_sub (); -#endif - -void -#if __STDC__ -ref_mpf_add (mpf_t w, const mpf_t u, const mpf_t v) -#else -ref_mpf_add (w, u, v) - mpf_t w; - const mpf_t u; - const mpf_t v; -#endif -{ - mp_size_t hi, lo, size; - mp_ptr ut, vt, wt; - int neg; - mp_exp_t exp; - mp_limb_t cy; - TMP_DECL (mark); - - TMP_MARK (mark); - - if (SIZ (u) == 0) - { - size = ABSIZ (v); - wt = (mp_ptr) TMP_ALLOC (size * BYTES_PER_MP_LIMB); - MPN_COPY (wt, PTR (v), size); - exp = EXP (v); - neg = SIZ (v) < 0; - goto done; - } - if (SIZ (v) == 0) - { - size = ABSIZ (u); - wt = (mp_ptr) TMP_ALLOC (size * BYTES_PER_MP_LIMB); - MPN_COPY (wt, PTR (u), size); - exp = EXP (u); - neg = SIZ (u) < 0; - goto done; - } - if ((SIZ (u) ^ SIZ (v)) < 0) - { - mpf_t tmp; - SIZ (tmp) = -SIZ (v); - EXP (tmp) = EXP (v); - PTR (tmp) = PTR (v); - ref_mpf_sub (w, u, tmp); - return; - } - neg = SIZ (u) < 0; - - /* Compute the significance of the hi and lo end of the result. */ - hi = MAX (EXP (u), EXP (v)); - lo = MIN (EXP (u) - ABSIZ (u), EXP (v) - ABSIZ (v)); - size = hi - lo; - ut = (mp_ptr) TMP_ALLOC ((size + 1) * BYTES_PER_MP_LIMB); - vt = (mp_ptr) TMP_ALLOC ((size + 1) * BYTES_PER_MP_LIMB); - wt = (mp_ptr) TMP_ALLOC ((size + 1) * BYTES_PER_MP_LIMB); - MPN_ZERO (ut, size); - MPN_ZERO (vt, size); - {int off; - off = size + (EXP (u) - hi) - ABSIZ (u); - MPN_COPY (ut + off, PTR (u), ABSIZ (u)); - off = size + (EXP (v) - hi) - ABSIZ (v); - MPN_COPY (vt + off, PTR (v), ABSIZ (v)); - } - - cy = mpn_add_n (wt, ut, vt, size); - wt[size] = cy; - size += cy; - exp = hi + cy; - -done: - if (size > PREC (w)) - { - wt += size - PREC (w); - size = PREC (w); - } - MPN_COPY (PTR (w), wt, size); - SIZ (w) = neg == 0 ? size : -size; - EXP (w) = exp; - TMP_FREE (mark); -} - -void -#if __STDC__ -ref_mpf_sub (mpf_t w, const mpf_t u, const mpf_t v) -#else -ref_mpf_sub (w, u, v) - mpf_t w; - const mpf_t u; - const mpf_t v; -#endif -{ - mp_size_t hi, lo, size; - mp_ptr ut, vt, wt; - int neg; - mp_exp_t exp; - TMP_DECL (mark); - - TMP_MARK (mark); - - if (SIZ (u) == 0) - { - size = ABSIZ (v); - wt = (mp_ptr) TMP_ALLOC (size * BYTES_PER_MP_LIMB); - MPN_COPY (wt, PTR (v), size); - exp = EXP (v); - neg = SIZ (v) > 0; - goto done; - } - if (SIZ (v) == 0) - { - size = ABSIZ (u); - wt = (mp_ptr) TMP_ALLOC (size * BYTES_PER_MP_LIMB); - MPN_COPY (wt, PTR (u), size); - exp = EXP (u); - neg = SIZ (u) < 0; - goto done; - } - if ((SIZ (u) ^ SIZ (v)) < 0) - { - mpf_t tmp; - SIZ (tmp) = -SIZ (v); - EXP (tmp) = EXP (v); - PTR (tmp) = PTR (v); - ref_mpf_add (w, u, tmp); - if (SIZ (u) < 0) - mpf_neg (w, w); - return; - } - neg = SIZ (u) < 0; - - /* Compute the significance of the hi and lo end of the result. */ - hi = MAX (EXP (u), EXP (v)); - lo = MIN (EXP (u) - ABSIZ (u), EXP (v) - ABSIZ (v)); - size = hi - lo; - ut = (mp_ptr) TMP_ALLOC ((size + 1) * BYTES_PER_MP_LIMB); - vt = (mp_ptr) TMP_ALLOC ((size + 1) * BYTES_PER_MP_LIMB); - wt = (mp_ptr) TMP_ALLOC ((size + 1) * BYTES_PER_MP_LIMB); - MPN_ZERO (ut, size); - MPN_ZERO (vt, size); - {int off; - off = size + (EXP (u) - hi) - ABSIZ (u); - MPN_COPY (ut + off, PTR (u), ABSIZ (u)); - off = size + (EXP (v) - hi) - ABSIZ (v); - MPN_COPY (vt + off, PTR (v), ABSIZ (v)); - } - - if (mpn_cmp (ut, vt, size) >= 0) - mpn_sub_n (wt, ut, vt, size); - else - { - mpn_sub_n (wt, vt, ut, size); - neg ^= 1; - } - exp = hi; - while (size != 0 && wt[size - 1] == 0) - { - size--; - exp--; - } - -done: - if (size > PREC (w)) - { - wt += size - PREC (w); - size = PREC (w); - } - MPN_COPY (PTR (w), wt, size); - SIZ (w) = neg == 0 ? size : -size; - EXP (w) = exp; - TMP_FREE (mark); -} diff --git a/gnu/lib/libgmp/mpf/tests/reuse.c b/gnu/lib/libgmp/mpf/tests/reuse.c deleted file mode 100644 index 6829cc4..0000000 --- a/gnu/lib/libgmp/mpf/tests/reuse.c +++ /dev/null @@ -1,186 +0,0 @@ -/* Test that routines allow reusing a source variable as destination. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -#ifndef SIZE -#define SIZE 16 -#endif - -#ifndef EXPO -#define EXPO 32 -#endif - -#if __STDC__ -typedef void (*dss_func) (mpf_ptr, mpf_srcptr, mpf_srcptr); -#else -typedef void (*dss_func) (); -#endif - -dss_func dss_funcs[] = -{ - mpf_div, mpf_add, mpf_mul, mpf_sub, -}; - -char *dss_func_names[] = -{ - "mpf_div", "mpf_add", "mpf_mul", "mpf_sub", -}; - -#if __STDC__ -typedef void (*dsi_func) (mpf_ptr, mpf_srcptr, unsigned long int); -#else -typedef void (*dsi_func) (); -#endif - -dsi_func dsi_funcs[] = -{ - mpf_div_ui, mpf_add_ui, mpf_mul_ui, mpf_sub_ui, -}; - -char *dsi_func_names[] = -{ - "mpf_div_ui", "mpf_add_ui", "mpf_mul_ui", "mpf_sub_ui", -}; - -#if __STDC__ -typedef void (*dis_func) (mpf_ptr, unsigned long int, mpf_srcptr); -#else -typedef void (*dis_func) (); -#endif - -dis_func dis_funcs[] = -{ - mpf_ui_div, mpf_ui_sub, -}; - -char *dis_func_names[] = -{ - "mpf_ui_div", "mpf_ui_sub", -}; - -main (argc, argv) - int argc; - char **argv; -{ - int i; - int pass, reps = 100000; - mpf_t in1, in2, out1; - unsigned long int in1i, in2i; - mpf_t res1, res2, res3; - mp_size_t bprec = 100; - - if (argc > 1) - { - reps = strtol (argv[1], 0, 0); - if (argc > 2) - bprec = strtol (argv[2], 0, 0); - } - - mpf_set_default_prec (bprec); - - mpf_init (in1); - mpf_init (in2); - mpf_init (out1); - mpf_init (res1); - mpf_init (res2); - mpf_init (res3); - - for (pass = 1; pass <= reps; pass++) - { - mpf_random2 (in1, urandom () % SIZE - SIZE/2, urandom () % EXPO); - mpf_random2 (in2, urandom () % SIZE - SIZE/2, urandom () % EXPO); - - for (i = 0; i < sizeof (dss_funcs) / sizeof (dss_func); i++) - { - /* Don't divide by 0. */ - if (i == 0 && mpf_cmp_ui (in2, 0) == 0) - continue; - - (dss_funcs[i]) (res1, in1, in2); - - mpf_set (out1, in1); - (dss_funcs[i]) (out1, out1, in2); - mpf_set (res2, out1); - - mpf_set (out1, in2); - (dss_funcs[i]) (out1, in1, out1); - mpf_set (res3, out1); - - if (mpf_cmp (res1, res2) != 0) - dump_abort (dss_func_names[i], res1, res2); - if (mpf_cmp (res1, res3) != 0) - dump_abort (dss_func_names[i], res1, res3); - } - - in2i = urandom (); - for (i = 0; i < sizeof (dsi_funcs) / sizeof (dsi_func); i++) - { - /* Don't divide by 0. */ - if (i == 0 && in2i == 0) - continue; - - (dsi_funcs[i]) (res1, in1, in2i); - - mpf_set (out1, in1); - (dsi_funcs[i]) (out1, out1, in2i); - mpf_set (res2, out1); - - if (mpf_cmp (res1, res2) != 0) - dump_abort (dsi_func_names[i], res1, res2); - } - - in1i = urandom (); - for (i = 0; i < sizeof (dis_funcs) / sizeof (dis_func); i++) - { - /* Don't divide by 0. */ - if (i == 0 && mpf_cmp_ui (in2, 0) == 0) - continue; - - (dis_funcs[i]) (res1, in1i, in2); - - mpf_set (out1, in2); - (dis_funcs[i]) (out1, in1i, in2); - mpf_set (res2, out1); - - if (mpf_cmp (res1, res2) != 0) - dump_abort (dis_func_names[i], res1, res2); - } - - } - - exit (0); -} - -dump_abort (name, res1, res2) - char *name; - mpf_t res1, res2; -{ - printf ("failure in %s:", name); - oo (res1); - oo (res2); - abort (); -} - -oo (x) - mpf_t x; -{ - mp_size_t i; - printf (" exp = %ld\n", x->_mp_exp); - printf ("size = %d\n", x->_mp_size); - for (i = ABS (x->_mp_size) - 1; i >= 0; i--) - printf ("%08lX ", x->_mp_d[i]); - printf ("\n"); - mpf_dump (x); -} - -#if 0 -void mpf_div_2exp _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int)); -void mpf_mul_2exp _PROTO ((mpf_ptr, mpf_srcptr, unsigned long int)); - -void mpf_abs _PROTO ((mpf_ptr, mpf_srcptr)); -void mpf_sqrt _PROTO ((mpf_ptr, mpf_srcptr)); -void mpf_neg _PROTO ((mpf_ptr, mpf_srcptr)); -#endif diff --git a/gnu/lib/libgmp/mpf/tests/t-add.c b/gnu/lib/libgmp/mpf/tests/t-add.c deleted file mode 100644 index 6f985bb..0000000 --- a/gnu/lib/libgmp/mpf/tests/t-add.c +++ /dev/null @@ -1,117 +0,0 @@ -/* Test mpf_add. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -#ifndef SIZE -#define SIZE 16 -#endif - -#if __STDC__ -void ref_mpf_add (mpf_t, const mpf_t, const mpf_t); -void ref_mpf_sub (mpf_t, const mpf_t, const mpf_t); -#else -void ref_mpf_add (); -void ref_mpf_sub (); -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mp_size_t size; - mp_exp_t exp; - int reps = 100000; - int i; - mpf_t u, v, w, wref; - mp_size_t bprec = 100; - mpf_t rerr, max_rerr, limit_rerr; - - if (argc > 1) - { - reps = strtol (argv[1], 0, 0); - if (argc > 2) - bprec = strtol (argv[2], 0, 0); - } - - mpf_set_default_prec (bprec); - - mpf_init_set_ui (limit_rerr, 1); - mpf_div_2exp (limit_rerr, limit_rerr, bprec); -#if VERBOSE - mpf_dump (limit_rerr); -#endif - mpf_init (rerr); - mpf_init_set_ui (max_rerr, 0); - - mpf_init (u); - mpf_init (v); - mpf_init (w); - mpf_init (wref); - for (i = 0; i < reps; i++) - { - size = urandom () % (2 * SIZE) - SIZE; - exp = urandom () % SIZE; - mpf_random2 (u, size, exp); - - size = urandom () % (2 * SIZE) - SIZE; - exp = urandom () % SIZE; - mpf_random2 (v, size, exp); - - mpf_add (w, u, v); - ref_mpf_add (wref, u, v); - - mpf_reldiff (rerr, w, wref); - if (mpf_cmp (rerr, max_rerr) > 0) - { - mpf_set (max_rerr, rerr); -#if VERBOSE - mpf_dump (max_rerr); -#endif - if (mpf_cmp (rerr, limit_rerr) > 0) - { - printf ("ERROR after %d tests\n", i); - printf (" u = "); mpf_dump (u); - printf (" v = "); mpf_dump (v); - printf ("wref = "); mpf_dump (wref); - printf (" w = "); mpf_dump (w); - abort (); - } - } - } - - exit (0); -} - -oo (x) - mpf_t x; -{ - mp_size_t i; - printf (" exp = %ld\n", x->_mp_exp); - printf ("size = %d\n", x->_mp_size); - for (i = ABS (x->_mp_size) - 1; i >= 0; i--) - printf ("%08lX ", x->_mp_d[i]); - printf ("\n"); - mpf_dump (x); -} diff --git a/gnu/lib/libgmp/mpf/tests/t-conv.c b/gnu/lib/libgmp/mpf/tests/t-conv.c deleted file mode 100644 index 00d461d..0000000 --- a/gnu/lib/libgmp/mpf/tests/t-conv.c +++ /dev/null @@ -1,120 +0,0 @@ -/* Test mpf_get_str and mpf_set_str. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -#ifndef SIZE -#define SIZE 10 -#endif - -#ifndef EXPO -#define EXPO 20 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpf_t x, y; - int reps = 20000; - int i; - mp_size_t bprec = 100; - mpf_t d, rerr, max_rerr, limit_rerr; - char *str; - long bexp; - long size, exp; - int base; - char buf[SIZE * BITS_PER_MP_LIMB + 5]; - - if (argc > 1) - { - reps = strtol (argv[1], 0, 0); - if (argc > 2) - bprec = strtol (argv[2], 0, 0); - } - - mpf_set_default_prec (bprec); - - mpf_init_set_ui (limit_rerr, 1); - mpf_div_2exp (limit_rerr, limit_rerr, bprec); -#if VERBOSE - mpf_dump (limit_rerr); -#endif - mpf_init (rerr); - mpf_init_set_ui (max_rerr, 0); - - mpf_init (x); - mpf_init (y); - mpf_init (d); - - for (i = 0; i < reps; i++) - { - size = urandom () % (2 * SIZE) - SIZE; - exp = urandom () % EXPO; - mpf_random2 (x, size, exp); - - base = urandom () % 35 + 2; - - str = mpf_get_str (0, &bexp, base, 0, x); - - if (str[0] == '-') - sprintf (buf, "-0.%s@%ld", str + 1, bexp); - else - sprintf (buf, "0.%s@%ld", str, bexp); - - mpf_set_str (y, buf, -base); - free (str); - - mpf_reldiff (rerr, x, y); - if (mpf_cmp (rerr, max_rerr) > 0) - { - mpf_set (max_rerr, rerr); -#if VERBOSE - mpf_dump (max_rerr); -#endif - if (mpf_cmp (rerr, limit_rerr) > 0) - { - printf ("ERROR after %d tests\n", i); - printf ("base = %d\n", base); - printf (" x = "); mpf_dump (x); - printf (" y = "); mpf_dump (y); - abort (); - } - } - } - - exit (0); -} - -oo (x) - mpf_t x; -{ - int i; - printf (" exp = %ld\n", x->_mp_exp); - printf ("size = %d\n", x->_mp_size); - for (i = ABS (x->_mp_size) - 1; i >= 0; i--) - printf ("%08lX ", x->_mp_d[i]); - printf ("\n"); - mpf_dump (x); -} diff --git a/gnu/lib/libgmp/mpf/tests/t-dm2exp.c b/gnu/lib/libgmp/mpf/tests/t-dm2exp.c deleted file mode 100644 index a8c4e8f..0000000 --- a/gnu/lib/libgmp/mpf/tests/t-dm2exp.c +++ /dev/null @@ -1,101 +0,0 @@ -/* Test mpf_div, mpf_div_2exp, mpf_mul_2exp. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -#ifndef SIZE -#define SIZE 16 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - int reps = 500000; - int i; - mpf_t u, v, w1, w2; - mp_size_t bprec = 100; - mpf_t rerr, limit_rerr; - - if (argc > 1) - { - reps = strtol (argv[1], 0, 0); - if (argc > 2) - bprec = strtol (argv[2], 0, 0); - } - - mpf_set_default_prec (bprec); - - mpf_init (rerr); - mpf_init (limit_rerr); - - mpf_init (u); - mpf_init (v); - mpf_init (w1); - mpf_init (w2); - - for (i = 0; i < reps; i++) - { - mp_size_t res_prec; - unsigned long int pow2; - - res_prec = urandom () % (bprec + 100); - mpf_set_prec (w1, res_prec); - mpf_set_prec (w2, res_prec); - - mpf_set_ui (limit_rerr, 1); - mpf_div_2exp (limit_rerr, limit_rerr, res_prec); - - pow2 = urandom () % 0x10000; - mpf_set_ui (v, 1); - mpf_mul_2exp (v, v, pow2); - - mpf_div_2exp (w1, u, pow2); - mpf_div (w2, u, v); - mpf_reldiff (rerr, w1, w2); - if (mpf_cmp (rerr, limit_rerr) > 0) - { - printf ("ERROR in mpf_div or mpf_div_2exp after %d tests\n", i); - printf (" u = "); mpf_dump (u); - printf (" v = "); mpf_dump (v); - printf (" w1 = "); mpf_dump (w1); - printf (" w2 = "); mpf_dump (w2); - abort (); - } - } - - exit (0); -} - -oo (x) - mpf_t x; -{ - mp_size_t i; - printf (" exp = %ld\n", x->_mp_exp); - printf ("size = %d\n", x->_mp_size); - for (i = ABS (x->_mp_size) - 1; i >= 0; i--) - printf ("%08lX ", x->_mp_d[i]); - printf ("\n"); - mpf_dump (x); -} diff --git a/gnu/lib/libgmp/mpf/tests/t-muldiv.c b/gnu/lib/libgmp/mpf/tests/t-muldiv.c deleted file mode 100644 index d1721e8..0000000 --- a/gnu/lib/libgmp/mpf/tests/t-muldiv.c +++ /dev/null @@ -1,161 +0,0 @@ -/* Test mpf_mul, mpf_div, mpf_ui_div, and mpf_div_ui. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -#ifndef SIZE -#define SIZE 16 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mp_size_t size; - mp_exp_t exp; - int reps = 100000; - int i; - mpf_t u, v, w, x; - mp_size_t bprec = 100; - mpf_t rerr, limit_rerr; - mp_limb_t ulimb, vlimb; - int single_flag; - - if (argc > 1) - { - reps = strtol (argv[1], 0, 0); - if (argc > 2) - bprec = strtol (argv[2], 0, 0); - } - - mpf_set_default_prec (bprec); - - mpf_init (rerr); - mpf_init (limit_rerr); - - mpf_init (u); - mpf_init (v); - mpf_init (w); - mpf_init (x); - - for (i = 0; i < reps; i++) - { - mp_size_t res_prec; - - res_prec = urandom () % (bprec + 100); - mpf_set_prec (w, res_prec); - mpf_set_prec (x, res_prec); - - mpf_set_ui (limit_rerr, 1); - mpf_div_2exp (limit_rerr, limit_rerr, res_prec); - - single_flag = 0; - - if ((urandom () & 1) != 0) - { - size = urandom () % (2 * SIZE) - SIZE; - exp = urandom () % SIZE; - mpf_random2 (u, size, exp); - } - else - { - ulimb = urandom (); - mpf_set_ui (u, ulimb); - single_flag = 1; - } - - if ((urandom () & 1) != 0) - { - size = urandom () % (2 * SIZE) - SIZE; - exp = urandom () % SIZE; - mpf_random2 (v, size, exp); - } - else - { - vlimb = urandom (); - mpf_set_ui (v, vlimb); - single_flag = 2; - } - - if (mpf_sgn (v) == 0) - continue; - - mpf_div (w, u, v); - mpf_mul (x, w, v); - mpf_reldiff (rerr, u, x); - if (mpf_cmp (rerr, limit_rerr) > 0) - { - printf ("ERROR in mpf_mul or mpf_div after %d tests\n", i); - printf (" u = "); mpf_dump (u); - printf (" v = "); mpf_dump (v); - printf (" x = "); mpf_dump (x); - printf (" w = "); mpf_dump (w); - abort (); - } - - if (single_flag == 2) - { - mpf_div_ui (x, u, vlimb); - mpf_reldiff (rerr, w, x); - if (mpf_cmp (rerr, limit_rerr) > 0) - { - printf ("ERROR in mpf_div or mpf_div_ui after %d tests\n", i); - printf (" u = "); mpf_dump (u); - printf (" v = "); mpf_dump (v); - printf (" x = "); mpf_dump (x); - printf (" w = "); mpf_dump (w); - abort (); - } - } - - if (single_flag == 1) - { - mpf_ui_div (x, ulimb, v); - mpf_reldiff (rerr, w, x); - if (mpf_cmp (rerr, limit_rerr) > 0) - { - printf ("ERROR in mpf_div or mpf_ui_div after %d tests\n", i); - printf (" u = "); mpf_dump (u); - printf (" v = "); mpf_dump (v); - printf (" x = "); mpf_dump (x); - printf (" w = "); mpf_dump (w); - abort (); - } - } - } - - exit (0); -} - -oo (x) - mpf_t x; -{ - mp_size_t i; - printf (" exp = %ld\n", x->_mp_exp); - printf ("size = %d\n", x->_mp_size); - for (i = ABS (x->_mp_size) - 1; i >= 0; i--) - printf ("%08lX ", x->_mp_d[i]); - printf ("\n"); - mpf_dump (x); -} diff --git a/gnu/lib/libgmp/mpf/tests/t-sqrt.c b/gnu/lib/libgmp/mpf/tests/t-sqrt.c deleted file mode 100644 index 5c72ab5..0000000 --- a/gnu/lib/libgmp/mpf/tests/t-sqrt.c +++ /dev/null @@ -1,103 +0,0 @@ -/* Test mpf_sqrt, mpf_mul. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -#ifndef SIZE -#define SIZE 16 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mp_size_t size; - mp_exp_t exp; - int reps = 100000; - int i; - mpf_t x, y, y2; - mp_size_t bprec = 100; - mpf_t rerr, max_rerr, limit_rerr; - - if (argc > 1) - { - reps = strtol (argv[1], 0, 0); - if (argc > 2) - bprec = strtol (argv[2], 0, 0); - } - - mpf_set_default_prec (bprec); - - mpf_init_set_ui (limit_rerr, 1); - mpf_div_2exp (limit_rerr, limit_rerr, bprec); -#if VERBOSE - mpf_dump (limit_rerr); -#endif - mpf_init (rerr); - mpf_init_set_ui (max_rerr, 0); - - mpf_init (x); - mpf_init (y); - mpf_init (y2); - for (i = 0; i < reps; i++) - { - size = urandom () % SIZE; - exp = urandom () % SIZE; - mpf_random2 (x, size, exp); - - mpf_sqrt (y, x); - mpf_mul (y2, y, y); - - mpf_reldiff (rerr, x, y2); - if (mpf_cmp (rerr, max_rerr) > 0) - { - mpf_set (max_rerr, rerr); -#if VERBOSE - mpf_dump (max_rerr); -#endif - if (mpf_cmp (rerr, limit_rerr) > 0) - { - printf ("ERROR after %d tests\n", i); - printf (" x = "); mpf_dump (x); - printf (" y = "); mpf_dump (y); - printf (" y2 = "); mpf_dump (y2); - abort (); - } - } - } - - exit (0); -} - -oo (x) - mpf_t x; -{ - mp_size_t i; - printf (" exp = %ld\n", x->_mp_exp); - printf ("size = %d\n", x->_mp_size); - for (i = ABS (x->_mp_size) - 1; i >= 0; i--) - printf ("%08lX ", x->_mp_d[i]); - printf ("\n"); - mpf_dump (x); -} diff --git a/gnu/lib/libgmp/mpf/tests/t-sub.c b/gnu/lib/libgmp/mpf/tests/t-sub.c deleted file mode 100644 index 6918866..0000000 --- a/gnu/lib/libgmp/mpf/tests/t-sub.c +++ /dev/null @@ -1,122 +0,0 @@ -/* Test mpf_sub. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -#ifndef SIZE -#define SIZE 16 -#endif - -#if __STDC__ -void ref_mpf_add (mpf_t, const mpf_t, const mpf_t); -void ref_mpf_sub (mpf_t, const mpf_t, const mpf_t); -#else -void ref_mpf_add (); -void ref_mpf_sub (); -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mp_size_t size; - mp_exp_t exp; - int reps = 500000; - int i; - mpf_t u, v, w, wref; - mp_size_t bprec = 100; - mpf_t rerr, max_rerr, limit_rerr; - - if (argc > 1) - { - reps = strtol (argv[1], 0, 0); - if (argc > 2) - bprec = strtol (argv[2], 0, 0); - } - - mpf_set_default_prec (bprec); - - mpf_init_set_ui (limit_rerr, 1); - mpf_div_2exp (limit_rerr, limit_rerr, bprec); -#if VERBOSE - mpf_dump (limit_rerr); -#endif - mpf_init (rerr); - mpf_init_set_ui (max_rerr, 0); - - mpf_init (u); - mpf_init (v); - mpf_init (w); - mpf_init (wref); - for (i = 0; i < reps; i++) - { - size = urandom () % (2 * SIZE) - SIZE; - exp = urandom () % SIZE; - mpf_random2 (u, size, exp); - - size = urandom () % (2 * SIZE) - SIZE; - exp = urandom () % SIZE; - mpf_random2 (v, size, exp); - - if ((urandom () & 1) != 0) - mpf_add_ui (u, v, 1); - else if ((urandom () & 1) != 0) - mpf_sub_ui (u, v, 1); - - mpf_sub (w, u, v); - ref_mpf_sub (wref, u, v); - - mpf_reldiff (rerr, w, wref); - if (mpf_cmp (rerr, max_rerr) > 0) - { - mpf_set (max_rerr, rerr); -#if VERBOSE - mpf_dump (max_rerr); -#endif - if (mpf_cmp (rerr, limit_rerr) > 0) - { - printf ("ERROR after %d tests\n", i); - printf (" u = "); mpf_dump (u); - printf (" v = "); mpf_dump (v); - printf ("wref = "); mpf_dump (wref); - printf (" w = "); mpf_dump (w); - abort (); - } - } - } - - exit (0); -} - -oo (x) - mpf_t x; -{ - mp_size_t i; - printf (" exp = %ld\n", x->_mp_exp); - printf ("size = %d\n", x->_mp_size); - for (i = ABS (x->_mp_size) - 1; i >= 0; i--) - printf ("%08lX ", x->_mp_d[i]); - printf ("\n"); - mpf_dump (x); -} diff --git a/gnu/lib/libgmp/mpf/ui_div.c b/gnu/lib/libgmp/mpf/ui_div.c deleted file mode 100644 index a49a952..0000000 --- a/gnu/lib/libgmp/mpf/ui_div.c +++ /dev/null @@ -1,131 +0,0 @@ -/* mpf_ui_div -- Divide an unsigned integer with a float. - -Copyright (C) 1993, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void -#if __STDC__ -mpf_ui_div (mpf_ptr r, unsigned long int u, mpf_srcptr v) -#else -mpf_ui_div (r, u, v) - mpf_ptr r; - unsigned long int u; - mpf_srcptr v; -#endif -{ - mp_srcptr vp; - mp_ptr rp, tp; - mp_size_t vsize; - mp_size_t rsize, tsize; - mp_size_t sign_quotient; - mp_size_t prec; - unsigned normalization_steps; - mp_limb_t q_limb; - mp_exp_t rexp; - TMP_DECL (marker); - - vsize = v->_mp_size; - sign_quotient = vsize; - vsize = ABS (vsize); - prec = r->_mp_prec; - - if (vsize == 0) - vsize = 1 / vsize; /* divide by zero as directed */ - if (u == 0) - { - r->_mp_size = 0; - r->_mp_exp = 0; - return; - } - - TMP_MARK (marker); - rexp = 1 - v->_mp_exp; - - rp = r->_mp_d; - vp = v->_mp_d; - - if (vsize > prec) - { - vp += vsize - prec; - vsize = prec; - } - - tsize = vsize + prec; - tp = (mp_ptr) TMP_ALLOC ((tsize + 1) * BYTES_PER_MP_LIMB); - MPN_ZERO (tp, tsize); - - count_leading_zeros (normalization_steps, vp[vsize - 1]); - - /* Normalize the divisor and the dividend. */ - if (normalization_steps != 0) - { - mp_ptr tmp; - mp_limb_t dividend_high, dividend_low; - - /* Shift up the divisor setting the most significant bit of - the most significant limb. Use temporary storage not to clobber - the original contents of the divisor. */ - tmp = (mp_ptr) TMP_ALLOC (vsize * BYTES_PER_MP_LIMB); - mpn_lshift (tmp, vp, vsize, normalization_steps); - vp = tmp; - - /* Shift up the dividend, possibly introducing a new most - significant word. */ - dividend_high = (mp_limb_t) u >> (BITS_PER_MP_LIMB - normalization_steps); - dividend_low = (mp_limb_t) u << normalization_steps; - - tp[tsize - 1] = dividend_low; - if (dividend_high != 0) - { - tp[tsize] = dividend_high; - tsize++; - rexp++; - } - } - else - { - /* The divisor is already normalized, as required. - Copy it to temporary space if it overlaps with the quotient. */ - if (vp - rp <= tsize - vsize) - { - mp_ptr tmp = (mp_ptr) TMP_ALLOC (vsize * BYTES_PER_MP_LIMB); - MPN_COPY (tmp, vp, vsize); - vp = (mp_srcptr) tmp; - } - - tp[tsize - 1] = u; - } - - q_limb = mpn_divmod (rp, tp, tsize, vp, vsize); - rsize = tsize - vsize; - if (q_limb) - { - rp[rsize] = q_limb; - rsize++; - rexp++; - } - - r->_mp_size = sign_quotient >= 0 ? rsize : -rsize; - r->_mp_exp = rexp; - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpf/ui_sub.c b/gnu/lib/libgmp/mpf/ui_sub.c deleted file mode 100644 index acb9210..0000000 --- a/gnu/lib/libgmp/mpf/ui_sub.c +++ /dev/null @@ -1,334 +0,0 @@ -/* mpf_ui_sub -- Subtract a float from an unsigned long int. - -Copyright (C) 1993, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpf_ui_sub (mpf_ptr r, unsigned long int u, mpf_srcptr v) -#else -mpf_ui_sub (r, u, v) - mpf_ptr r; - unsigned long int u; - mpf_srcptr v; -#endif -{ - mp_srcptr up, vp; - mp_ptr rp, tp; - mp_size_t usize, vsize, rsize; - mp_size_t prec; - mp_exp_t uexp; - mp_size_t ediff; - int negate; - mp_limb_t ulimb; - TMP_DECL (marker); - - vsize = v->_mp_size; - - /* Handle special cases that don't work in generic code below. */ - if (u == 0) - { - mpf_neg (r, v); - return; - } - if (vsize == 0) - { - mpf_set_ui (r, u); - return; - } - - /* If signs of U and V are different, perform addition. */ - if (vsize < 0) - { - __mpf_struct v_negated; - v_negated._mp_size = -vsize; - v_negated._mp_exp = v->_mp_exp; - v_negated._mp_d = v->_mp_d; - mpf_add_ui (r, &v_negated, u); - return; - } - - TMP_MARK (marker); - - /* Signs are now known to be the same. */ - - ulimb = u; - /* Make U be the operand with the largest exponent. */ - if (1 < v->_mp_exp) - { - negate = 1; - usize = ABS (vsize); - vsize = 1; - up = v->_mp_d; - vp = &ulimb; - rp = r->_mp_d; - prec = r->_mp_prec + 1; - uexp = v->_mp_exp; - ediff = uexp - 1; - } - else - { - negate = 0; - usize = 1; - vsize = ABS (vsize); - up = &ulimb; - vp = v->_mp_d; - rp = r->_mp_d; - prec = r->_mp_prec; - uexp = 1; - ediff = 1 - v->_mp_exp; - } - - /* Ignore leading limbs in U and V that are equal. Doing - this helps increase the precision of the result. */ - if (ediff == 0) - { - /* This loop normally exits immediately. Optimize for that. */ - for (;;) - { - usize--; - vsize--; - if (up[usize] != vp[vsize]) - break; - uexp--; - if (usize == 0) - goto Lu0; - if (vsize == 0) - goto Lv0; - } - usize++; - vsize++; - /* Note that either operand (but not both operands) might now have - leading zero limbs. It matters only that U is unnormalized if - vsize is now zero, and vice versa. And it is only in that case - that we have to adjust uexp. */ - if (vsize == 0) - Lv0: - while (usize != 0 && up[usize - 1] == 0) - usize--, uexp--; - if (usize == 0) - Lu0: - while (vsize != 0 && vp[vsize - 1] == 0) - vsize--, uexp--; - } - - /* If U extends beyond PREC, ignore the part that does. */ - if (usize > prec) - { - up += usize - prec; - usize = prec; - } - - /* If V extends beyond PREC, ignore the part that does. - Note that this may make vsize negative. */ - if (vsize + ediff > prec) - { - vp += vsize + ediff - prec; - vsize = prec - ediff; - } - - /* Allocate temp space for the result. Allocate - just vsize + ediff later??? */ - tp = (mp_ptr) TMP_ALLOC (prec * BYTES_PER_MP_LIMB); - - if (ediff >= prec) - { - /* V completely cancelled. */ - if (tp != up) - MPN_COPY (rp, up, usize); - rsize = usize; - } - else - { - /* Locate the least significant non-zero limb in (the needed - parts of) U and V, to simplify the code below. */ - for (;;) - { - if (vsize == 0) - { - MPN_COPY (rp, up, usize); - rsize = usize; - goto done; - } - if (vp[0] != 0) - break; - vp++, vsize--; - } - for (;;) - { - if (usize == 0) - { - MPN_COPY (rp, vp, vsize); - rsize = vsize; - negate ^= 1; - goto done; - } - if (up[0] != 0) - break; - up++, usize--; - } - - /* uuuu | uuuu | uuuu | uuuu | uuuu */ - /* vvvvvvv | vv | vvvvv | v | vv */ - - if (usize > ediff) - { - /* U and V partially overlaps. */ - if (ediff == 0) - { - /* Have to compare the leading limbs of u and v - to determine whether to compute u - v or v - u. */ - if (usize > vsize) - { - /* uuuu */ - /* vv */ - int cmp; - cmp = mpn_cmp (up + usize - vsize, vp, vsize); - if (cmp >= 0) - { - mp_size_t size; - size = usize - vsize; - MPN_COPY (tp, up, size); - mpn_sub_n (tp + size, up + size, vp, vsize); - rsize = usize; - } - else - { - /* vv */ /* Swap U and V. */ - /* uuuu */ - mp_size_t size, i; - size = usize - vsize; - tp[0] = -up[0]; - for (i = 1; i < size; i++) - tp[i] = ~up[i]; - mpn_sub_n (tp + size, vp, up + size, vsize); - mpn_sub_1 (tp + size, tp + size, vsize, (mp_limb_t) 1); - negate ^= 1; - rsize = usize; - } - } - else if (usize < vsize) - { - /* uuuu */ - /* vvvvvvv */ - int cmp; - cmp = mpn_cmp (up, vp + vsize - usize, usize); - if (cmp > 0) - { - mp_size_t size, i; - size = vsize - usize; - tp[0] = -vp[0]; - for (i = 1; i < size; i++) - tp[i] = ~vp[i]; - mpn_sub_n (tp + size, up, vp + size, usize); - mpn_sub_1 (tp + size, tp + size, usize, (mp_limb_t) 1); - rsize = vsize; - } - else - { - /* vvvvvvv */ /* Swap U and V. */ - /* uuuu */ - /* This is the only place we can get 0.0. */ - mp_size_t size; - size = vsize - usize; - MPN_COPY (tp, vp, size); - mpn_sub_n (tp + size, vp + size, up, usize); - negate ^= 1; - rsize = vsize; - } - } - else - { - /* uuuu */ - /* vvvv */ - int cmp; - cmp = mpn_cmp (up, vp + vsize - usize, usize); - if (cmp > 0) - { - mpn_sub_n (tp, up, vp, usize); - rsize = usize; - } - else - { - mpn_sub_n (tp, vp, up, usize); - negate ^= 1; - rsize = usize; - /* can give zero */ - } - } - } - else - { - if (vsize + ediff <= usize) - { - /* uuuu */ - /* v */ - mp_size_t size; - size = usize - ediff - vsize; - MPN_COPY (tp, up, size); - mpn_sub (tp + size, up + size, usize - size, vp, vsize); - rsize = usize; - } - else - { - /* uuuu */ - /* vvvvv */ - mp_size_t size, i; - size = vsize + ediff - usize; - tp[0] = -vp[0]; - for (i = 1; i < size; i++) - tp[i] = ~vp[i]; - mpn_sub (tp + size, up, usize, vp + size, usize - ediff); - mpn_sub_1 (tp + size, tp + size, usize, (mp_limb_t) 1); - rsize = vsize + ediff; - } - } - } - else - { - /* uuuu */ - /* vv */ - mp_size_t size, i; - size = vsize + ediff - usize; - tp[0] = -vp[0]; - for (i = 1; i < vsize; i++) - tp[i] = ~vp[i]; - for (i = vsize; i < size; i++) - tp[i] = ~(mp_limb_t) 0; - mpn_sub_1 (tp + size, up, usize, (mp_limb_t) 1); - rsize = size + usize; - } - - /* Full normalize. Optimize later. */ - while (rsize != 0 && tp[rsize - 1] == 0) - { - rsize--; - uexp--; - } - MPN_COPY (rp, tp, rsize); - } - - done: - r->_mp_size = negate ? -rsize : rsize; - r->_mp_exp = uexp; - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpn/Makefile.in b/gnu/lib/libgmp/mpn/Makefile.in deleted file mode 100644 index 132159b..0000000 --- a/gnu/lib/libgmp/mpn/Makefile.in +++ /dev/null @@ -1,92 +0,0 @@ -# Makefile for GNU MP/mpn functions -# Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -# the Free Software Foundation; either version 2 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 Library General Public -# License for more details. - -# You should have received a copy of the GNU Library General Public License -# along with the GNU MP Library; see the file COPYING.LIB. If not, write to -# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA. - -srcdir = . - -MPN_OBJECTS = This gets filled in by configure.in. -MPN_LINKS = This gets filled in by configure.in. -CC = gcc -CPP = $(CC) -E -CFLAGS = -g -O -INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. -AR = ar -AR_FLAGS = rc -SFLAGS= - -#### host and target specific makefile fragments come in here. -### - -libmpn.a: Makefile mp_bases.o $(MPN_OBJECTS) - rm -f $@ - $(AR) $(AR_FLAGS) $@ mp_bases.o $(MPN_OBJECTS) - -.SUFFIXES: .c .s .S - -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(XCFLAGS) $< - -.s.o: - $(CC) -c $(CFLAGS) $< - -.S.o: - $(CPP) $(SFLAGS) $(INCLUDES) $(CFLAGS) $< | grep -v '^#' >tmp-$*.s - $(CC) -c tmp-$*.s -o $@ - rm -f tmp-$*.s - -clean mostlyclean: - rm -f *.o tmp-* libmpn.a - #-cd tests; $(MAKE) $@ -distclean maintainer-clean: clean - rm -f asm-syntax.h Makefile config.status $(MPN_LINKS) - -cd tests; $(MAKE) $@ - -Makefile: $(srcdir)/Makefile.in - $(SHELL) ./config.status - - -# Maybe configure could add dependencies here..? - -H = $(srcdir)/../gmp.h $(srcdir)/../gmp-impl.h gmp-mparam.h -L = $(srcdir)/../longlong.h - -mp_bases.o: $(srcdir)/mp_bases.c $(H) -bdivmod.o: bdivmod.c $(H) $(L) -cmp.o: cmp.c $(H) -divmod_1.o: divmod_1.c $(H) $(L) -divrem.o: divrem.c $(H) $(L) -divrem_1.o: divrem_1.c $(H) $(L) -dump.o: dump.c $(H) -gcd.o: gcd.c $(H) $(L) -gcd_1.o: gcd_1.c $(H) $(L) -gcdext.o: gcdext.c $(H) $(L) -get_str.o: get_str.c $(H) $(L) -hamdist.o: hamdist.c $(H) -inlines.o: inlines.c $(srcdir)/../gmp.h -mod_1.o: mod_1.c $(H) $(L) -mul.o: mul.c $(H) -mul_n.o: mul_n.c $(H) -perfsqr.o: perfsqr.c $(H) $(L) -popcount.o: popcount.c $(H) -pre_mod_1.o: pre_mod_1.c $(H) $(L) -random2.o: random2.c $(H) -scan0.o: scan0.c $(H) $(L) -scan1.o: scan1.c $(H) $(L) -set_str.o: set_str.c $(H) -sqrtrem.o: sqrtrem.c $(H) $(L) diff --git a/gnu/lib/libgmp/mpn/README b/gnu/lib/libgmp/mpn/README deleted file mode 100644 index 3da559e..0000000 --- a/gnu/lib/libgmp/mpn/README +++ /dev/null @@ -1,15 +0,0 @@ -This directory contains all code for the mpn layer of GMP. - -Most subdirectories contain machine-dependent code, written in assembly or -C. The `generic' subdirectory contains default code, used when there is no -machine-dependent replacement for a particular machine. - -There is one subdirectory for each architecture. Note that e.g., 32-bit -sparc and 64-bit sparc cannot share any code, and are therefore considered -completely different architecture. - -A particular machine will only use code from one such subdirectory, and the -`generic' subdirectory. The architecture-specific subdirectory contains a -hierachy of directories for various architecture variants and -implementations; the top-most level contains code that runs correctly on all -variants. diff --git a/gnu/lib/libgmp/mpn/bsd.h b/gnu/lib/libgmp/mpn/bsd.h deleted file mode 100644 index 8a0cbce..0000000 --- a/gnu/lib/libgmp/mpn/bsd.h +++ /dev/null @@ -1,5 +0,0 @@ -#if __STDC__ -#define C_SYMBOL_NAME(name) _##name -#else -#define C_SYMBOL_NAME(name) _/**/name -#endif diff --git a/gnu/lib/libgmp/mpn/config/t-oldgas b/gnu/lib/libgmp/mpn/config/t-oldgas deleted file mode 100644 index ba02fa7..0000000 --- a/gnu/lib/libgmp/mpn/config/t-oldgas +++ /dev/null @@ -1 +0,0 @@ -SFLAGS=-DBROKEN_ALIGN diff --git a/gnu/lib/libgmp/mpn/config/t-ppc-aix b/gnu/lib/libgmp/mpn/config/t-ppc-aix deleted file mode 100644 index a31ce0d..0000000 --- a/gnu/lib/libgmp/mpn/config/t-ppc-aix +++ /dev/null @@ -1 +0,0 @@ -SFLAGS=-Wa,-mppc diff --git a/gnu/lib/libgmp/mpn/config/t-pwr-aix b/gnu/lib/libgmp/mpn/config/t-pwr-aix deleted file mode 100644 index 3e11d9f..0000000 --- a/gnu/lib/libgmp/mpn/config/t-pwr-aix +++ /dev/null @@ -1 +0,0 @@ -SFLAGS=-Wa,-mpwr diff --git a/gnu/lib/libgmp/mpn/configure.in b/gnu/lib/libgmp/mpn/configure.in deleted file mode 100644 index 90c2626..0000000 --- a/gnu/lib/libgmp/mpn/configure.in +++ /dev/null @@ -1,178 +0,0 @@ -# This file is a shell script fragment that supplies the information -# necessary for a configure script to process the program in -# this directory. For more information, look at ../configure. - -configdirs= -srctrigger=powerpc32 -srcname="GNU Multi-Precision library/mpn" - -# per-host: - -# per-target: - -case "${target}" in - sparc9*-*-* | sparc64*-*-* | ultrasparc*-*-*) - #path="sparc64" ;; Don't use this until compilers are ready - path="sparc32/v8 sparc" ;; - sparc8*-*-* | microsparc*-*-*) - path="sparc32/v8 sparc" ;; - supersparc*-*-*) - path="sparc32/v8/supersparc sparc32/v8 sparc" - extra_functions="udiv" ;; - sparc*-*-*) path="sparc32" - if [ x$floating_point = xno ] - then extra_functions="udiv_nfp" - else extra_functions="udiv_fp" - fi - ;; - hppa7000*-*-*) path="hppa/hppa1_1 hppa"; extra_functions="udiv_qrnnd" ;; - hppa1.0*-*-*) path="hppa"; extra_functions="udiv_qrnnd" ;; - hppa*-*-*) # assume pa7100 - path="hppa/hppa1_1/pa7100 hppa/hppa1_1 hppa" - extra_functions="udiv_qrnnd" ;; - cray2-cray-unicos* | [xy]mp-cray-unicos* | [ctj]90-cray-unicos*) - path="cray" ;; - alphaev5-*-*) path="alpha/ev5 alpha"; extra_functions="udiv_qrnnd" ;; - alpha*-*-*) path="alpha"; extra_functions="udiv_qrnnd" ;; - am29000*-*-*) path="am29000" ;; - a29k*-*-*) path="am29000" ;; - -# Intel x86 configurations - i[34]86*-*-linuxaout* | i[34]86*-*-linuxoldld* | \ - i[34]86*-*-*bsd*) # x86 running BSD or Linux with a.out - echo '#define BSD_SYNTAX' >asm-syntax.h - echo '#include "'$srcdir'/x86/syntax.h"' >>asm-syntax.h - path="x86" ;; - i[56]86*-*-linuxaout* | pentium-*-linuxaout* | pentiumpro-*-linuxaout* | \ - i[56]86*-*-linuxoldld* | pentium-*-linuxoldld* | pentiumpro-*-linuxoldld* | \ - i[56]86*-*-*bsd* | pentium-*-*bsd* | pentiumpro-*-*bsd*) - echo '#define BSD_SYNTAX' >asm-syntax.h - echo '#include "'$srcdir'/x86/syntax.h"' >>asm-syntax.h - path="x86/pentium x86" ;; - i[34]86*-*-*) # x86 with ELF/SysV format - echo '#define ELF_SYNTAX' >asm-syntax.h - echo '#include "'$srcdir'/x86/syntax.h"' >>asm-syntax.h - path="x86" ;; - i[56]86*-*-* | pentium-*-* | pentiumpro-*-*) # x86 with ELF/SysV format - echo '#define ELF_SYNTAX' >asm-syntax.h - echo '#include "'$srcdir'/x86/syntax.h"' >>asm-syntax.h - path="x86/pentium x86" ;; - -# Motorola 68k configurations. Let m68k mean 68020-68040. -# mc68000 or mc68060 configurations need to be specified explicitly - m680[234]0*-*-linuxaout* | m68k*-*-linuxaout*) - echo '#define MIT_SYNTAX' >asm-syntax.h - echo '#include "'$srcdir'/m68k/syntax.h"' >>asm-syntax.h - path="m68k/mc68020 m68k" ;; - m68060*-*-linuxaout*) - echo '#define MIT_SYNTAX' >asm-syntax.h - echo '#include "'$srcdir'/m68k/syntax.h"' >>asm-syntax.h - path="m68k" ;; - m680[234]0*-*-linux* | m68k*-*-linux*) - echo '#define ELF_SYNTAX' >asm-syntax.h - echo '#include "'$srcdir'/m68k/syntax.h"' >>asm-syntax.h - path="m68k/mc68020 m68k" ;; - m68060*-*-linux*) - echo '#define ELF_SYNTAX' >asm-syntax.h - echo '#include "'$srcdir'/m68k/syntax.h"' >>asm-syntax.h - path="m68k" ;; - m68000*-*-* | m68060*-*-*) - echo '#define MIT_SYNTAX' >asm-syntax.h - echo '#include "'$srcdir'/m68k/syntax.h"' >>asm-syntax.h - path="m68k/mc68000" ;; - m680[234]0*-*-* | m68k*-*-*) - echo '#define MIT_SYNTAX' >asm-syntax.h - echo '#include "'$srcdir'/m68k/syntax.h"' >>asm-syntax.h - path="m68k/mc68020 m68k" ;; - - i960*-*-*) path="i960" ;; - m88k*-*-* | m88k*-*-*) path="m88k" ;; - m88110*-*-*) path="m88k/mc88110 m88k" ;; - ns32k*-*-*) path="n32k" ;; - ppc601-*-*) path="power powerpc32" ;; - ppc620-*-* | powerpc64*-*-*) path="powerpc64" ;; - ppc60[234]*-*-* | powerpc*-*-*) path="powerpc32" ;; - pyramid-*-*) path="pyr" ;; - rs6000-*-* | power-*-* | power2-*-*) - path="power"; extra_functions="udiv_w_sdiv" ;; - sh-*-*) path="sh" ;; - sh2-*-*) path="sh/sh2 sh" ;; - mips[34]*-*-*) path="mips3" ;; - mips*-*-irix6*) path="mips3" ;; - mips*-*-*) path="mips2" ;; - vax*-*-*) path="vax"; extra_functions="udiv_w_sdiv" ;; - z8000x*-*-*) path="z8000x"; extra_functions="udiv_w_sdiv" ;; - z8000*-*-*) path="z8000"; extra_functions="udiv_w_sdiv" ;; - clipper*-*-*) path="clipper" ;; - *-*-*) ;; -esac - -case "${target}" in - *-*-linuxaout* | *-*-linuxoldld*) config=bsd.h ;; - *-sysv* | *-solaris* | *-*-linux*) config="sysv.h" ;; - *) config="bsd.h" ;; -esac - -case "${target}" in - i[3456]86*-*-*bsd* | i[3456]86*-*-linuxaout* | i[3456]86*-*-linuxoldld* | \ - pentium-*-*bsd* | pentium-*-linuxaout* | pentium-*-linuxoldld* | \ - pentiumpro-*-*bsd* | pentiumpro-*-linuxaout* | pentiumpro-*-linuxoldld*) - target_makefile_frag=config/t-oldgas ;; - rs6000-*-aix[456789]* | rs6000-*-aix3.2.[456789]) - target_makefile_frag=config/t-pwr-aix ;; - ppc601-*-aix[456789]* | ppc601-*-aix3.2.[456789] | \ - ppc60[234]*-*-aix[456789]* | ppc60[234]*-*-aix3.2.[456789] | \ - powerpc*-*-aix[456789]* | powerpc*-*-aix3.2.[456789]) - target_makefile_frag=config/t-ppc-aix ;; -esac - - -functions="${extra_functions} inlines add_n addmul_1 cmp divmod_1 \ - divrem divrem_1 dump lshift mod_1 mul mul_1 mul_n random2 rshift sqrtrem \ - sub_n submul_1 get_str set_str scan0 scan1 popcount hamdist gcd_1 \ - pre_mod_1 perfsqr bdivmod gcd gcdext" - -path="$path generic" -mpn_objects= - -for fn in $functions ; do - mpn_objects="$mpn_objects $fn.o" - for dir in $path ; do - rm -f $fn.[Ssc] - if test -f $srcdir/$dir/$fn.S ; then - files="$files $dir/$fn.S" - links="$links $fn.S" - break - elif test -f $srcdir/$dir/$fn.s ; then - files="$files $dir/$fn.s" - links="$links $fn.s" - break - elif test -f $srcdir/$dir/$fn.c ; then - files="$files $dir/$fn.c" - links="$links $fn.c" - break - fi - done -done - -for dir in $path ; do - rm -f gmp-mparam.h - if test -f $srcdir/$dir/gmp-mparam.h ; then - files="$files $dir/gmp-mparam.h" - links="$links gmp-mparam.h" - break - fi -done - -links="sysdep.h $links" -files="$config $files" - -mpn_links=$links - -# post-target: - -sed Makefile.tmp \ - -e "s/MPN_LINKS = .*/MPN_LINKS =${mpn_links}/" \ - -e "s/MPN_OBJECTS = .*/MPN_OBJECTS =${mpn_objects}/" - -mv Makefile.tmp Makefile diff --git a/gnu/lib/libgmp/mpn/generic/add_n.c b/gnu/lib/libgmp/mpn/generic/add_n.c deleted file mode 100644 index 9d71df1..0000000 --- a/gnu/lib/libgmp/mpn/generic/add_n.c +++ /dev/null @@ -1,62 +0,0 @@ -/* mpn_add_n -- Add two limb vectors of equal, non-zero length. - -Copyright (C) 1992, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -mp_limb_t -#if __STDC__ -mpn_add_n (mp_ptr res_ptr, mp_srcptr s1_ptr, mp_srcptr s2_ptr, mp_size_t size) -#else -mpn_add_n (res_ptr, s1_ptr, s2_ptr, size) - register mp_ptr res_ptr; - register mp_srcptr s1_ptr; - register mp_srcptr s2_ptr; - mp_size_t size; -#endif -{ - register mp_limb_t x, y, cy; - register mp_size_t j; - - /* The loop counter and index J goes from -SIZE to -1. This way - the loop becomes faster. */ - j = -size; - - /* Offset the base pointers to compensate for the negative indices. */ - s1_ptr -= j; - s2_ptr -= j; - res_ptr -= j; - - cy = 0; - do - { - y = s2_ptr[j]; - x = s1_ptr[j]; - y += cy; /* add previous carry to one addend */ - cy = (y < cy); /* get out carry from that addition */ - y = x + y; /* add other addend */ - cy = (y < x) + cy; /* get out carry from that add, combine */ - res_ptr[j] = y; - } - while (++j != 0); - - return cy; -} diff --git a/gnu/lib/libgmp/mpn/generic/addmul_1.c b/gnu/lib/libgmp/mpn/generic/addmul_1.c deleted file mode 100644 index 3a5e214..0000000 --- a/gnu/lib/libgmp/mpn/generic/addmul_1.c +++ /dev/null @@ -1,65 +0,0 @@ -/* mpn_addmul_1 -- multiply the S1_SIZE long limb vector pointed to by S1_PTR - by S2_LIMB, add the S1_SIZE least significant limbs of the product to the - limb vector pointed to by RES_PTR. Return the most significant limb of - the product, adjusted for carry-out from the addition. - -Copyright (C) 1992, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -mp_limb_t -mpn_addmul_1 (res_ptr, s1_ptr, s1_size, s2_limb) - register mp_ptr res_ptr; - register mp_srcptr s1_ptr; - mp_size_t s1_size; - register mp_limb_t s2_limb; -{ - register mp_limb_t cy_limb; - register mp_size_t j; - register mp_limb_t prod_high, prod_low; - register mp_limb_t x; - - /* The loop counter and index J goes from -SIZE to -1. This way - the loop becomes faster. */ - j = -s1_size; - - /* Offset the base pointers to compensate for the negative indices. */ - res_ptr -= j; - s1_ptr -= j; - - cy_limb = 0; - do - { - umul_ppmm (prod_high, prod_low, s1_ptr[j], s2_limb); - - prod_low += cy_limb; - cy_limb = (prod_low < cy_limb) + prod_high; - - x = res_ptr[j]; - prod_low = x + prod_low; - cy_limb += (prod_low < x); - res_ptr[j] = prod_low; - } - while (++j != 0); - - return cy_limb; -} diff --git a/gnu/lib/libgmp/mpn/generic/bdivmod.c b/gnu/lib/libgmp/mpn/generic/bdivmod.c deleted file mode 100644 index f095288..0000000 --- a/gnu/lib/libgmp/mpn/generic/bdivmod.c +++ /dev/null @@ -1,129 +0,0 @@ -/* mpn/bdivmod.c: mpn_bdivmod for computing U/V mod 2^d. - -Copyright (C) 1991, 1993, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* q_high = mpn_bdivmod (qp, up, usize, vp, vsize, d). - - Puts the low d/BITS_PER_MP_LIMB limbs of Q = U / V mod 2^d at qp, and - returns the high d%BITS_PER_MP_LIMB bits of Q as the result. - - Also, U - Q * V mod 2^(usize*BITS_PER_MP_LIMB) is placed at up. Since the - low d/BITS_PER_MP_LIMB limbs of this difference are zero, the code allows - the limb vectors at qp to overwrite the low limbs at up, provided qp <= up. - - Preconditions: - 1. V is odd. - 2. usize * BITS_PER_MP_LIMB >= d. - 3. If Q and U overlap, qp <= up. - - Ken Weber (kweber@mat.ufrgs.br, kweber@mcs.kent.edu) - - Funding for this work has been partially provided by Conselho Nacional - de Desenvolvimento Cienti'fico e Tecnolo'gico (CNPq) do Brazil, Grant - 301314194-2, and was done while I was a visiting reseacher in the Instituto - de Matema'tica at Universidade Federal do Rio Grande do Sul (UFRGS). - - References: - T. Jebelean, An algorithm for exact division, Journal of Symbolic - Computation, v. 15, 1993, pp. 169-180. - - K. Weber, The accelerated integer GCD algorithm, ACM Transactions on - Mathematical Software, v. 21 (March), 1995, pp. 111-122. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -mp_limb_t -#if __STDC__ -mpn_bdivmod (mp_ptr qp, mp_ptr up, mp_size_t usize, - mp_srcptr vp, mp_size_t vsize, unsigned long int d) -#else -mpn_bdivmod (qp, up, usize, vp, vsize, d) - mp_ptr qp; - mp_ptr up; - mp_size_t usize; - mp_srcptr vp; - mp_size_t vsize; - unsigned long int d; -#endif -{ - /* Cache for v_inv is used to make mpn_accelgcd faster. */ - static mp_limb_t previous_low_vlimb = 0; - static mp_limb_t v_inv; /* 1/V mod 2^BITS_PER_MP_LIMB. */ - - if (vp[0] != previous_low_vlimb) /* Cache miss; compute v_inv. */ - { - mp_limb_t v = previous_low_vlimb = vp[0]; - mp_limb_t make_zero = 1; - mp_limb_t two_i = 1; - v_inv = 0; - do - { - while ((two_i & make_zero) == 0) - two_i <<= 1, v <<= 1; - v_inv += two_i; - make_zero -= v; - } - while (make_zero); - } - - /* Need faster computation for some common cases in mpn_accelgcd. */ - if (usize == 2 && vsize == 2 && - (d == BITS_PER_MP_LIMB || d == 2*BITS_PER_MP_LIMB)) - { - mp_limb_t hi, lo; - mp_limb_t q = up[0] * v_inv; - umul_ppmm (hi, lo, q, vp[0]); - up[0] = 0, up[1] -= hi + q*vp[1], qp[0] = q; - if (d == 2*BITS_PER_MP_LIMB) - q = up[1] * v_inv, up[1] = 0, qp[1] = q; - return 0; - } - - /* Main loop. */ - while (d >= BITS_PER_MP_LIMB) - { - mp_limb_t q = up[0] * v_inv; - mp_limb_t b = mpn_submul_1 (up, vp, MIN (usize, vsize), q); - if (usize > vsize) - mpn_sub_1 (up + vsize, up + vsize, usize - vsize, b); - d -= BITS_PER_MP_LIMB; - up += 1, usize -= 1; - *qp++ = q; - } - - if (d) - { - mp_limb_t b; - mp_limb_t q = (up[0] * v_inv) & (((mp_limb_t)1< vsize) - mpn_sub_1 (up + vsize, up + vsize, usize - vsize, b); - return q; - } - - return 0; -} diff --git a/gnu/lib/libgmp/mpn/generic/cmp.c b/gnu/lib/libgmp/mpn/generic/cmp.c deleted file mode 100644 index 4e9c60d..0000000 --- a/gnu/lib/libgmp/mpn/generic/cmp.c +++ /dev/null @@ -1,56 +0,0 @@ -/* mpn_cmp -- Compare two low-level natural-number integers. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -/* Compare OP1_PTR/OP1_SIZE with OP2_PTR/OP2_SIZE. - There are no restrictions on the relative sizes of - the two arguments. - Return 1 if OP1 > OP2, 0 if they are equal, and -1 if OP1 < OP2. */ - -int -#if __STDC__ -mpn_cmp (mp_srcptr op1_ptr, mp_srcptr op2_ptr, mp_size_t size) -#else -mpn_cmp (op1_ptr, op2_ptr, size) - mp_srcptr op1_ptr; - mp_srcptr op2_ptr; - mp_size_t size; -#endif -{ - mp_size_t i; - mp_limb_t op1_word, op2_word; - - for (i = size - 1; i >= 0; i--) - { - op1_word = op1_ptr[i]; - op2_word = op2_ptr[i]; - if (op1_word != op2_word) - goto diff; - } - return 0; - diff: - /* This can *not* be simplified to - op2_word - op2_word - since that expression might give signed overflow. */ - return (op1_word > op2_word) ? 1 : -1; -} diff --git a/gnu/lib/libgmp/mpn/generic/divmod_1.c b/gnu/lib/libgmp/mpn/generic/divmod_1.c deleted file mode 100644 index f93841f..0000000 --- a/gnu/lib/libgmp/mpn/generic/divmod_1.c +++ /dev/null @@ -1,208 +0,0 @@ -/* mpn_divmod_1(quot_ptr, dividend_ptr, dividend_size, divisor_limb) -- - Divide (DIVIDEND_PTR,,DIVIDEND_SIZE) by DIVISOR_LIMB. - Write DIVIDEND_SIZE limbs of quotient at QUOT_PTR. - Return the single-limb remainder. - There are no constraints on the value of the divisor. - - QUOT_PTR and DIVIDEND_PTR might point to the same limb. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -#ifndef UMUL_TIME -#define UMUL_TIME 1 -#endif - -#ifndef UDIV_TIME -#define UDIV_TIME UMUL_TIME -#endif - -/* FIXME: We should be using invert_limb (or invert_normalized_limb) - here (not udiv_qrnnd). */ - -mp_limb_t -#if __STDC__ -mpn_divmod_1 (mp_ptr quot_ptr, - mp_srcptr dividend_ptr, mp_size_t dividend_size, - mp_limb_t divisor_limb) -#else -mpn_divmod_1 (quot_ptr, dividend_ptr, dividend_size, divisor_limb) - mp_ptr quot_ptr; - mp_srcptr dividend_ptr; - mp_size_t dividend_size; - mp_limb_t divisor_limb; -#endif -{ - mp_size_t i; - mp_limb_t n1, n0, r; - int dummy; - - /* ??? Should this be handled at all? Rely on callers? */ - if (dividend_size == 0) - return 0; - - /* If multiplication is much faster than division, and the - dividend is large, pre-invert the divisor, and use - only multiplications in the inner loop. */ - - /* This test should be read: - Does it ever help to use udiv_qrnnd_preinv? - && Does what we save compensate for the inversion overhead? */ - if (UDIV_TIME > (2 * UMUL_TIME + 6) - && (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME) - { - int normalization_steps; - - count_leading_zeros (normalization_steps, divisor_limb); - if (normalization_steps != 0) - { - mp_limb_t divisor_limb_inverted; - - divisor_limb <<= normalization_steps; - - /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The - result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the - most significant bit (with weight 2**N) implicit. */ - - /* Special case for DIVISOR_LIMB == 100...000. */ - if (divisor_limb << 1 == 0) - divisor_limb_inverted = ~(mp_limb_t) 0; - else - udiv_qrnnd (divisor_limb_inverted, dummy, - -divisor_limb, 0, divisor_limb); - - n1 = dividend_ptr[dividend_size - 1]; - r = n1 >> (BITS_PER_MP_LIMB - normalization_steps); - - /* Possible optimization: - if (r == 0 - && divisor_limb > ((n1 << normalization_steps) - | (dividend_ptr[dividend_size - 2] >> ...))) - ...one division less... */ - - for (i = dividend_size - 2; i >= 0; i--) - { - n0 = dividend_ptr[i]; - udiv_qrnnd_preinv (quot_ptr[i + 1], r, r, - ((n1 << normalization_steps) - | (n0 >> (BITS_PER_MP_LIMB - normalization_steps))), - divisor_limb, divisor_limb_inverted); - n1 = n0; - } - udiv_qrnnd_preinv (quot_ptr[0], r, r, - n1 << normalization_steps, - divisor_limb, divisor_limb_inverted); - return r >> normalization_steps; - } - else - { - mp_limb_t divisor_limb_inverted; - - /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The - result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the - most significant bit (with weight 2**N) implicit. */ - - /* Special case for DIVISOR_LIMB == 100...000. */ - if (divisor_limb << 1 == 0) - divisor_limb_inverted = ~(mp_limb_t) 0; - else - udiv_qrnnd (divisor_limb_inverted, dummy, - -divisor_limb, 0, divisor_limb); - - i = dividend_size - 1; - r = dividend_ptr[i]; - - if (r >= divisor_limb) - r = 0; - else - { - quot_ptr[i] = 0; - i--; - } - - for (; i >= 0; i--) - { - n0 = dividend_ptr[i]; - udiv_qrnnd_preinv (quot_ptr[i], r, r, - n0, divisor_limb, divisor_limb_inverted); - } - return r; - } - } - else - { - if (UDIV_NEEDS_NORMALIZATION) - { - int normalization_steps; - - count_leading_zeros (normalization_steps, divisor_limb); - if (normalization_steps != 0) - { - divisor_limb <<= normalization_steps; - - n1 = dividend_ptr[dividend_size - 1]; - r = n1 >> (BITS_PER_MP_LIMB - normalization_steps); - - /* Possible optimization: - if (r == 0 - && divisor_limb > ((n1 << normalization_steps) - | (dividend_ptr[dividend_size - 2] >> ...))) - ...one division less... */ - - for (i = dividend_size - 2; i >= 0; i--) - { - n0 = dividend_ptr[i]; - udiv_qrnnd (quot_ptr[i + 1], r, r, - ((n1 << normalization_steps) - | (n0 >> (BITS_PER_MP_LIMB - normalization_steps))), - divisor_limb); - n1 = n0; - } - udiv_qrnnd (quot_ptr[0], r, r, - n1 << normalization_steps, - divisor_limb); - return r >> normalization_steps; - } - } - /* No normalization needed, either because udiv_qrnnd doesn't require - it, or because DIVISOR_LIMB is already normalized. */ - - i = dividend_size - 1; - r = dividend_ptr[i]; - - if (r >= divisor_limb) - r = 0; - else - { - quot_ptr[i] = 0; - i--; - } - - for (; i >= 0; i--) - { - n0 = dividend_ptr[i]; - udiv_qrnnd (quot_ptr[i], r, r, n0, divisor_limb); - } - return r; - } -} diff --git a/gnu/lib/libgmp/mpn/generic/divrem.c b/gnu/lib/libgmp/mpn/generic/divrem.c deleted file mode 100644 index 1fe865a..0000000 --- a/gnu/lib/libgmp/mpn/generic/divrem.c +++ /dev/null @@ -1,245 +0,0 @@ -/* mpn_divrem -- Divide natural numbers, producing both remainder and - quotient. - -Copyright (C) 1993, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -/* Divide num (NP/NSIZE) by den (DP/DSIZE) and write - the NSIZE-DSIZE least significant quotient limbs at QP - and the DSIZE long remainder at NP. If QEXTRA_LIMBS is - non-zero, generate that many fraction bits and append them after the - other quotient limbs. - Return the most significant limb of the quotient, this is always 0 or 1. - - Preconditions: - 0. NSIZE >= DSIZE. - 1. The most significant bit of the divisor must be set. - 2. QP must either not overlap with the input operands at all, or - QP + DSIZE >= NP must hold true. (This means that it's - possible to put the quotient in the high part of NUM, right after the - remainder in NUM. - 3. NSIZE >= DSIZE, even if QEXTRA_LIMBS is non-zero. */ - -mp_limb_t -#if __STDC__ -mpn_divrem (mp_ptr qp, mp_size_t qextra_limbs, - mp_ptr np, mp_size_t nsize, - mp_srcptr dp, mp_size_t dsize) -#else -mpn_divrem (qp, qextra_limbs, np, nsize, dp, dsize) - mp_ptr qp; - mp_size_t qextra_limbs; - mp_ptr np; - mp_size_t nsize; - mp_srcptr dp; - mp_size_t dsize; -#endif -{ - mp_limb_t most_significant_q_limb = 0; - - switch (dsize) - { - case 0: - /* We are asked to divide by zero, so go ahead and do it! (To make - the compiler not remove this statement, return the value.) */ - return 1 / dsize; - - case 1: - { - mp_size_t i; - mp_limb_t n1; - mp_limb_t d; - - d = dp[0]; - n1 = np[nsize - 1]; - - if (n1 >= d) - { - n1 -= d; - most_significant_q_limb = 1; - } - - qp += qextra_limbs; - for (i = nsize - 2; i >= 0; i--) - udiv_qrnnd (qp[i], n1, n1, np[i], d); - qp -= qextra_limbs; - - for (i = qextra_limbs - 1; i >= 0; i--) - udiv_qrnnd (qp[i], n1, n1, 0, d); - - np[0] = n1; - } - break; - - case 2: - { - mp_size_t i; - mp_limb_t n1, n0, n2; - mp_limb_t d1, d0; - - np += nsize - 2; - d1 = dp[1]; - d0 = dp[0]; - n1 = np[1]; - n0 = np[0]; - - if (n1 >= d1 && (n1 > d1 || n0 >= d0)) - { - sub_ddmmss (n1, n0, n1, n0, d1, d0); - most_significant_q_limb = 1; - } - - for (i = qextra_limbs + nsize - 2 - 1; i >= 0; i--) - { - mp_limb_t q; - mp_limb_t r; - - if (i >= qextra_limbs) - np--; - else - np[0] = 0; - - if (n1 == d1) - { - /* Q should be either 111..111 or 111..110. Need special - treatment of this rare case as normal division would - give overflow. */ - q = ~(mp_limb_t) 0; - - r = n0 + d1; - if (r < d1) /* Carry in the addition? */ - { - add_ssaaaa (n1, n0, r - d0, np[0], 0, d0); - qp[i] = q; - continue; - } - n1 = d0 - (d0 != 0); - n0 = -d0; - } - else - { - udiv_qrnnd (q, r, n1, n0, d1); - umul_ppmm (n1, n0, d0, q); - } - - n2 = np[0]; - q_test: - if (n1 > r || (n1 == r && n0 > n2)) - { - /* The estimated Q was too large. */ - q--; - - sub_ddmmss (n1, n0, n1, n0, 0, d0); - r += d1; - if (r >= d1) /* If not carry, test Q again. */ - goto q_test; - } - - qp[i] = q; - sub_ddmmss (n1, n0, r, n2, n1, n0); - } - np[1] = n1; - np[0] = n0; - } - break; - - default: - { - mp_size_t i; - mp_limb_t dX, d1, n0; - - np += nsize - dsize; - dX = dp[dsize - 1]; - d1 = dp[dsize - 2]; - n0 = np[dsize - 1]; - - if (n0 >= dX) - { - if (n0 > dX || mpn_cmp (np, dp, dsize - 1) >= 0) - { - mpn_sub_n (np, np, dp, dsize); - n0 = np[dsize - 1]; - most_significant_q_limb = 1; - } - } - - for (i = qextra_limbs + nsize - dsize - 1; i >= 0; i--) - { - mp_limb_t q; - mp_limb_t n1, n2; - mp_limb_t cy_limb; - - if (i >= qextra_limbs) - { - np--; - n2 = np[dsize]; - } - else - { - n2 = np[dsize - 1]; - MPN_COPY_DECR (np + 1, np, dsize); - np[0] = 0; - } - - if (n0 == dX) - /* This might over-estimate q, but it's probably not worth - the extra code here to find out. */ - q = ~(mp_limb_t) 0; - else - { - mp_limb_t r; - - udiv_qrnnd (q, r, n0, np[dsize - 1], dX); - umul_ppmm (n1, n0, d1, q); - - while (n1 > r || (n1 == r && n0 > np[dsize - 2])) - { - q--; - r += dX; - if (r < dX) /* I.e. "carry in previous addition?" */ - break; - n1 -= n0 < d1; - n0 -= d1; - } - } - - /* Possible optimization: We already have (q * n0) and (1 * n1) - after the calculation of q. Taking advantage of that, we - could make this loop make two iterations less. */ - - cy_limb = mpn_submul_1 (np, dp, dsize, q); - - if (n2 != cy_limb) - { - mpn_add_n (np, np, dp, dsize); - q--; - } - - qp[i] = q; - n0 = np[dsize - 1]; - } - } - } - - return most_significant_q_limb; -} diff --git a/gnu/lib/libgmp/mpn/generic/divrem_1.c b/gnu/lib/libgmp/mpn/generic/divrem_1.c deleted file mode 100644 index d213267..0000000 --- a/gnu/lib/libgmp/mpn/generic/divrem_1.c +++ /dev/null @@ -1,58 +0,0 @@ -/* mpn_divrem_1(quot_ptr, qsize, dividend_ptr, dividend_size, divisor_limb) -- - Divide (DIVIDEND_PTR,,DIVIDEND_SIZE) by DIVISOR_LIMB. - Write DIVIDEND_SIZE limbs of quotient at QUOT_PTR. - Return the single-limb remainder. - There are no constraints on the value of the divisor. - - QUOT_PTR and DIVIDEND_PTR might point to the same limb. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -mp_limb_t -#if __STDC__ -mpn_divrem_1 (mp_ptr qp, mp_size_t qsize, - mp_srcptr dividend_ptr, mp_size_t dividend_size, - mp_limb_t divisor_limb) -#else -mpn_divrem_1 (qp, qsize, dividend_ptr, dividend_size, divisor_limb) - mp_ptr qp; - mp_size_t qsize; - mp_srcptr dividend_ptr; - mp_size_t dividend_size; - mp_limb_t divisor_limb; -#endif -{ - mp_limb_t rlimb; - long i; - - /* Develop integer part of quotient. */ - rlimb = mpn_divmod_1 (qp + qsize, dividend_ptr, dividend_size, divisor_limb); - - if (qsize != 0) - { - for (i = qsize - 1; i >= 0; i--) - udiv_qrnnd (qp[i], rlimb, rlimb, 0, divisor_limb); - } - return rlimb; -} diff --git a/gnu/lib/libgmp/mpn/generic/dump.c b/gnu/lib/libgmp/mpn/generic/dump.c deleted file mode 100644 index a5831c4..0000000 --- a/gnu/lib/libgmp/mpn/generic/dump.c +++ /dev/null @@ -1,20 +0,0 @@ -#include -#include "gmp.h" -#include "gmp-impl.h" - -void -mpn_dump (ptr, size) - mp_srcptr ptr; - mp_size_t size; -{ - if (size == 0) - printf ("0\n"); - { - while (size) - { - size--; - printf ("%0*lX", (int) (2 * BYTES_PER_MP_LIMB), ptr[size]); - } - printf ("\n"); - } -} diff --git a/gnu/lib/libgmp/mpn/generic/gcd.c b/gnu/lib/libgmp/mpn/generic/gcd.c deleted file mode 100644 index 8c2bbf0..0000000 --- a/gnu/lib/libgmp/mpn/generic/gcd.c +++ /dev/null @@ -1,402 +0,0 @@ -/* mpn/gcd.c: mpn_gcd for gcd of two odd integers. - -Copyright (C) 1991, 1993, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* Integer greatest common divisor of two unsigned integers, using - the accelerated algorithm (see reference below). - - mp_size_t mpn_gcd (vp, vsize, up, usize). - - Preconditions [U = (up, usize) and V = (vp, vsize)]: - - 1. V is odd. - 2. numbits(U) >= numbits(V). - - Both U and V are destroyed by the operation. The result is left at vp, - and its size is returned. - - Ken Weber (kweber@mat.ufrgs.br, kweber@mcs.kent.edu) - - Funding for this work has been partially provided by Conselho Nacional - de Desenvolvimento Cienti'fico e Tecnolo'gico (CNPq) do Brazil, Grant - 301314194-2, and was done while I was a visiting reseacher in the Instituto - de Matema'tica at Universidade Federal do Rio Grande do Sul (UFRGS). - - Refer to - K. Weber, The accelerated integer GCD algorithm, ACM Transactions on - Mathematical Software, v. 21 (March), 1995, pp. 111-122. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -/* If MIN (usize, vsize) > ACCEL_THRESHOLD, then the accelerated algorithm is - used, otherwise the binary algorithm is used. This may be adjusted for - different architectures. */ -#ifndef ACCEL_THRESHOLD -#define ACCEL_THRESHOLD 4 -#endif - -/* When U and V differ in size by more than BMOD_THRESHOLD, the accelerated - algorithm reduces using the bmod operation. Otherwise, the k-ary reduction - is used. 0 <= BMOD_THRESHOLD < BITS_PER_MP_LIMB. */ -enum - { - BMOD_THRESHOLD = BITS_PER_MP_LIMB/2 - }; - -#define SIGN_BIT (~(~(mp_limb_t)0 >> 1)) - - -#define SWAP_LIMB(UL, VL) do{mp_limb_t __l=(UL);(UL)=(VL);(VL)=__l;}while(0) -#define SWAP_PTR(UP, VP) do{mp_ptr __p=(UP);(UP)=(VP);(VP)=__p;}while(0) -#define SWAP_SZ(US, VS) do{mp_size_t __s=(US);(US)=(VS);(VS)=__s;}while(0) -#define SWAP_MPN(UP, US, VP, VS) do{SWAP_PTR(UP,VP);SWAP_SZ(US,VS);}while(0) - -/* Use binary algorithm to compute V <-- GCD (V, U) for usize, vsize == 2. - Both U and V must be odd. */ -static __gmp_inline mp_size_t -#if __STDC__ -gcd_2 (mp_ptr vp, mp_srcptr up) -#else -gcd_2 (vp, up) - mp_ptr vp; - mp_srcptr up; -#endif -{ - mp_limb_t u0, u1, v0, v1; - mp_size_t vsize; - - u0 = up[0], u1 = up[1], v0 = vp[0], v1 = vp[1]; - - while (u1 != v1 && u0 != v0) - { - unsigned long int r; - if (u1 > v1) - { - u1 -= v1 + (u0 < v0), u0 -= v0; - count_trailing_zeros (r, u0); - u0 = u1 << (BITS_PER_MP_LIMB - r) | u0 >> r; - u1 >>= r; - } - else /* u1 < v1. */ - { - v1 -= u1 + (v0 < u0), v0 -= u0; - count_trailing_zeros (r, v0); - v0 = v1 << (BITS_PER_MP_LIMB - r) | v0 >> r; - v1 >>= r; - } - } - - vp[0] = v0, vp[1] = v1, vsize = 1 + (v1 != 0); - - /* If U == V == GCD, done. Otherwise, compute GCD (V, |U - V|). */ - if (u1 == v1 && u0 == v0) - return vsize; - - v0 = (u0 == v0) ? (u1 > v1) ? u1-v1 : v1-u1 : (u0 > v0) ? u0-v0 : v0-u0; - vp[0] = mpn_gcd_1 (vp, vsize, v0); - - return 1; -} - -/* The function find_a finds 0 < N < 2^BITS_PER_MP_LIMB such that there exists - 0 < |D| < 2^BITS_PER_MP_LIMB, and N == D * C mod 2^(2*BITS_PER_MP_LIMB). - In the reference article, D was computed along with N, but it is better to - compute D separately as D <-- N / C mod 2^(BITS_PER_MP_LIMB + 1), treating - the result as a twos' complement signed integer. - - Initialize N1 to C mod 2^(2*BITS_PER_MP_LIMB). According to the reference - article, N2 should be initialized to 2^(2*BITS_PER_MP_LIMB), but we use - 2^(2*BITS_PER_MP_LIMB) - N1 to start the calculations within double - precision. If N2 > N1 initially, the first iteration of the while loop - will swap them. In all other situations, N1 >= N2 is maintained. */ - -static __gmp_inline mp_limb_t -#if __STDC__ -find_a (mp_srcptr cp) -#else -find_a (cp) - mp_srcptr cp; -#endif -{ - unsigned long int leading_zero_bits = 0; - - mp_limb_t n1_l = cp[0]; /* N1 == n1_h * 2^BITS_PER_MP_LIMB + n1_l. */ - mp_limb_t n1_h = cp[1]; - - mp_limb_t n2_l = -n1_l; /* N2 == n2_h * 2^BITS_PER_MP_LIMB + n2_l. */ - mp_limb_t n2_h = ~n1_h; - - /* Main loop. */ - while (n2_h) /* While N2 >= 2^BITS_PER_MP_LIMB. */ - { - /* N1 <-- N1 % N2. */ - if ((SIGN_BIT >> leading_zero_bits & n2_h) == 0) - { - unsigned long int i; - count_leading_zeros (i, n2_h); - i -= leading_zero_bits, leading_zero_bits += i; - n2_h = n2_h<>(BITS_PER_MP_LIMB - i), n2_l <<= i; - do - { - if (n1_h > n2_h || (n1_h == n2_h && n1_l >= n2_l)) - n1_h -= n2_h + (n1_l < n2_l), n1_l -= n2_l; - n2_l = n2_l>>1 | n2_h<<(BITS_PER_MP_LIMB - 1), n2_h >>= 1; - i -= 1; - } - while (i); - } - if (n1_h > n2_h || (n1_h == n2_h && n1_l >= n2_l)) - n1_h -= n2_h + (n1_l < n2_l), n1_l -= n2_l; - - SWAP_LIMB (n1_h, n2_h); - SWAP_LIMB (n1_l, n2_l); - } - - return n2_l; -} - -mp_size_t -#if __STDC__ -mpn_gcd (mp_ptr gp, mp_ptr vp, mp_size_t vsize, mp_ptr up, mp_size_t usize) -#else -mpn_gcd (gp, vp, vsize, up, usize) - mp_ptr gp; - mp_ptr vp; - mp_size_t vsize; - mp_ptr up; - mp_size_t usize; -#endif -{ - mp_ptr orig_vp = vp; - mp_size_t orig_vsize = vsize; - int binary_gcd_ctr; /* Number of times binary gcd will execute. */ - TMP_DECL (marker); - - TMP_MARK (marker); - - /* Use accelerated algorithm if vsize is over ACCEL_THRESHOLD. - Two EXTRA limbs for U and V are required for kary reduction. */ - if (vsize > ACCEL_THRESHOLD) - { - unsigned long int vbitsize, d; - mp_ptr orig_up = up; - mp_size_t orig_usize = usize; - mp_ptr anchor_up = (mp_ptr) TMP_ALLOC ((usize + 2) * BYTES_PER_MP_LIMB); - - MPN_COPY (anchor_up, orig_up, usize); - up = anchor_up; - - count_leading_zeros (d, up[usize-1]); - d = usize * BITS_PER_MP_LIMB - d; - count_leading_zeros (vbitsize, vp[vsize-1]); - vbitsize = vsize * BITS_PER_MP_LIMB - vbitsize; - d = d - vbitsize + 1; - - /* Use bmod reduction to quickly discover whether V divides U. */ - up[usize++] = 0; /* Insert leading zero. */ - mpn_bdivmod (up, up, usize, vp, vsize, d); - - /* Now skip U/V mod 2^d and any low zero limbs. */ - d /= BITS_PER_MP_LIMB, up += d, usize -= d; - while (usize != 0 && up[0] == 0) - up++, usize--; - - if (usize == 0) /* GCD == ORIG_V. */ - goto done; - - vp = (mp_ptr) TMP_ALLOC ((vsize + 2) * BYTES_PER_MP_LIMB); - MPN_COPY (vp, orig_vp, vsize); - - do /* Main loop. */ - { - if (up[usize-1] & SIGN_BIT) /* U < 0; take twos' compl. */ - { - mp_size_t i; - anchor_up[0] = -up[0]; - for (i = 1; i < usize; i++) - anchor_up[i] = ~up[i]; - up = anchor_up; - } - - MPN_NORMALIZE_NOT_ZERO (up, usize); - - if ((up[0] & 1) == 0) /* Result even; remove twos. */ - { - unsigned long int r; - count_trailing_zeros (r, up[0]); - mpn_rshift (anchor_up, up, usize, r); - usize -= (anchor_up[usize-1] == 0); - } - else if (anchor_up != up) - MPN_COPY (anchor_up, up, usize); - - SWAP_MPN (anchor_up, usize, vp, vsize); - up = anchor_up; - - if (vsize <= 2) /* Kary can't handle < 2 limbs and */ - break; /* isn't efficient for == 2 limbs. */ - - d = vbitsize; - count_leading_zeros (vbitsize, vp[vsize-1]); - vbitsize = vsize * BITS_PER_MP_LIMB - vbitsize; - d = d - vbitsize + 1; - - if (d > BMOD_THRESHOLD) /* Bmod reduction. */ - { - up[usize++] = 0; - mpn_bdivmod (up, up, usize, vp, vsize, d); - d /= BITS_PER_MP_LIMB, up += d, usize -= d; - } - else /* Kary reduction. */ - { - mp_limb_t bp[2], cp[2]; - - /* C <-- V/U mod 2^(2*BITS_PER_MP_LIMB). */ - cp[0] = vp[0], cp[1] = vp[1]; - mpn_bdivmod (cp, cp, 2, up, 2, 2*BITS_PER_MP_LIMB); - - /* U <-- find_a (C) * U. */ - up[usize] = mpn_mul_1 (up, up, usize, find_a (cp)); - usize++; - - /* B <-- A/C == U/V mod 2^(BITS_PER_MP_LIMB + 1). - bp[0] <-- U/V mod 2^BITS_PER_MP_LIMB and - bp[1] <-- ( (U - bp[0] * V)/2^BITS_PER_MP_LIMB ) / V mod 2 */ - bp[0] = up[0], bp[1] = up[1]; - mpn_bdivmod (bp, bp, 2, vp, 2, BITS_PER_MP_LIMB); - bp[1] &= 1; /* Since V is odd, division is unnecessary. */ - - up[usize++] = 0; - if (bp[1]) /* B < 0: U <-- U + (-B) * V. */ - { - mp_limb_t c = mpn_addmul_1 (up, vp, vsize, -bp[0]); - mpn_add_1 (up + vsize, up + vsize, usize - vsize, c); - } - else /* B >= 0: U <-- U - B * V. */ - { - mp_limb_t b = mpn_submul_1 (up, vp, vsize, bp[0]); - mpn_sub_1 (up + vsize, up + vsize, usize - vsize, b); - } - - up += 2, usize -= 2; /* At least two low limbs are zero. */ - } - - /* Must remove low zero limbs before complementing. */ - while (usize != 0 && up[0] == 0) - up++, usize--; - } - while (usize); - - /* Compute GCD (ORIG_V, GCD (ORIG_U, V)). Binary will execute twice. */ - up = orig_up, usize = orig_usize; - binary_gcd_ctr = 2; - } - else - binary_gcd_ctr = 1; - - /* Finish up with the binary algorithm. Executes once or twice. */ - for ( ; binary_gcd_ctr--; up = orig_vp, usize = orig_vsize) - { - if (usize > 2) /* First make U close to V in size. */ - { - unsigned long int vbitsize, d; - count_leading_zeros (d, up[usize-1]); - d = usize * BITS_PER_MP_LIMB - d; - count_leading_zeros (vbitsize, vp[vsize-1]); - vbitsize = vsize * BITS_PER_MP_LIMB - vbitsize; - d = d - vbitsize - 1; - if (d != -(unsigned long int)1 && d > 2) - { - mpn_bdivmod (up, up, usize, vp, vsize, d); /* Result > 0. */ - d /= (unsigned long int)BITS_PER_MP_LIMB, up += d, usize -= d; - } - } - - /* Start binary GCD. */ - do - { - mp_size_t zeros; - - /* Make sure U is odd. */ - MPN_NORMALIZE (up, usize); - while (up[0] == 0) - up += 1, usize -= 1; - if ((up[0] & 1) == 0) - { - unsigned long int r; - count_trailing_zeros (r, up[0]); - mpn_rshift (up, up, usize, r); - usize -= (up[usize-1] == 0); - } - - /* Keep usize >= vsize. */ - if (usize < vsize) - SWAP_MPN (up, usize, vp, vsize); - - if (usize <= 2) /* Double precision. */ - { - if (vsize == 1) - vp[0] = mpn_gcd_1 (up, usize, vp[0]); - else - vsize = gcd_2 (vp, up); - break; /* Binary GCD done. */ - } - - /* Count number of low zero limbs of U - V. */ - for (zeros = 0; up[zeros] == vp[zeros] && ++zeros != vsize; ) - continue; - - /* If U < V, swap U and V; in any case, subtract V from U. */ - if (zeros == vsize) /* Subtract done. */ - up += zeros, usize -= zeros; - else if (usize == vsize) - { - mp_size_t size = vsize; - do - size--; - while (up[size] == vp[size]); - if (up[size] < vp[size]) /* usize == vsize. */ - SWAP_PTR (up, vp); - up += zeros, usize = size + 1 - zeros; - mpn_sub_n (up, up, vp + zeros, usize); - } - else - { - mp_size_t size = vsize - zeros; - up += zeros, usize -= zeros; - if (mpn_sub_n (up, up, vp + zeros, size)) - { - while (up[size] == 0) /* Propagate borrow. */ - up[size++] = -(mp_limb_t)1; - up[size] -= 1; - } - } - } - while (usize); /* End binary GCD. */ - } - -done: - if (vp != gp) - MPN_COPY (gp, vp, vsize); - TMP_FREE (marker); - return vsize; -} diff --git a/gnu/lib/libgmp/mpn/generic/gcd_1.c b/gnu/lib/libgmp/mpn/generic/gcd_1.c deleted file mode 100644 index ebcdfb5..0000000 --- a/gnu/lib/libgmp/mpn/generic/gcd_1.c +++ /dev/null @@ -1,73 +0,0 @@ -/* mpn_gcd_1 -- - -Copyright (C) 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -/* Does not work for U == 0 or V == 0. It would be tough to make it work for - V == 0 since gcd(x,0) = x, and U does not generally fit in an mp_limb_t. */ - -mp_limb_t -mpn_gcd_1 (up, size, vlimb) - mp_srcptr up; - mp_size_t size; - mp_limb_t vlimb; -{ - mp_limb_t ulimb; - unsigned long int u_low_zero_bits, v_low_zero_bits; - - if (size > 1) - { - ulimb = mpn_mod_1 (up, size, vlimb); - if (ulimb == 0) - return vlimb; - } - else - ulimb = up[0]; - - /* Need to eliminate low zero bits. */ - count_trailing_zeros (u_low_zero_bits, ulimb); - ulimb >>= u_low_zero_bits; - - count_trailing_zeros (v_low_zero_bits, vlimb); - vlimb >>= v_low_zero_bits; - - while (ulimb != vlimb) - { - if (ulimb > vlimb) - { - ulimb -= vlimb; - do - ulimb >>= 1; - while ((ulimb & 1) == 0); - } - else /* vlimb > ulimb. */ - { - vlimb -= ulimb; - do - vlimb >>= 1; - while ((vlimb & 1) == 0); - } - } - - return ulimb << MIN (u_low_zero_bits, v_low_zero_bits); -} diff --git a/gnu/lib/libgmp/mpn/generic/gcdext.c b/gnu/lib/libgmp/mpn/generic/gcdext.c deleted file mode 100644 index 245e20a..0000000 --- a/gnu/lib/libgmp/mpn/generic/gcdext.c +++ /dev/null @@ -1,441 +0,0 @@ -/* mpn_gcdext -- Extended Greatest Common Divisor. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -#ifndef EXTEND -#define EXTEND 1 -#endif - -#if STAT -int arr[BITS_PER_MP_LIMB]; -#endif - -#define SGN(A) (((A) < 0) ? -1 : ((A) > 0)) - -/* Idea 1: After we have performed a full division, don't shift operands back, - but instead account for the extra factors-of-2 thus introduced. - Idea 2: Simple generalization to use divide-and-conquer would give us an - algorithm that runs faster than O(n^2). - Idea 3: The input numbers need less space as the computation progresses, - while the s0 and s1 variables need more space. To save space, we - could make them share space, and have the latter variables grow - into the former. */ - -/* Precondition: U >= V. */ - -mp_size_t -#if EXTEND -#if __STDC__ -mpn_gcdext (mp_ptr gp, mp_ptr s0p, - mp_ptr up, mp_size_t size, mp_ptr vp, mp_size_t vsize) -#else -mpn_gcdext (gp, s0p, up, size, vp, vsize) - mp_ptr gp; - mp_ptr s0p; - mp_ptr up; - mp_size_t size; - mp_ptr vp; - mp_size_t vsize; -#endif -#else -#if __STDC__ -mpn_gcd (mp_ptr gp, - mp_ptr up, mp_size_t size, mp_ptr vp, mp_size_t vsize) -#else -mpn_gcd (gp, up, size, vp, vsize) - mp_ptr gp; - mp_ptr up; - mp_size_t size; - mp_ptr vp; - mp_size_t vsize; -#endif -#endif -{ - mp_limb_t uh, vh; - mp_limb_signed_t A, B, C, D; - int cnt; - mp_ptr tp, wp; -#if RECORD - mp_limb_signed_t min = 0, max = 0; -#endif -#if EXTEND - mp_ptr s1p; - mp_ptr orig_s0p = s0p; - mp_size_t ssize, orig_size = size; - TMP_DECL (mark); - - TMP_MARK (mark); - - tp = (mp_ptr) TMP_ALLOC ((size + 1) * BYTES_PER_MP_LIMB); - wp = (mp_ptr) TMP_ALLOC ((size + 1) * BYTES_PER_MP_LIMB); - s1p = (mp_ptr) TMP_ALLOC (size * BYTES_PER_MP_LIMB); - - MPN_ZERO (s0p, size); - MPN_ZERO (s1p, size); - - s0p[0] = 1; - s1p[0] = 0; - ssize = 1; -#endif - - if (size > vsize) - { - /* Normalize V (and shift up U the same amount). */ - count_leading_zeros (cnt, vp[vsize - 1]); - if (cnt != 0) - { - mp_limb_t cy; - mpn_lshift (vp, vp, vsize, cnt); - cy = mpn_lshift (up, up, size, cnt); - up[size] = cy; - size += cy != 0; - } - - mpn_divmod (up + vsize, up, size, vp, vsize); -#if EXTEND - /* This is really what it boils down to in this case... */ - s0p[0] = 0; - s1p[0] = 1; -#endif - size = vsize; - if (cnt != 0) - { - mpn_rshift (up, up, size, cnt); - mpn_rshift (vp, vp, size, cnt); - } - { - mp_ptr xp; - xp = up; up = vp; vp = xp; - } - } - - for (;;) - { - /* Figure out exact size of V. */ - vsize = size; - MPN_NORMALIZE (vp, vsize); - if (vsize <= 1) - break; - - /* Make UH be the most significant limb of U, and make VH be - corresponding bits from V. */ - uh = up[size - 1]; - vh = vp[size - 1]; - count_leading_zeros (cnt, uh); - if (cnt != 0) - { - uh = (uh << cnt) | (up[size - 2] >> (BITS_PER_MP_LIMB - cnt)); - vh = (vh << cnt) | (vp[size - 2] >> (BITS_PER_MP_LIMB - cnt)); - } - -#if 0 - /* For now, only handle BITS_PER_MP_LIMB-1 bits. This makes - room for sign bit. */ - uh >>= 1; - vh >>= 1; -#endif - A = 1; - B = 0; - C = 0; - D = 1; - - for (;;) - { - mp_limb_signed_t q, T; - if (vh + C == 0 || vh + D == 0) - break; - - q = (uh + A) / (vh + C); - if (q != (uh + B) / (vh + D)) - break; - - T = A - q * C; - A = C; - C = T; - T = B - q * D; - B = D; - D = T; - T = uh - q * vh; - uh = vh; - vh = T; - } - -#if RECORD - min = MIN (A, min); min = MIN (B, min); - min = MIN (C, min); min = MIN (D, min); - max = MAX (A, max); max = MAX (B, max); - max = MAX (C, max); max = MAX (D, max); -#endif - - if (B == 0) - { - mp_limb_t qh; - mp_size_t i; - - /* This is quite rare. I.e., optimize something else! */ - - /* Normalize V (and shift up U the same amount). */ - count_leading_zeros (cnt, vp[vsize - 1]); - if (cnt != 0) - { - mp_limb_t cy; - mpn_lshift (vp, vp, vsize, cnt); - cy = mpn_lshift (up, up, size, cnt); - up[size] = cy; - size += cy != 0; - } - - qh = mpn_divmod (up + vsize, up, size, vp, vsize); -#if EXTEND - MPN_COPY (tp, s0p, ssize); - for (i = 0; i < size - vsize; i++) - { - mp_limb_t cy; - cy = mpn_addmul_1 (tp + i, s1p, ssize, up[vsize + i]); - if (cy != 0) - tp[ssize++] = cy; - } - if (qh != 0) - { - mp_limb_t cy; - abort (); - /* XXX since qh == 1, mpn_addmul_1 is overkill */ - cy = mpn_addmul_1 (tp + size - vsize, s1p, ssize, qh); - if (cy != 0) - tp[ssize++] = cy; - } -#if 0 - MPN_COPY (s0p, s1p, ssize); /* should be old ssize, kind of */ - MPN_COPY (s1p, tp, ssize); -#else - { - mp_ptr xp; - xp = s0p; s0p = s1p; s1p = xp; - xp = s1p; s1p = tp; tp = xp; - } -#endif -#endif - size = vsize; - if (cnt != 0) - { - mpn_rshift (up, up, size, cnt); - mpn_rshift (vp, vp, size, cnt); - } - - { - mp_ptr xp; - xp = up; up = vp; vp = xp; - } - MPN_NORMALIZE (up, size); - } - else - { - /* T = U*A + V*B - W = U*C + V*D - U = T - V = W */ - - if (SGN(A) == SGN(B)) /* should be different sign */ - abort (); - if (SGN(C) == SGN(D)) /* should be different sign */ - abort (); -#if STAT - { mp_limb_t x; - x = ABS (A) | ABS (B) | ABS (C) | ABS (D); - count_leading_zeros (cnt, x); - arr[BITS_PER_MP_LIMB - cnt]++; } -#endif - if (A == 0) - { - if (B != 1) abort (); - MPN_COPY (tp, vp, size); - } - else - { - if (A < 0) - { - mpn_mul_1 (tp, vp, size, B); - mpn_submul_1 (tp, up, size, -A); - } - else - { - mpn_mul_1 (tp, up, size, A); - mpn_submul_1 (tp, vp, size, -B); - } - } - if (C < 0) - { - mpn_mul_1 (wp, vp, size, D); - mpn_submul_1 (wp, up, size, -C); - } - else - { - mpn_mul_1 (wp, up, size, C); - mpn_submul_1 (wp, vp, size, -D); - } - - { - mp_ptr xp; - xp = tp; tp = up; up = xp; - xp = wp; wp = vp; vp = xp; - } - -#if EXTEND - { mp_limb_t cy; - MPN_ZERO (tp, orig_size); - if (A == 0) - { - if (B != 1) abort (); - MPN_COPY (tp, s1p, ssize); - } - else - { - if (A < 0) - { - cy = mpn_mul_1 (tp, s1p, ssize, B); - cy += mpn_addmul_1 (tp, s0p, ssize, -A); - } - else - { - cy = mpn_mul_1 (tp, s0p, ssize, A); - cy += mpn_addmul_1 (tp, s1p, ssize, -B); - } - if (cy != 0) - tp[ssize++] = cy; - } - MPN_ZERO (wp, orig_size); - if (C < 0) - { - cy = mpn_mul_1 (wp, s1p, ssize, D); - cy += mpn_addmul_1 (wp, s0p, ssize, -C); - } - else - { - cy = mpn_mul_1 (wp, s0p, ssize, C); - cy += mpn_addmul_1 (wp, s1p, ssize, -D); - } - if (cy != 0) - wp[ssize++] = cy; - } - { - mp_ptr xp; - xp = tp; tp = s0p; s0p = xp; - xp = wp; wp = s1p; s1p = xp; - } -#endif -#if 0 /* Is it a win to remove multiple zeros here? */ - MPN_NORMALIZE (up, size); -#else - if (up[size - 1] == 0) - size--; -#endif - } - } - -#if RECORD - printf ("min: %ld\n", min); - printf ("max: %ld\n", max); -#endif - - if (vsize == 0) - { - if (gp != up) - MPN_COPY (gp, up, size); -#if EXTEND - if (orig_s0p != s0p) - MPN_COPY (orig_s0p, s0p, ssize); -#endif - TMP_FREE (mark); - return size; - } - else - { - mp_limb_t vl, ul, t; -#if EXTEND - mp_limb_t cy; - mp_size_t i; -#endif - vl = vp[0]; -#if EXTEND - t = mpn_divmod_1 (wp, up, size, vl); - MPN_COPY (tp, s0p, ssize); - for (i = 0; i < size; i++) - { - cy = mpn_addmul_1 (tp + i, s1p, ssize, wp[i]); - if (cy != 0) - tp[ssize++] = cy; - } -#if 0 - MPN_COPY (s0p, s1p, ssize); - MPN_COPY (s1p, tp, ssize); -#else - { - mp_ptr xp; - xp = s0p; s0p = s1p; s1p = xp; - xp = s1p; s1p = tp; tp = xp; - } -#endif -#else - t = mpn_mod_1 (up, size, vl); -#endif - ul = vl; - vl = t; - while (vl != 0) - { - mp_limb_t t; -#if EXTEND - mp_limb_t q, cy; - q = ul / vl; - t = ul - q*vl; - - MPN_COPY (tp, s0p, ssize); - cy = mpn_addmul_1 (tp, s1p, ssize, q); - if (cy != 0) - tp[ssize++] = cy; -#if 0 - MPN_COPY (s0p, s1p, ssize); - MPN_COPY (s1p, tp, ssize); -#else - { - mp_ptr xp; - xp = s0p; s0p = s1p; s1p = xp; - xp = s1p; s1p = tp; tp = xp; - } -#endif - -#else - t = ul % vl; -#endif - ul = vl; - vl = t; - } - gp[0] = ul; -#if EXTEND - if (orig_s0p != s0p) - MPN_COPY (orig_s0p, s0p, ssize); -#endif - TMP_FREE (mark); - return 1; - } -} diff --git a/gnu/lib/libgmp/mpn/generic/get_str.c b/gnu/lib/libgmp/mpn/generic/get_str.c deleted file mode 100644 index 0e7fc60..0000000 --- a/gnu/lib/libgmp/mpn/generic/get_str.c +++ /dev/null @@ -1,211 +0,0 @@ -/* mpn_get_str -- Convert a MSIZE long limb vector pointed to by MPTR - to a printable string in STR in base BASE. - -Copyright (C) 1991, 1992, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -/* Convert the limb vector pointed to by MPTR and MSIZE long to a - char array, using base BASE for the result array. Store the - result in the character array STR. STR must point to an array with - space for the largest possible number represented by a MSIZE long - limb vector + 1 extra character. - - The result is NOT in Ascii, to convert it to printable format, add - '0' or 'A' depending on the base and range. - - Return the number of digits in the result string. - This may include some leading zeros. - - The limb vector pointed to by MPTR is clobbered. */ - -size_t -mpn_get_str (str, base, mptr, msize) - unsigned char *str; - int base; - mp_ptr mptr; - mp_size_t msize; -{ - mp_limb_t big_base; -#if UDIV_NEEDS_NORMALIZATION || UDIV_TIME > 2 * UMUL_TIME - int normalization_steps; -#endif -#if UDIV_TIME > 2 * UMUL_TIME - mp_limb_t big_base_inverted; -#endif - unsigned int dig_per_u; - mp_size_t out_len; - register unsigned char *s; - - big_base = __mp_bases[base].big_base; - - s = str; - - /* Special case zero, as the code below doesn't handle it. */ - if (msize == 0) - { - s[0] = 0; - return 1; - } - - if ((base & (base - 1)) == 0) - { - /* The base is a power of 2. Make conversion from most - significant side. */ - mp_limb_t n1, n0; - register int bits_per_digit = big_base; - register int x; - register int bit_pos; - register int i; - - n1 = mptr[msize - 1]; - count_leading_zeros (x, n1); - - /* BIT_POS should be R when input ends in least sign. nibble, - R + bits_per_digit * n when input ends in n:th least significant - nibble. */ - - { - int bits; - - bits = BITS_PER_MP_LIMB * msize - x; - x = bits % bits_per_digit; - if (x != 0) - bits += bits_per_digit - x; - bit_pos = bits - (msize - 1) * BITS_PER_MP_LIMB; - } - - /* Fast loop for bit output. */ - i = msize - 1; - for (;;) - { - bit_pos -= bits_per_digit; - while (bit_pos >= 0) - { - *s++ = (n1 >> bit_pos) & ((1 << bits_per_digit) - 1); - bit_pos -= bits_per_digit; - } - i--; - if (i < 0) - break; - n0 = (n1 << -bit_pos) & ((1 << bits_per_digit) - 1); - n1 = mptr[i]; - bit_pos += BITS_PER_MP_LIMB; - *s++ = n0 | (n1 >> bit_pos); - } - - *s = 0; - - return s - str; - } - else - { - /* General case. The base is not a power of 2. Make conversion - from least significant end. */ - - /* If udiv_qrnnd only handles divisors with the most significant bit - set, prepare BIG_BASE for being a divisor by shifting it to the - left exactly enough to set the most significant bit. */ -#if UDIV_NEEDS_NORMALIZATION || UDIV_TIME > 2 * UMUL_TIME - count_leading_zeros (normalization_steps, big_base); - big_base <<= normalization_steps; -#if UDIV_TIME > 2 * UMUL_TIME - /* Get the fixed-point approximation to 1/(BIG_BASE << NORMALIZATION_STEPS). */ - big_base_inverted = __mp_bases[base].big_base_inverted; -#endif -#endif - - dig_per_u = __mp_bases[base].chars_per_limb; - out_len = ((size_t) msize * BITS_PER_MP_LIMB - * __mp_bases[base].chars_per_bit_exactly) + 1; - s += out_len; - - while (msize != 0) - { - int i; - mp_limb_t n0, n1; - -#if UDIV_NEEDS_NORMALIZATION || UDIV_TIME > 2 * UMUL_TIME - /* If we shifted BIG_BASE above, shift the dividend too, to get - the right quotient. We need to do this every loop, - since the intermediate quotients are OK, but the quotient from - one turn in the loop is going to be the dividend in the - next turn, and the dividend needs to be up-shifted. */ - if (normalization_steps != 0) - { - n0 = mpn_lshift (mptr, mptr, msize, normalization_steps); - - /* If the shifting gave a carry out limb, store it and - increase the length. */ - if (n0 != 0) - { - mptr[msize] = n0; - msize++; - } - } -#endif - - /* Divide the number at TP with BIG_BASE to get a quotient and a - remainder. The remainder is our new digit in base BIG_BASE. */ - i = msize - 1; - n1 = mptr[i]; - - if (n1 >= big_base) - n1 = 0; - else - { - msize--; - i--; - } - - for (; i >= 0; i--) - { - n0 = mptr[i]; -#if UDIV_TIME > 2 * UMUL_TIME - udiv_qrnnd_preinv (mptr[i], n1, n1, n0, big_base, big_base_inverted); -#else - udiv_qrnnd (mptr[i], n1, n1, n0, big_base); -#endif - } - -#if UDIV_NEEDS_NORMALIZATION || UDIV_TIME > 2 * UMUL_TIME - /* If we shifted above (at previous UDIV_NEEDS_NORMALIZATION tests) - the remainder will be up-shifted here. Compensate. */ - n1 >>= normalization_steps; -#endif - - /* Convert N1 from BIG_BASE to a string of digits in BASE - using single precision operations. */ - for (i = dig_per_u - 1; i >= 0; i--) - { - *--s = n1 % base; - n1 /= base; - if (n1 == 0 && msize == 0) - break; - } - } - - while (s != str) - *--s = 0; - return out_len; - } -} diff --git a/gnu/lib/libgmp/mpn/generic/gmp-mparam.h b/gnu/lib/libgmp/mpn/generic/gmp-mparam.h deleted file mode 100644 index 7c88557..0000000 --- a/gnu/lib/libgmp/mpn/generic/gmp-mparam.h +++ /dev/null @@ -1,27 +0,0 @@ -/* gmp-mparam.h -- Compiler/machine parameter header file. - -Copyright (C) 1991, 1993, 1994 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#define BITS_PER_MP_LIMB 32 -#define BYTES_PER_MP_LIMB 4 -#define BITS_PER_LONGINT 32 -#define BITS_PER_INT 32 -#define BITS_PER_SHORTINT 16 -#define BITS_PER_CHAR 8 diff --git a/gnu/lib/libgmp/mpn/generic/hamdist.c b/gnu/lib/libgmp/mpn/generic/hamdist.c deleted file mode 100644 index 2190b63..0000000 --- a/gnu/lib/libgmp/mpn/generic/hamdist.c +++ /dev/null @@ -1,88 +0,0 @@ -/* mpn_hamdist -- - -Copyright (C) 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -#if defined __GNUC__ -#if defined __sparc_v9__ && BITS_PER_MP_LIMB == 64 -#define popc_limb(a) \ - ({ \ - DItype __res; \ - asm ("popc %1,%0" : "=r" (__res) : "rI" (a)); \ - __res; \ - }) -#endif -#endif - -#ifndef popc_limb - -/* Cool population count of a mp_limb_t. - You have to figure out how this works, I won't tell you! */ - -static inline unsigned int -popc_limb (x) - mp_limb_t x; -{ -#if BITS_PER_MP_LIMB == 64 - /* We have to go into some trouble to define these constants. - (For mp_limb_t being `long long'.) */ - mp_limb_t cnst; - cnst = 0x55555555L | ((mp_limb_t) 0x55555555L << BITS_PER_MP_LIMB/2); - x = ((x & ~cnst) >> 1) + (x & cnst); - cnst = 0x33333333L | ((mp_limb_t) 0x33333333L << BITS_PER_MP_LIMB/2); - x = ((x & ~cnst) >> 2) + (x & cnst); - cnst = 0x0f0f0f0fL | ((mp_limb_t) 0x0f0f0f0fL << BITS_PER_MP_LIMB/2); - x = ((x >> 4) + x) & cnst; - x = ((x >> 8) + x); - x = ((x >> 16) + x); - x = ((x >> 32) + x) & 0xff; -#endif -#if BITS_PER_MP_LIMB == 32 - x = ((x >> 1) & 0x55555555L) + (x & 0x55555555L); - x = ((x >> 2) & 0x33333333L) + (x & 0x33333333L); - x = ((x >> 4) + x) & 0x0f0f0f0fL; - x = ((x >> 8) + x); - x = ((x >> 16) + x) & 0xff; -#endif - return x; -} -#endif - -unsigned long int -#if __STDC__ -mpn_hamdist (mp_srcptr up, mp_srcptr vp, mp_size_t size) -#else -mpn_hamdist (up, vp, size) - register mp_srcptr up; - register mp_srcptr vp; - register mp_size_t size; -#endif -{ - unsigned long int hamdist; - mp_size_t i; - - hamdist = 0; - for (i = 0; i < size; i++) - hamdist += popc_limb (up[i] ^ vp[i]); - - return hamdist; -} diff --git a/gnu/lib/libgmp/mpn/generic/inlines.c b/gnu/lib/libgmp/mpn/generic/inlines.c deleted file mode 100644 index dca305e..0000000 --- a/gnu/lib/libgmp/mpn/generic/inlines.c +++ /dev/null @@ -1,3 +0,0 @@ -#define _FORCE_INLINES -#define _EXTERN_INLINE /* empty */ -#include "gmp.h" diff --git a/gnu/lib/libgmp/mpn/generic/lshift.c b/gnu/lib/libgmp/mpn/generic/lshift.c deleted file mode 100644 index e244bc5..0000000 --- a/gnu/lib/libgmp/mpn/generic/lshift.c +++ /dev/null @@ -1,87 +0,0 @@ -/* mpn_lshift -- Shift left low level. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -/* Shift U (pointed to by UP and USIZE digits long) CNT bits to the left - and store the USIZE least significant digits of the result at WP. - Return the bits shifted out from the most significant digit. - - Argument constraints: - 1. 0 < CNT < BITS_PER_MP_LIMB - 2. If the result is to be written over the input, WP must be >= UP. -*/ - -mp_limb_t -#if __STDC__ -mpn_lshift (register mp_ptr wp, - register mp_srcptr up, mp_size_t usize, - register unsigned int cnt) -#else -mpn_lshift (wp, up, usize, cnt) - register mp_ptr wp; - register mp_srcptr up; - mp_size_t usize; - register unsigned int cnt; -#endif -{ - register mp_limb_t high_limb, low_limb; - register unsigned sh_1, sh_2; - register mp_size_t i; - mp_limb_t retval; - -#ifdef DEBUG - if (usize == 0 || cnt == 0) - abort (); -#endif - - sh_1 = cnt; -#if 0 - if (sh_1 == 0) - { - if (wp != up) - { - /* Copy from high end to low end, to allow specified input/output - overlapping. */ - for (i = usize - 1; i >= 0; i--) - wp[i] = up[i]; - } - return 0; - } -#endif - - wp += 1; - sh_2 = BITS_PER_MP_LIMB - sh_1; - i = usize - 1; - low_limb = up[i]; - retval = low_limb >> sh_2; - high_limb = low_limb; - while (--i >= 0) - { - low_limb = up[i]; - wp[i] = (high_limb << sh_1) | (low_limb >> sh_2); - high_limb = low_limb; - } - wp[i] = high_limb << sh_1; - - return retval; -} diff --git a/gnu/lib/libgmp/mpn/generic/mod_1.c b/gnu/lib/libgmp/mpn/generic/mod_1.c deleted file mode 100644 index 314d11b..0000000 --- a/gnu/lib/libgmp/mpn/generic/mod_1.c +++ /dev/null @@ -1,197 +0,0 @@ -/* mpn_mod_1(dividend_ptr, dividend_size, divisor_limb) -- - Divide (DIVIDEND_PTR,,DIVIDEND_SIZE) by DIVISOR_LIMB. - Return the single-limb remainder. - There are no constraints on the value of the divisor. - -Copyright (C) 1991, 1993, 1994, 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -#ifndef UMUL_TIME -#define UMUL_TIME 1 -#endif - -#ifndef UDIV_TIME -#define UDIV_TIME UMUL_TIME -#endif - -/* FIXME: We should be using invert_limb (or invert_normalized_limb) - here (not udiv_qrnnd). */ - -mp_limb_t -#if __STDC__ -mpn_mod_1 (mp_srcptr dividend_ptr, mp_size_t dividend_size, - mp_limb_t divisor_limb) -#else -mpn_mod_1 (dividend_ptr, dividend_size, divisor_limb) - mp_srcptr dividend_ptr; - mp_size_t dividend_size; - mp_limb_t divisor_limb; -#endif -{ - mp_size_t i; - mp_limb_t n1, n0, r; - int dummy; - - /* Botch: Should this be handled at all? Rely on callers? */ - if (dividend_size == 0) - return 0; - - /* If multiplication is much faster than division, and the - dividend is large, pre-invert the divisor, and use - only multiplications in the inner loop. */ - - /* This test should be read: - Does it ever help to use udiv_qrnnd_preinv? - && Does what we save compensate for the inversion overhead? */ - if (UDIV_TIME > (2 * UMUL_TIME + 6) - && (UDIV_TIME - (2 * UMUL_TIME + 6)) * dividend_size > UDIV_TIME) - { - int normalization_steps; - - count_leading_zeros (normalization_steps, divisor_limb); - if (normalization_steps != 0) - { - mp_limb_t divisor_limb_inverted; - - divisor_limb <<= normalization_steps; - - /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The - result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the - most significant bit (with weight 2**N) implicit. */ - - /* Special case for DIVISOR_LIMB == 100...000. */ - if (divisor_limb << 1 == 0) - divisor_limb_inverted = ~(mp_limb_t) 0; - else - udiv_qrnnd (divisor_limb_inverted, dummy, - -divisor_limb, 0, divisor_limb); - - n1 = dividend_ptr[dividend_size - 1]; - r = n1 >> (BITS_PER_MP_LIMB - normalization_steps); - - /* Possible optimization: - if (r == 0 - && divisor_limb > ((n1 << normalization_steps) - | (dividend_ptr[dividend_size - 2] >> ...))) - ...one division less... */ - - for (i = dividend_size - 2; i >= 0; i--) - { - n0 = dividend_ptr[i]; - udiv_qrnnd_preinv (dummy, r, r, - ((n1 << normalization_steps) - | (n0 >> (BITS_PER_MP_LIMB - normalization_steps))), - divisor_limb, divisor_limb_inverted); - n1 = n0; - } - udiv_qrnnd_preinv (dummy, r, r, - n1 << normalization_steps, - divisor_limb, divisor_limb_inverted); - return r >> normalization_steps; - } - else - { - mp_limb_t divisor_limb_inverted; - - /* Compute (2**2N - 2**N * DIVISOR_LIMB) / DIVISOR_LIMB. The - result is a (N+1)-bit approximation to 1/DIVISOR_LIMB, with the - most significant bit (with weight 2**N) implicit. */ - - /* Special case for DIVISOR_LIMB == 100...000. */ - if (divisor_limb << 1 == 0) - divisor_limb_inverted = ~(mp_limb_t) 0; - else - udiv_qrnnd (divisor_limb_inverted, dummy, - -divisor_limb, 0, divisor_limb); - - i = dividend_size - 1; - r = dividend_ptr[i]; - - if (r >= divisor_limb) - r = 0; - else - i--; - - for (; i >= 0; i--) - { - n0 = dividend_ptr[i]; - udiv_qrnnd_preinv (dummy, r, r, - n0, divisor_limb, divisor_limb_inverted); - } - return r; - } - } - else - { - if (UDIV_NEEDS_NORMALIZATION) - { - int normalization_steps; - - count_leading_zeros (normalization_steps, divisor_limb); - if (normalization_steps != 0) - { - divisor_limb <<= normalization_steps; - - n1 = dividend_ptr[dividend_size - 1]; - r = n1 >> (BITS_PER_MP_LIMB - normalization_steps); - - /* Possible optimization: - if (r == 0 - && divisor_limb > ((n1 << normalization_steps) - | (dividend_ptr[dividend_size - 2] >> ...))) - ...one division less... */ - - for (i = dividend_size - 2; i >= 0; i--) - { - n0 = dividend_ptr[i]; - udiv_qrnnd (dummy, r, r, - ((n1 << normalization_steps) - | (n0 >> (BITS_PER_MP_LIMB - normalization_steps))), - divisor_limb); - n1 = n0; - } - udiv_qrnnd (dummy, r, r, - n1 << normalization_steps, - divisor_limb); - return r >> normalization_steps; - } - } - /* No normalization needed, either because udiv_qrnnd doesn't require - it, or because DIVISOR_LIMB is already normalized. */ - - i = dividend_size - 1; - r = dividend_ptr[i]; - - if (r >= divisor_limb) - r = 0; - else - i--; - - for (; i >= 0; i--) - { - n0 = dividend_ptr[i]; - udiv_qrnnd (dummy, r, r, n0, divisor_limb); - } - return r; - } -} diff --git a/gnu/lib/libgmp/mpn/generic/mul.c b/gnu/lib/libgmp/mpn/generic/mul.c deleted file mode 100644 index dcf8cb4..0000000 --- a/gnu/lib/libgmp/mpn/generic/mul.c +++ /dev/null @@ -1,152 +0,0 @@ -/* mpn_mul -- Multiply two natural numbers. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -/* Multiply the natural numbers u (pointed to by UP, with USIZE limbs) - and v (pointed to by VP, with VSIZE limbs), and store the result at - PRODP. USIZE + VSIZE limbs are always stored, but if the input - operands are normalized. Return the most significant limb of the - result. - - NOTE: The space pointed to by PRODP is overwritten before finished - with U and V, so overlap is an error. - - Argument constraints: - 1. USIZE >= VSIZE. - 2. PRODP != UP and PRODP != VP, i.e. the destination - must be distinct from the multiplier and the multiplicand. */ - -/* If KARATSUBA_THRESHOLD is not already defined, define it to a - value which is good on most machines. */ -#ifndef KARATSUBA_THRESHOLD -#define KARATSUBA_THRESHOLD 32 -#endif - -mp_limb_t -#if __STDC__ -mpn_mul (mp_ptr prodp, - mp_srcptr up, mp_size_t usize, - mp_srcptr vp, mp_size_t vsize) -#else -mpn_mul (prodp, up, usize, vp, vsize) - mp_ptr prodp; - mp_srcptr up; - mp_size_t usize; - mp_srcptr vp; - mp_size_t vsize; -#endif -{ - mp_ptr prod_endp = prodp + usize + vsize - 1; - mp_limb_t cy; - mp_ptr tspace; - TMP_DECL (marker); - - if (vsize < KARATSUBA_THRESHOLD) - { - /* Handle simple cases with traditional multiplication. - - This is the most critical code of the entire function. All - multiplies rely on this, both small and huge. Small ones arrive - here immediately. Huge ones arrive here as this is the base case - for Karatsuba's recursive algorithm below. */ - mp_size_t i; - mp_limb_t cy_limb; - mp_limb_t v_limb; - - if (vsize == 0) - return 0; - - /* Multiply by the first limb in V separately, as the result can be - stored (not added) to PROD. We also avoid a loop for zeroing. */ - v_limb = vp[0]; - if (v_limb <= 1) - { - if (v_limb == 1) - MPN_COPY (prodp, up, usize); - else - MPN_ZERO (prodp, usize); - cy_limb = 0; - } - else - cy_limb = mpn_mul_1 (prodp, up, usize, v_limb); - - prodp[usize] = cy_limb; - prodp++; - - /* For each iteration in the outer loop, multiply one limb from - U with one limb from V, and add it to PROD. */ - for (i = 1; i < vsize; i++) - { - v_limb = vp[i]; - if (v_limb <= 1) - { - cy_limb = 0; - if (v_limb == 1) - cy_limb = mpn_add_n (prodp, prodp, up, usize); - } - else - cy_limb = mpn_addmul_1 (prodp, up, usize, v_limb); - - prodp[usize] = cy_limb; - prodp++; - } - return cy_limb; - } - - TMP_MARK (marker); - - tspace = (mp_ptr) TMP_ALLOC (2 * vsize * BYTES_PER_MP_LIMB); - MPN_MUL_N_RECURSE (prodp, up, vp, vsize, tspace); - - prodp += vsize; - up += vsize; - usize -= vsize; - if (usize >= vsize) - { - mp_ptr tp = (mp_ptr) TMP_ALLOC (2 * vsize * BYTES_PER_MP_LIMB); - do - { - MPN_MUL_N_RECURSE (tp, up, vp, vsize, tspace); - cy = mpn_add_n (prodp, prodp, tp, vsize); - mpn_add_1 (prodp + vsize, tp + vsize, vsize, cy); - prodp += vsize; - up += vsize; - usize -= vsize; - } - while (usize >= vsize); - } - - /* True: usize < vsize. */ - - /* Make life simple: Recurse. */ - - if (usize != 0) - { - mpn_mul (tspace, vp, vsize, up, usize); - cy = mpn_add_n (prodp, prodp, tspace, vsize); - mpn_add_1 (prodp + vsize, tspace + vsize, usize, cy); - } - - TMP_FREE (marker); - return *prod_endp; -} diff --git a/gnu/lib/libgmp/mpn/generic/mul_1.c b/gnu/lib/libgmp/mpn/generic/mul_1.c deleted file mode 100644 index 2de680a..0000000 --- a/gnu/lib/libgmp/mpn/generic/mul_1.c +++ /dev/null @@ -1,59 +0,0 @@ -/* mpn_mul_1 -- Multiply a limb vector with a single limb and - store the product in a second limb vector. - -Copyright (C) 1991, 1992, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -mp_limb_t -mpn_mul_1 (res_ptr, s1_ptr, s1_size, s2_limb) - register mp_ptr res_ptr; - register mp_srcptr s1_ptr; - mp_size_t s1_size; - register mp_limb_t s2_limb; -{ - register mp_limb_t cy_limb; - register mp_size_t j; - register mp_limb_t prod_high, prod_low; - - /* The loop counter and index J goes from -S1_SIZE to -1. This way - the loop becomes faster. */ - j = -s1_size; - - /* Offset the base pointers to compensate for the negative indices. */ - s1_ptr -= j; - res_ptr -= j; - - cy_limb = 0; - do - { - umul_ppmm (prod_high, prod_low, s1_ptr[j], s2_limb); - - prod_low += cy_limb; - cy_limb = (prod_low < cy_limb) + prod_high; - - res_ptr[j] = prod_low; - } - while (++j != 0); - - return cy_limb; -} diff --git a/gnu/lib/libgmp/mpn/generic/mul_n.c b/gnu/lib/libgmp/mpn/generic/mul_n.c deleted file mode 100644 index b38e8ad..0000000 --- a/gnu/lib/libgmp/mpn/generic/mul_n.c +++ /dev/null @@ -1,401 +0,0 @@ -/* mpn_mul_n -- Multiply two natural numbers of length n. - -Copyright (C) 1991, 1992, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -/* Multiply the natural numbers u (pointed to by UP) and v (pointed to by VP), - both with SIZE limbs, and store the result at PRODP. 2 * SIZE limbs are - always stored. Return the most significant limb. - - Argument constraints: - 1. PRODP != UP and PRODP != VP, i.e. the destination - must be distinct from the multiplier and the multiplicand. */ - -/* If KARATSUBA_THRESHOLD is not already defined, define it to a - value which is good on most machines. */ -#ifndef KARATSUBA_THRESHOLD -#define KARATSUBA_THRESHOLD 32 -#endif - -/* The code can't handle KARATSUBA_THRESHOLD smaller than 2. */ -#if KARATSUBA_THRESHOLD < 2 -#undef KARATSUBA_THRESHOLD -#define KARATSUBA_THRESHOLD 2 -#endif - -/* Handle simple cases with traditional multiplication. - - This is the most critical code of multiplication. All multiplies rely - on this, both small and huge. Small ones arrive here immediately. Huge - ones arrive here as this is the base case for Karatsuba's recursive - algorithm below. */ - -void -#if __STDC__ -impn_mul_n_basecase (mp_ptr prodp, mp_srcptr up, mp_srcptr vp, mp_size_t size) -#else -impn_mul_n_basecase (prodp, up, vp, size) - mp_ptr prodp; - mp_srcptr up; - mp_srcptr vp; - mp_size_t size; -#endif -{ - mp_size_t i; - mp_limb_t cy_limb; - mp_limb_t v_limb; - - /* Multiply by the first limb in V separately, as the result can be - stored (not added) to PROD. We also avoid a loop for zeroing. */ - v_limb = vp[0]; - if (v_limb <= 1) - { - if (v_limb == 1) - MPN_COPY (prodp, up, size); - else - MPN_ZERO (prodp, size); - cy_limb = 0; - } - else - cy_limb = mpn_mul_1 (prodp, up, size, v_limb); - - prodp[size] = cy_limb; - prodp++; - - /* For each iteration in the outer loop, multiply one limb from - U with one limb from V, and add it to PROD. */ - for (i = 1; i < size; i++) - { - v_limb = vp[i]; - if (v_limb <= 1) - { - cy_limb = 0; - if (v_limb == 1) - cy_limb = mpn_add_n (prodp, prodp, up, size); - } - else - cy_limb = mpn_addmul_1 (prodp, up, size, v_limb); - - prodp[size] = cy_limb; - prodp++; - } -} - -void -#if __STDC__ -impn_mul_n (mp_ptr prodp, - mp_srcptr up, mp_srcptr vp, mp_size_t size, mp_ptr tspace) -#else -impn_mul_n (prodp, up, vp, size, tspace) - mp_ptr prodp; - mp_srcptr up; - mp_srcptr vp; - mp_size_t size; - mp_ptr tspace; -#endif -{ - if ((size & 1) != 0) - { - /* The size is odd, the code code below doesn't handle that. - Multiply the least significant (size - 1) limbs with a recursive - call, and handle the most significant limb of S1 and S2 - separately. */ - /* A slightly faster way to do this would be to make the Karatsuba - code below behave as if the size were even, and let it check for - odd size in the end. I.e., in essence move this code to the end. - Doing so would save us a recursive call, and potentially make the - stack grow a lot less. */ - - mp_size_t esize = size - 1; /* even size */ - mp_limb_t cy_limb; - - MPN_MUL_N_RECURSE (prodp, up, vp, esize, tspace); - cy_limb = mpn_addmul_1 (prodp + esize, up, esize, vp[esize]); - prodp[esize + esize] = cy_limb; - cy_limb = mpn_addmul_1 (prodp + esize, vp, size, up[esize]); - - prodp[esize + size] = cy_limb; - } - else - { - /* Anatolij Alekseevich Karatsuba's divide-and-conquer algorithm. - - Split U in two pieces, U1 and U0, such that - U = U0 + U1*(B**n), - and V in V1 and V0, such that - V = V0 + V1*(B**n). - - UV is then computed recursively using the identity - - 2n n n n - UV = (B + B )U V + B (U -U )(V -V ) + (B + 1)U V - 1 1 1 0 0 1 0 0 - - Where B = 2**BITS_PER_MP_LIMB. */ - - mp_size_t hsize = size >> 1; - mp_limb_t cy; - int negflg; - - /*** Product H. ________________ ________________ - |_____U1 x V1____||____U0 x V0_____| */ - /* Put result in upper part of PROD and pass low part of TSPACE - as new TSPACE. */ - MPN_MUL_N_RECURSE (prodp + size, up + hsize, vp + hsize, hsize, tspace); - - /*** Product M. ________________ - |_(U1-U0)(V0-V1)_| */ - if (mpn_cmp (up + hsize, up, hsize) >= 0) - { - mpn_sub_n (prodp, up + hsize, up, hsize); - negflg = 0; - } - else - { - mpn_sub_n (prodp, up, up + hsize, hsize); - negflg = 1; - } - if (mpn_cmp (vp + hsize, vp, hsize) >= 0) - { - mpn_sub_n (prodp + hsize, vp + hsize, vp, hsize); - negflg ^= 1; - } - else - { - mpn_sub_n (prodp + hsize, vp, vp + hsize, hsize); - /* No change of NEGFLG. */ - } - /* Read temporary operands from low part of PROD. - Put result in low part of TSPACE using upper part of TSPACE - as new TSPACE. */ - MPN_MUL_N_RECURSE (tspace, prodp, prodp + hsize, hsize, tspace + size); - - /*** Add/copy product H. */ - MPN_COPY (prodp + hsize, prodp + size, hsize); - cy = mpn_add_n (prodp + size, prodp + size, prodp + size + hsize, hsize); - - /*** Add product M (if NEGFLG M is a negative number). */ - if (negflg) - cy -= mpn_sub_n (prodp + hsize, prodp + hsize, tspace, size); - else - cy += mpn_add_n (prodp + hsize, prodp + hsize, tspace, size); - - /*** Product L. ________________ ________________ - |________________||____U0 x V0_____| */ - /* Read temporary operands from low part of PROD. - Put result in low part of TSPACE using upper part of TSPACE - as new TSPACE. */ - MPN_MUL_N_RECURSE (tspace, up, vp, hsize, tspace + size); - - /*** Add/copy Product L (twice). */ - - cy += mpn_add_n (prodp + hsize, prodp + hsize, tspace, size); - if (cy) - mpn_add_1 (prodp + hsize + size, prodp + hsize + size, hsize, cy); - - MPN_COPY (prodp, tspace, hsize); - cy = mpn_add_n (prodp + hsize, prodp + hsize, tspace + hsize, hsize); - if (cy) - mpn_add_1 (prodp + size, prodp + size, size, 1); - } -} - -void -#if __STDC__ -impn_sqr_n_basecase (mp_ptr prodp, mp_srcptr up, mp_size_t size) -#else -impn_sqr_n_basecase (prodp, up, size) - mp_ptr prodp; - mp_srcptr up; - mp_size_t size; -#endif -{ - mp_size_t i; - mp_limb_t cy_limb; - mp_limb_t v_limb; - - /* Multiply by the first limb in V separately, as the result can be - stored (not added) to PROD. We also avoid a loop for zeroing. */ - v_limb = up[0]; - if (v_limb <= 1) - { - if (v_limb == 1) - MPN_COPY (prodp, up, size); - else - MPN_ZERO (prodp, size); - cy_limb = 0; - } - else - cy_limb = mpn_mul_1 (prodp, up, size, v_limb); - - prodp[size] = cy_limb; - prodp++; - - /* For each iteration in the outer loop, multiply one limb from - U with one limb from V, and add it to PROD. */ - for (i = 1; i < size; i++) - { - v_limb = up[i]; - if (v_limb <= 1) - { - cy_limb = 0; - if (v_limb == 1) - cy_limb = mpn_add_n (prodp, prodp, up, size); - } - else - cy_limb = mpn_addmul_1 (prodp, up, size, v_limb); - - prodp[size] = cy_limb; - prodp++; - } -} - -void -#if __STDC__ -impn_sqr_n (mp_ptr prodp, - mp_srcptr up, mp_size_t size, mp_ptr tspace) -#else -impn_sqr_n (prodp, up, size, tspace) - mp_ptr prodp; - mp_srcptr up; - mp_size_t size; - mp_ptr tspace; -#endif -{ - if ((size & 1) != 0) - { - /* The size is odd, the code code below doesn't handle that. - Multiply the least significant (size - 1) limbs with a recursive - call, and handle the most significant limb of S1 and S2 - separately. */ - /* A slightly faster way to do this would be to make the Karatsuba - code below behave as if the size were even, and let it check for - odd size in the end. I.e., in essence move this code to the end. - Doing so would save us a recursive call, and potentially make the - stack grow a lot less. */ - - mp_size_t esize = size - 1; /* even size */ - mp_limb_t cy_limb; - - MPN_SQR_N_RECURSE (prodp, up, esize, tspace); - cy_limb = mpn_addmul_1 (prodp + esize, up, esize, up[esize]); - prodp[esize + esize] = cy_limb; - cy_limb = mpn_addmul_1 (prodp + esize, up, size, up[esize]); - - prodp[esize + size] = cy_limb; - } - else - { - mp_size_t hsize = size >> 1; - mp_limb_t cy; - - /*** Product H. ________________ ________________ - |_____U1 x U1____||____U0 x U0_____| */ - /* Put result in upper part of PROD and pass low part of TSPACE - as new TSPACE. */ - MPN_SQR_N_RECURSE (prodp + size, up + hsize, hsize, tspace); - - /*** Product M. ________________ - |_(U1-U0)(U0-U1)_| */ - if (mpn_cmp (up + hsize, up, hsize) >= 0) - { - mpn_sub_n (prodp, up + hsize, up, hsize); - } - else - { - mpn_sub_n (prodp, up, up + hsize, hsize); - } - - /* Read temporary operands from low part of PROD. - Put result in low part of TSPACE using upper part of TSPACE - as new TSPACE. */ - MPN_SQR_N_RECURSE (tspace, prodp, hsize, tspace + size); - - /*** Add/copy product H. */ - MPN_COPY (prodp + hsize, prodp + size, hsize); - cy = mpn_add_n (prodp + size, prodp + size, prodp + size + hsize, hsize); - - /*** Add product M (if NEGFLG M is a negative number). */ - cy -= mpn_sub_n (prodp + hsize, prodp + hsize, tspace, size); - - /*** Product L. ________________ ________________ - |________________||____U0 x U0_____| */ - /* Read temporary operands from low part of PROD. - Put result in low part of TSPACE using upper part of TSPACE - as new TSPACE. */ - MPN_SQR_N_RECURSE (tspace, up, hsize, tspace + size); - - /*** Add/copy Product L (twice). */ - - cy += mpn_add_n (prodp + hsize, prodp + hsize, tspace, size); - if (cy) - mpn_add_1 (prodp + hsize + size, prodp + hsize + size, hsize, cy); - - MPN_COPY (prodp, tspace, hsize); - cy = mpn_add_n (prodp + hsize, prodp + hsize, tspace + hsize, hsize); - if (cy) - mpn_add_1 (prodp + size, prodp + size, size, 1); - } -} - -/* This should be made into an inline function in gmp.h. */ -inline void -#if __STDC__ -mpn_mul_n (mp_ptr prodp, mp_srcptr up, mp_srcptr vp, mp_size_t size) -#else -mpn_mul_n (prodp, up, vp, size) - mp_ptr prodp; - mp_srcptr up; - mp_srcptr vp; - mp_size_t size; -#endif -{ - TMP_DECL (marker); - TMP_MARK (marker); - if (up == vp) - { - if (size < KARATSUBA_THRESHOLD) - { - impn_sqr_n_basecase (prodp, up, size); - } - else - { - mp_ptr tspace; - tspace = (mp_ptr) TMP_ALLOC (2 * size * BYTES_PER_MP_LIMB); - impn_sqr_n (prodp, up, size, tspace); - } - } - else - { - if (size < KARATSUBA_THRESHOLD) - { - impn_mul_n_basecase (prodp, up, vp, size); - } - else - { - mp_ptr tspace; - tspace = (mp_ptr) TMP_ALLOC (2 * size * BYTES_PER_MP_LIMB); - impn_mul_n (prodp, up, vp, size, tspace); - } - } - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpn/generic/perfsqr.c b/gnu/lib/libgmp/mpn/generic/perfsqr.c deleted file mode 100644 index 5a6e2af..0000000 --- a/gnu/lib/libgmp/mpn/generic/perfsqr.c +++ /dev/null @@ -1,138 +0,0 @@ -/* mpn_perfect_square_p(u,usize) -- Return non-zero if U is a perfect square, - zero otherwise. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -#ifndef UMUL_TIME -#define UMUL_TIME 1 -#endif - -#ifndef UDIV_TIME -#define UDIV_TIME UMUL_TIME -#endif - -#if BITS_PER_MP_LIMB == 32 -#define PP 0xC0CFD797L /* 3 x 5 x 7 x 11 x 13 x ... x 29 */ -#define PP_INVERTED 0x53E5645CL -#endif - -#if BITS_PER_MP_LIMB == 64 -#define PP 0xE221F97C30E94E1DL /* 3 x 5 x 7 x 11 x 13 x ... x 53 */ -#define PP_INVERTED 0x21CFE6CFC938B36BL -#endif - -/* sq_res_0x100[x mod 0x100] == 1 iff x mod 0x100 is a quadratic residue - modulo 0x100. */ -static unsigned char const sq_res_0x100[0x100] = -{ - 1,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0, - 0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0, - 1,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0, - 0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0, - 0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0, - 0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0, - 0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0, - 0,1,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0, -}; - -int -#if __STDC__ -mpn_perfect_square_p (mp_srcptr up, mp_size_t usize) -#else -mpn_perfect_square_p (up, usize) - mp_srcptr up; - mp_size_t usize; -#endif -{ - mp_limb_t rem; - mp_ptr root_ptr; - int res; - TMP_DECL (marker); - - /* The first test excludes 55/64 (85.9%) of the perfect square candidates - in O(1) time. */ - if ((sq_res_0x100[(unsigned int) up[0] % 0x100] & 1) == 0) - return 0; - -#if defined (PP) - /* The second test excludes 30652543/30808063 (99.5%) of the remaining - perfect square candidates in O(n) time. */ - - /* Firstly, compute REM = A mod PP. */ - if (UDIV_TIME > (2 * UMUL_TIME + 6)) - rem = mpn_preinv_mod_1 (up, usize, (mp_limb_t) PP, (mp_limb_t) PP_INVERTED); - else - rem = mpn_mod_1 (up, usize, (mp_limb_t) PP); - - /* Now decide if REM is a quadratic residue modulo the factors in PP. */ - - /* If A is just a few limbs, computing the square root does not take long - time, so things might run faster if we limit this loop according to the - size of A. */ - -#if BITS_PER_MP_LIMB == 64 - if (((0x12DD703303AED3L >> rem % 53) & 1) == 0) - return 0; - if (((0x4351B2753DFL >> rem % 47) & 1) == 0) - return 0; - if (((0x35883A3EE53L >> rem % 43) & 1) == 0) - return 0; - if (((0x1B382B50737L >> rem % 41) & 1) == 0) - return 0; - if (((0x165E211E9BL >> rem % 37) & 1) == 0) - return 0; - if (((0x121D47B7L >> rem % 31) & 1) == 0) - return 0; -#endif - if (((0x13D122F3L >> rem % 29) & 1) == 0) - return 0; - if (((0x5335FL >> rem % 23) & 1) == 0) - return 0; - if (((0x30AF3L >> rem % 19) & 1) == 0) - return 0; - if (((0x1A317L >> rem % 17) & 1) == 0) - return 0; - if (((0x161BL >> rem % 13) & 1) == 0) - return 0; - if (((0x23BL >> rem % 11) & 1) == 0) - return 0; - if (((0x017L >> rem % 7) & 1) == 0) - return 0; - if (((0x13L >> rem % 5) & 1) == 0) - return 0; - if (((0x3L >> rem % 3) & 1) == 0) - return 0; -#endif - - TMP_MARK (marker); - - /* For the third and last test, we finally compute the square root, - to make sure we've really got a perfect square. */ - root_ptr = (mp_ptr) TMP_ALLOC ((usize + 1) / 2 * BYTES_PER_MP_LIMB); - - /* Iff mpn_sqrtrem returns zero, the square is perfect. */ - res = ! mpn_sqrtrem (root_ptr, NULL, up, usize); - TMP_FREE (marker); - return res; -} diff --git a/gnu/lib/libgmp/mpn/generic/popcount.c b/gnu/lib/libgmp/mpn/generic/popcount.c deleted file mode 100644 index c48573a..0000000 --- a/gnu/lib/libgmp/mpn/generic/popcount.c +++ /dev/null @@ -1,87 +0,0 @@ -/* popcount.c - -Copyright (C) 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -#if defined __GNUC__ -#if defined __sparc_v9__ && BITS_PER_MP_LIMB == 64 -#define popc_limb(a) \ - ({ \ - DItype __res; \ - asm ("popc %1,%0" : "=r" (__res) : "rI" (a)); \ - __res; \ - }) -#endif -#endif - -#ifndef popc_limb - -/* Cool population count of a mp_limb_t. - You have to figure out how this works, I won't tell you! */ - -static inline unsigned int -popc_limb (x) - mp_limb_t x; -{ -#if BITS_PER_MP_LIMB == 64 - /* We have to go into some trouble to define these constants. - (For mp_limb_t being `long long'.) */ - mp_limb_t cnst; - cnst = 0x55555555L | ((mp_limb_t) 0x55555555L << BITS_PER_MP_LIMB/2); - x = ((x & ~cnst) >> 1) + (x & cnst); - cnst = 0x33333333L | ((mp_limb_t) 0x33333333L << BITS_PER_MP_LIMB/2); - x = ((x & ~cnst) >> 2) + (x & cnst); - cnst = 0x0f0f0f0fL | ((mp_limb_t) 0x0f0f0f0fL << BITS_PER_MP_LIMB/2); - x = ((x >> 4) + x) & cnst; - x = ((x >> 8) + x); - x = ((x >> 16) + x); - x = ((x >> 32) + x) & 0xff; -#endif -#if BITS_PER_MP_LIMB == 32 - x = ((x >> 1) & 0x55555555L) + (x & 0x55555555L); - x = ((x >> 2) & 0x33333333L) + (x & 0x33333333L); - x = ((x >> 4) + x) & 0x0f0f0f0fL; - x = ((x >> 8) + x); - x = ((x >> 16) + x) & 0xff; -#endif - return x; -} -#endif - -unsigned long int -#if __STDC__ -mpn_popcount (register mp_srcptr p, register mp_size_t size) -#else -mpn_popcount (p, size) - register mp_srcptr p; - register mp_size_t size; -#endif -{ - unsigned long int popcnt; - mp_size_t i; - - popcnt = 0; - for (i = 0; i < size; i++) - popcnt += popc_limb (p[i]); - - return popcnt; -} diff --git a/gnu/lib/libgmp/mpn/generic/pre_mod_1.c b/gnu/lib/libgmp/mpn/generic/pre_mod_1.c deleted file mode 100644 index 92d413b..0000000 --- a/gnu/lib/libgmp/mpn/generic/pre_mod_1.c +++ /dev/null @@ -1,69 +0,0 @@ -/* mpn_preinv_mod_1 (dividend_ptr, dividend_size, divisor_limb, - divisor_limb_inverted) -- - Divide (DIVIDEND_PTR,,DIVIDEND_SIZE) by the normalized DIVISOR_LIMB. - DIVISOR_LIMB_INVERTED should be 2^(2*BITS_PER_MP_LIMB) / DIVISOR_LIMB + - - 2^BITS_PER_MP_LIMB. - Return the single-limb remainder. - -Copyright (C) 1991, 1993, 1994, 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -#ifndef UMUL_TIME -#define UMUL_TIME 1 -#endif - -#ifndef UDIV_TIME -#define UDIV_TIME UMUL_TIME -#endif - -mp_limb_t -#if __STDC__ -mpn_preinv_mod_1 (mp_srcptr dividend_ptr, mp_size_t dividend_size, - mp_limb_t divisor_limb, mp_limb_t divisor_limb_inverted) -#else -mpn_preinv_mod_1 (dividend_ptr, dividend_size, divisor_limb, divisor_limb_inverted) - mp_srcptr dividend_ptr; - mp_size_t dividend_size; - mp_limb_t divisor_limb; - mp_limb_t divisor_limb_inverted; -#endif -{ - mp_size_t i; - mp_limb_t n0, r; - int dummy; - - i = dividend_size - 1; - r = dividend_ptr[i]; - - if (r >= divisor_limb) - r = 0; - else - i--; - - for (; i >= 0; i--) - { - n0 = dividend_ptr[i]; - udiv_qrnnd_preinv (dummy, r, r, n0, divisor_limb, divisor_limb_inverted); - } - return r; -} diff --git a/gnu/lib/libgmp/mpn/generic/random2.c b/gnu/lib/libgmp/mpn/generic/random2.c deleted file mode 100644 index 2954608..0000000 --- a/gnu/lib/libgmp/mpn/generic/random2.c +++ /dev/null @@ -1,93 +0,0 @@ -/* mpn_random2 -- Generate random numbers with relatively long strings - of ones and zeroes. Suitable for border testing. - -Copyright (C) 1992, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -#if defined (__hpux) || defined (alpha__) || defined (__svr4__) || defined (__SVR4) -/* HPUX lacks random(). DEC OSF/1 1.2 random() returns a double. */ -long mrand48 (); -static inline long -random () -{ - return mrand48 (); -} -#else -long random (); -#endif - -/* It's a bit tricky to get this right, so please test the code well - if you hack with it. Some early versions of the function produced - random numbers with the leading limb == 0, and some versions never - made the most significant bit set. */ - -void -mpn_random2 (res_ptr, size) - mp_ptr res_ptr; - mp_size_t size; -{ - int n_bits; - int bit_pos; - mp_size_t limb_pos; - unsigned int ran; - mp_limb_t limb; - - limb = 0; - - /* Start off in a random bit position in the most significant limb. */ - bit_pos = random () & (BITS_PER_MP_LIMB - 1); - - /* Least significant bit of RAN chooses string of ones/string of zeroes. - Make most significant limb be non-zero by setting bit 0 of RAN. */ - ran = random () | 1; - - for (limb_pos = size - 1; limb_pos >= 0; ) - { - n_bits = (ran >> 1) % BITS_PER_MP_LIMB + 1; - if ((ran & 1) != 0) - { - /* Generate a string of ones. */ - if (n_bits >= bit_pos) - { - res_ptr[limb_pos--] = limb | ((((mp_limb_t) 2) << bit_pos) - 1); - bit_pos += BITS_PER_MP_LIMB; - limb = (~(mp_limb_t) 0) << (bit_pos - n_bits); - } - else - { - limb |= ((((mp_limb_t) 1) << n_bits) - 1) << (bit_pos - n_bits + 1); - } - } - else - { - /* Generate a string of zeroes. */ - if (n_bits >= bit_pos) - { - res_ptr[limb_pos--] = limb; - limb = 0; - bit_pos += BITS_PER_MP_LIMB; - } - } - bit_pos -= n_bits; - ran = random (); - } -} diff --git a/gnu/lib/libgmp/mpn/generic/rshift.c b/gnu/lib/libgmp/mpn/generic/rshift.c deleted file mode 100644 index 804f9be..0000000 --- a/gnu/lib/libgmp/mpn/generic/rshift.c +++ /dev/null @@ -1,88 +0,0 @@ -/* mpn_rshift -- Shift right a low-level natural-number integer. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -/* Shift U (pointed to by UP and USIZE limbs long) CNT bits to the right - and store the USIZE least significant limbs of the result at WP. - The bits shifted out to the right are returned. - - Argument constraints: - 1. 0 < CNT < BITS_PER_MP_LIMB - 2. If the result is to be written over the input, WP must be <= UP. -*/ - -mp_limb_t -#if __STDC__ -mpn_rshift (register mp_ptr wp, - register mp_srcptr up, mp_size_t usize, - register unsigned int cnt) -#else -mpn_rshift (wp, up, usize, cnt) - register mp_ptr wp; - register mp_srcptr up; - mp_size_t usize; - register unsigned int cnt; -#endif -{ - register mp_limb_t high_limb, low_limb; - register unsigned sh_1, sh_2; - register mp_size_t i; - mp_limb_t retval; - -#ifdef DEBUG - if (usize == 0 || cnt == 0) - abort (); -#endif - - sh_1 = cnt; - -#if 0 - if (sh_1 == 0) - { - if (wp != up) - { - /* Copy from low end to high end, to allow specified input/output - overlapping. */ - for (i = 0; i < usize; i++) - wp[i] = up[i]; - } - return usize; - } -#endif - - wp -= 1; - sh_2 = BITS_PER_MP_LIMB - sh_1; - high_limb = up[0]; - retval = high_limb << sh_2; - low_limb = high_limb; - - for (i = 1; i < usize; i++) - { - high_limb = up[i]; - wp[i] = (low_limb >> sh_1) | (high_limb << sh_2); - low_limb = high_limb; - } - wp[i] = low_limb >> sh_1; - - return retval; -} diff --git a/gnu/lib/libgmp/mpn/generic/scan0.c b/gnu/lib/libgmp/mpn/generic/scan0.c deleted file mode 100644 index d6f6580..0000000 --- a/gnu/lib/libgmp/mpn/generic/scan0.c +++ /dev/null @@ -1,62 +0,0 @@ -/* mpn_scan0 -- Scan from a given bit position for the next clear bit. - -Copyright (C) 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -/* Design issues: - 1. What if starting_bit is not within U? Caller's problem? - 2. Bit index should be 'unsigned'? - - Argument constraints: - 1. U must sooner ot later have a limb with a clear bit. - */ - -unsigned long int -#if __STDC__ -mpn_scan0 (register mp_srcptr up, - register unsigned long int starting_bit) -#else -mpn_scan0 (up, starting_bit) - register mp_srcptr up; - register unsigned long int starting_bit; -#endif -{ - mp_size_t starting_word; - mp_limb_t alimb; - int cnt; - mp_srcptr p; - - /* Start at the word implied by STARTING_BIT. */ - starting_word = starting_bit / BITS_PER_MP_LIMB; - p = up + starting_word; - alimb = ~*p++; - - /* Mask off any bits before STARTING_BIT in the first limb. */ - alimb &= - (mp_limb_t) 1 << (starting_bit % BITS_PER_MP_LIMB); - - while (alimb == 0) - alimb = ~*p++; - - count_leading_zeros (cnt, alimb & -alimb); - return (p - up) * BITS_PER_MP_LIMB - 1 - cnt; -} diff --git a/gnu/lib/libgmp/mpn/generic/scan1.c b/gnu/lib/libgmp/mpn/generic/scan1.c deleted file mode 100644 index c95d090..0000000 --- a/gnu/lib/libgmp/mpn/generic/scan1.c +++ /dev/null @@ -1,62 +0,0 @@ -/* mpn_scan1 -- Scan from a given bit position for the next set bit. - -Copyright (C) 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -/* Design issues: - 1. What if starting_bit is not within U? Caller's problem? - 2. Bit index should be 'unsigned'? - - Argument constraints: - 1. U must sooner ot later have a limb != 0. - */ - -unsigned long int -#if __STDC__ -mpn_scan1 (register mp_srcptr up, - register unsigned long int starting_bit) -#else -mpn_scan1 (up, starting_bit) - register mp_srcptr up; - register unsigned long int starting_bit; -#endif -{ - mp_size_t starting_word; - mp_limb_t alimb; - int cnt; - mp_srcptr p; - - /* Start at the word implied by STARTING_BIT. */ - starting_word = starting_bit / BITS_PER_MP_LIMB; - p = up + starting_word; - alimb = *p++; - - /* Mask off any bits before STARTING_BIT in the first limb. */ - alimb &= - (mp_limb_t) 1 << (starting_bit % BITS_PER_MP_LIMB); - - while (alimb == 0) - alimb = *p++; - - count_leading_zeros (cnt, alimb & -alimb); - return (p - up) * BITS_PER_MP_LIMB - 1 - cnt; -} diff --git a/gnu/lib/libgmp/mpn/generic/set_str.c b/gnu/lib/libgmp/mpn/generic/set_str.c deleted file mode 100644 index 424fad3..0000000 --- a/gnu/lib/libgmp/mpn/generic/set_str.c +++ /dev/null @@ -1,154 +0,0 @@ -/* mpn_set_str (mp_ptr res_ptr, const char *str, size_t str_len, int base) - -- Convert a STR_LEN long base BASE byte string pointed to by STR to a - limb vector pointed to by RES_PTR. Return the number of limbs in - RES_PTR. - -Copyright (C) 1991, 1992, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -mp_size_t -mpn_set_str (xp, str, str_len, base) - mp_ptr xp; - const unsigned char *str; - size_t str_len; - int base; -{ - mp_size_t size; - mp_limb_t big_base; - int indigits_per_limb; - mp_limb_t res_digit; - - big_base = __mp_bases[base].big_base; - indigits_per_limb = __mp_bases[base].chars_per_limb; - -/* size = str_len / indigits_per_limb + 1; */ - - size = 0; - - if ((base & (base - 1)) == 0) - { - /* The base is a power of 2. Read the input string from - least to most significant character/digit. */ - - const unsigned char *s; - int next_bitpos; - int bits_per_indigit = big_base; - - res_digit = 0; - next_bitpos = 0; - - for (s = str + str_len - 1; s >= str; s--) - { - int inp_digit = *s; - - res_digit |= (mp_limb_t) inp_digit << next_bitpos; - next_bitpos += bits_per_indigit; - if (next_bitpos >= BITS_PER_MP_LIMB) - { - xp[size++] = res_digit; - next_bitpos -= BITS_PER_MP_LIMB; - res_digit = inp_digit >> (bits_per_indigit - next_bitpos); - } - } - - if (res_digit != 0) - xp[size++] = res_digit; - } - else - { - /* General case. The base is not a power of 2. */ - - size_t i; - int j; - mp_limb_t cy_limb; - - for (i = indigits_per_limb; i < str_len; i += indigits_per_limb) - { - res_digit = *str++; - if (base == 10) - { /* This is a common case. - Help the compiler to avoid multiplication. */ - for (j = 1; j < indigits_per_limb; j++) - res_digit = res_digit * 10 + *str++; - } - else - { - for (j = 1; j < indigits_per_limb; j++) - res_digit = res_digit * base + *str++; - } - - if (size == 0) - { - if (res_digit != 0) - { - xp[0] = res_digit; - size = 1; - } - } - else - { - cy_limb = mpn_mul_1 (xp, xp, size, big_base); - cy_limb += mpn_add_1 (xp, xp, size, res_digit); - if (cy_limb != 0) - xp[size++] = cy_limb; - } - } - - big_base = base; - res_digit = *str++; - if (base == 10) - { /* This is a common case. - Help the compiler to avoid multiplication. */ - for (j = 1; j < str_len - (i - indigits_per_limb); j++) - { - res_digit = res_digit * 10 + *str++; - big_base *= 10; - } - } - else - { - for (j = 1; j < str_len - (i - indigits_per_limb); j++) - { - res_digit = res_digit * base + *str++; - big_base *= base; - } - } - - if (size == 0) - { - if (res_digit != 0) - { - xp[0] = res_digit; - size = 1; - } - } - else - { - cy_limb = mpn_mul_1 (xp, xp, size, big_base); - cy_limb += mpn_add_1 (xp, xp, size, res_digit); - if (cy_limb != 0) - xp[size++] = cy_limb; - } - } - - return size; -} diff --git a/gnu/lib/libgmp/mpn/generic/sqrtrem.c b/gnu/lib/libgmp/mpn/generic/sqrtrem.c deleted file mode 100644 index 539480d..0000000 --- a/gnu/lib/libgmp/mpn/generic/sqrtrem.c +++ /dev/null @@ -1,498 +0,0 @@ -/* mpn_sqrtrem (root_ptr, rem_ptr, op_ptr, op_size) - - Write the square root of {OP_PTR, OP_SIZE} at ROOT_PTR. - Write the remainder at REM_PTR, if REM_PTR != NULL. - Return the size of the remainder. - (The size of the root is always half of the size of the operand.) - - OP_PTR and ROOT_PTR may not point to the same object. - OP_PTR and REM_PTR may point to the same object. - - If REM_PTR is NULL, only the root is computed and the return value of - the function is 0 if OP is a perfect square, and *any* non-zero number - otherwise. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* This code is just correct if "unsigned char" has at least 8 bits. It - doesn't help to use CHAR_BIT from limits.h, as the real problem is - the static arrays. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -/* Square root algorithm: - - 1. Shift OP (the input) to the left an even number of bits s.t. there - are an even number of words and either (or both) of the most - significant bits are set. This way, sqrt(OP) has exactly half as - many words as OP, and has its most significant bit set. - - 2. Get a 9-bit approximation to sqrt(OP) using the pre-computed tables. - This approximation is used for the first single-precision - iterations of Newton's method, yielding a full-word approximation - to sqrt(OP). - - 3. Perform multiple-precision Newton iteration until we have the - exact result. Only about half of the input operand is used in - this calculation, as the square root is perfectly determinable - from just the higher half of a number. */ - -/* Define this macro for IEEE P854 machines with a fast sqrt instruction. */ -#if defined __GNUC__ && ! defined __SOFT_FLOAT - -#if defined __sparc__ -#define SQRT(a) \ - ({ \ - double __sqrt_res; \ - asm ("fsqrtd %1,%0" : "=f" (__sqrt_res) : "f" (a)); \ - __sqrt_res; \ - }) -#endif - -#if defined __HAVE_68881__ -#define SQRT(a) \ - ({ \ - double __sqrt_res; \ - asm ("fsqrtx %1,%0" : "=f" (__sqrt_res) : "f" (a)); \ - __sqrt_res; \ - }) -#endif - -#if defined __hppa -#define SQRT(a) \ - ({ \ - double __sqrt_res; \ - asm ("fsqrt,dbl %1,%0" : "=fx" (__sqrt_res) : "fx" (a)); \ - __sqrt_res; \ - }) -#endif - -#if defined _ARCH_PWR2 -#define SQRT(a) \ - ({ \ - double __sqrt_res; \ - asm ("fsqrt %0,%1" : "=f" (__sqrt_res) : "f" (a)); \ - __sqrt_res; \ - }) -#endif - -#endif - -#ifndef SQRT - -/* Tables for initial approximation of the square root. These are - indexed with bits 1-8 of the operand for which the square root is - calculated, where bit 0 is the most significant non-zero bit. I.e. - the most significant one-bit is not used, since that per definition - is one. Likewise, the tables don't return the highest bit of the - result. That bit must be inserted by or:ing the returned value with - 0x100. This way, we get a 9-bit approximation from 8-bit tables! */ - -/* Table to be used for operands with an even total number of bits. - (Exactly as in the decimal system there are similarities between the - square root of numbers with the same initial digits and an even - difference in the total number of digits. Consider the square root - of 1, 10, 100, 1000, ...) */ -static unsigned char even_approx_tab[256] = -{ - 0x6a, 0x6a, 0x6b, 0x6c, 0x6c, 0x6d, 0x6e, 0x6e, - 0x6f, 0x70, 0x71, 0x71, 0x72, 0x73, 0x73, 0x74, - 0x75, 0x75, 0x76, 0x77, 0x77, 0x78, 0x79, 0x79, - 0x7a, 0x7b, 0x7b, 0x7c, 0x7d, 0x7d, 0x7e, 0x7f, - 0x80, 0x80, 0x81, 0x81, 0x82, 0x83, 0x83, 0x84, - 0x85, 0x85, 0x86, 0x87, 0x87, 0x88, 0x89, 0x89, - 0x8a, 0x8b, 0x8b, 0x8c, 0x8d, 0x8d, 0x8e, 0x8f, - 0x8f, 0x90, 0x90, 0x91, 0x92, 0x92, 0x93, 0x94, - 0x94, 0x95, 0x96, 0x96, 0x97, 0x97, 0x98, 0x99, - 0x99, 0x9a, 0x9b, 0x9b, 0x9c, 0x9c, 0x9d, 0x9e, - 0x9e, 0x9f, 0xa0, 0xa0, 0xa1, 0xa1, 0xa2, 0xa3, - 0xa3, 0xa4, 0xa4, 0xa5, 0xa6, 0xa6, 0xa7, 0xa7, - 0xa8, 0xa9, 0xa9, 0xaa, 0xaa, 0xab, 0xac, 0xac, - 0xad, 0xad, 0xae, 0xaf, 0xaf, 0xb0, 0xb0, 0xb1, - 0xb2, 0xb2, 0xb3, 0xb3, 0xb4, 0xb5, 0xb5, 0xb6, - 0xb6, 0xb7, 0xb7, 0xb8, 0xb9, 0xb9, 0xba, 0xba, - 0xbb, 0xbb, 0xbc, 0xbd, 0xbd, 0xbe, 0xbe, 0xbf, - 0xc0, 0xc0, 0xc1, 0xc1, 0xc2, 0xc2, 0xc3, 0xc3, - 0xc4, 0xc5, 0xc5, 0xc6, 0xc6, 0xc7, 0xc7, 0xc8, - 0xc9, 0xc9, 0xca, 0xca, 0xcb, 0xcb, 0xcc, 0xcc, - 0xcd, 0xce, 0xce, 0xcf, 0xcf, 0xd0, 0xd0, 0xd1, - 0xd1, 0xd2, 0xd3, 0xd3, 0xd4, 0xd4, 0xd5, 0xd5, - 0xd6, 0xd6, 0xd7, 0xd7, 0xd8, 0xd9, 0xd9, 0xda, - 0xda, 0xdb, 0xdb, 0xdc, 0xdc, 0xdd, 0xdd, 0xde, - 0xde, 0xdf, 0xe0, 0xe0, 0xe1, 0xe1, 0xe2, 0xe2, - 0xe3, 0xe3, 0xe4, 0xe4, 0xe5, 0xe5, 0xe6, 0xe6, - 0xe7, 0xe7, 0xe8, 0xe8, 0xe9, 0xea, 0xea, 0xeb, - 0xeb, 0xec, 0xec, 0xed, 0xed, 0xee, 0xee, 0xef, - 0xef, 0xf0, 0xf0, 0xf1, 0xf1, 0xf2, 0xf2, 0xf3, - 0xf3, 0xf4, 0xf4, 0xf5, 0xf5, 0xf6, 0xf6, 0xf7, - 0xf7, 0xf8, 0xf8, 0xf9, 0xf9, 0xfa, 0xfa, 0xfb, - 0xfb, 0xfc, 0xfc, 0xfd, 0xfd, 0xfe, 0xfe, 0xff, -}; - -/* Table to be used for operands with an odd total number of bits. - (Further comments before previous table.) */ -static unsigned char odd_approx_tab[256] = -{ - 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, - 0x03, 0x04, 0x04, 0x05, 0x05, 0x06, 0x06, 0x07, - 0x07, 0x08, 0x08, 0x09, 0x09, 0x0a, 0x0a, 0x0b, - 0x0b, 0x0c, 0x0c, 0x0d, 0x0d, 0x0e, 0x0e, 0x0f, - 0x0f, 0x10, 0x10, 0x10, 0x11, 0x11, 0x12, 0x12, - 0x13, 0x13, 0x14, 0x14, 0x15, 0x15, 0x16, 0x16, - 0x16, 0x17, 0x17, 0x18, 0x18, 0x19, 0x19, 0x1a, - 0x1a, 0x1b, 0x1b, 0x1b, 0x1c, 0x1c, 0x1d, 0x1d, - 0x1e, 0x1e, 0x1f, 0x1f, 0x20, 0x20, 0x20, 0x21, - 0x21, 0x22, 0x22, 0x23, 0x23, 0x23, 0x24, 0x24, - 0x25, 0x25, 0x26, 0x26, 0x27, 0x27, 0x27, 0x28, - 0x28, 0x29, 0x29, 0x2a, 0x2a, 0x2a, 0x2b, 0x2b, - 0x2c, 0x2c, 0x2d, 0x2d, 0x2d, 0x2e, 0x2e, 0x2f, - 0x2f, 0x30, 0x30, 0x30, 0x31, 0x31, 0x32, 0x32, - 0x32, 0x33, 0x33, 0x34, 0x34, 0x35, 0x35, 0x35, - 0x36, 0x36, 0x37, 0x37, 0x37, 0x38, 0x38, 0x39, - 0x39, 0x39, 0x3a, 0x3a, 0x3b, 0x3b, 0x3b, 0x3c, - 0x3c, 0x3d, 0x3d, 0x3d, 0x3e, 0x3e, 0x3f, 0x3f, - 0x40, 0x40, 0x40, 0x41, 0x41, 0x41, 0x42, 0x42, - 0x43, 0x43, 0x43, 0x44, 0x44, 0x45, 0x45, 0x45, - 0x46, 0x46, 0x47, 0x47, 0x47, 0x48, 0x48, 0x49, - 0x49, 0x49, 0x4a, 0x4a, 0x4b, 0x4b, 0x4b, 0x4c, - 0x4c, 0x4c, 0x4d, 0x4d, 0x4e, 0x4e, 0x4e, 0x4f, - 0x4f, 0x50, 0x50, 0x50, 0x51, 0x51, 0x51, 0x52, - 0x52, 0x53, 0x53, 0x53, 0x54, 0x54, 0x54, 0x55, - 0x55, 0x56, 0x56, 0x56, 0x57, 0x57, 0x57, 0x58, - 0x58, 0x59, 0x59, 0x59, 0x5a, 0x5a, 0x5a, 0x5b, - 0x5b, 0x5b, 0x5c, 0x5c, 0x5d, 0x5d, 0x5d, 0x5e, - 0x5e, 0x5e, 0x5f, 0x5f, 0x60, 0x60, 0x60, 0x61, - 0x61, 0x61, 0x62, 0x62, 0x62, 0x63, 0x63, 0x63, - 0x64, 0x64, 0x65, 0x65, 0x65, 0x66, 0x66, 0x66, - 0x67, 0x67, 0x67, 0x68, 0x68, 0x68, 0x69, 0x69, -}; -#endif - - -mp_size_t -#if __STDC__ -mpn_sqrtrem (mp_ptr root_ptr, mp_ptr rem_ptr, mp_srcptr op_ptr, mp_size_t op_size) -#else -mpn_sqrtrem (root_ptr, rem_ptr, op_ptr, op_size) - mp_ptr root_ptr; - mp_ptr rem_ptr; - mp_srcptr op_ptr; - mp_size_t op_size; -#endif -{ - /* R (root result) */ - mp_ptr rp; /* Pointer to least significant word */ - mp_size_t rsize; /* The size in words */ - - /* T (OP shifted to the left a.k.a. normalized) */ - mp_ptr tp; /* Pointer to least significant word */ - mp_size_t tsize; /* The size in words */ - mp_ptr t_end_ptr; /* Pointer right beyond most sign. word */ - mp_limb_t t_high0, t_high1; /* The two most significant words */ - - /* TT (temporary for numerator/remainder) */ - mp_ptr ttp; /* Pointer to least significant word */ - - /* X (temporary for quotient in main loop) */ - mp_ptr xp; /* Pointer to least significant word */ - mp_size_t xsize; /* The size in words */ - - unsigned cnt; - mp_limb_t initial_approx; /* Initially made approximation */ - mp_size_t tsizes[BITS_PER_MP_LIMB]; /* Successive calculation precisions */ - mp_size_t tmp; - mp_size_t i; - - mp_limb_t cy_limb; - TMP_DECL (marker); - - /* If OP is zero, both results are zero. */ - if (op_size == 0) - return 0; - - count_leading_zeros (cnt, op_ptr[op_size - 1]); - tsize = op_size; - if ((tsize & 1) != 0) - { - cnt += BITS_PER_MP_LIMB; - tsize++; - } - - rsize = tsize / 2; - rp = root_ptr; - - TMP_MARK (marker); - - /* Shift OP an even number of bits into T, such that either the most or - the second most significant bit is set, and such that the number of - words in T becomes even. This way, the number of words in R=sqrt(OP) - is exactly half as many as in OP, and the most significant bit of R - is set. - - Also, the initial approximation is simplified by this up-shifted OP. - - Finally, the Newtonian iteration which is the main part of this - program performs division by R. The fast division routine expects - the divisor to be "normalized" in exactly the sense of having the - most significant bit set. */ - - tp = (mp_ptr) TMP_ALLOC (tsize * BYTES_PER_MP_LIMB); - - if ((cnt & ~1) % BITS_PER_MP_LIMB != 0) - t_high0 = mpn_lshift (tp + cnt / BITS_PER_MP_LIMB, op_ptr, op_size, - (cnt & ~1) % BITS_PER_MP_LIMB); - else - MPN_COPY (tp + cnt / BITS_PER_MP_LIMB, op_ptr, op_size); - - if (cnt >= BITS_PER_MP_LIMB) - tp[0] = 0; - - t_high0 = tp[tsize - 1]; - t_high1 = tp[tsize - 2]; /* Never stray. TSIZE is >= 2. */ - -/* Is there a fast sqrt instruction defined for this machine? */ -#ifdef SQRT - { - initial_approx = SQRT (t_high0 * 2.0 - * ((mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1)) - + t_high1); - /* If t_high0,,t_high1 is big, the result in INITIAL_APPROX might have - become incorrect due to overflow in the conversion from double to - mp_limb_t above. It will typically be zero in that case, but might be - a small number on some machines. The most significant bit of - INITIAL_APPROX should be set, so that bit is a good overflow - indication. */ - if ((mp_limb_signed_t) initial_approx >= 0) - initial_approx = ~(mp_limb_t)0; - } -#else - /* Get a 9 bit approximation from the tables. The tables expect to - be indexed with the 8 high bits right below the highest bit. - Also, the highest result bit is not returned by the tables, and - must be or:ed into the result. The scheme gives 9 bits of start - approximation with just 256-entry 8 bit tables. */ - - if ((cnt & 1) == 0) - { - /* The most sign bit of t_high0 is set. */ - initial_approx = t_high0 >> (BITS_PER_MP_LIMB - 8 - 1); - initial_approx &= 0xff; - initial_approx = even_approx_tab[initial_approx]; - } - else - { - /* The most significant bit of T_HIGH0 is unset, - the second most significant is set. */ - initial_approx = t_high0 >> (BITS_PER_MP_LIMB - 8 - 2); - initial_approx &= 0xff; - initial_approx = odd_approx_tab[initial_approx]; - } - initial_approx |= 0x100; - initial_approx <<= BITS_PER_MP_LIMB - 8 - 1; - - /* Perform small precision Newtonian iterations to get a full word - approximation. For small operands, these iteration will make the - entire job. */ - if (t_high0 == ~(mp_limb_t)0) - initial_approx = t_high0; - else - { - mp_limb_t quot; - - if (t_high0 >= initial_approx) - initial_approx = t_high0 + 1; - - /* First get about 18 bits with pure C arithmetics. */ - quot = t_high0 / (initial_approx >> BITS_PER_MP_LIMB/2) << BITS_PER_MP_LIMB/2; - initial_approx = (initial_approx + quot) / 2; - initial_approx |= (mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1); - - /* Now get a full word by one (or for > 36 bit machines) several - iterations. */ - for (i = 16; i < BITS_PER_MP_LIMB; i <<= 1) - { - mp_limb_t ignored_remainder; - - udiv_qrnnd (quot, ignored_remainder, - t_high0, t_high1, initial_approx); - initial_approx = (initial_approx + quot) / 2; - initial_approx |= (mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1); - } - } -#endif - - rp[0] = initial_approx; - rsize = 1; - -#ifdef DEBUG - printf ("\n\nT = "); - mpn_dump (tp, tsize); -#endif - - if (tsize > 2) - { - /* Determine the successive precisions to use in the iteration. We - minimize the precisions, beginning with the highest (i.e. last - iteration) to the lowest (i.e. first iteration). */ - - xp = (mp_ptr) TMP_ALLOC (tsize * BYTES_PER_MP_LIMB); - ttp = (mp_ptr) TMP_ALLOC (tsize * BYTES_PER_MP_LIMB); - - t_end_ptr = tp + tsize; - - tmp = tsize / 2; - for (i = 0;; i++) - { - tsize = (tmp + 1) / 2; - if (tmp == tsize) - break; - tsizes[i] = tsize + tmp; - tmp = tsize; - } - - /* Main Newton iteration loop. For big arguments, most of the - time is spent here. */ - - /* It is possible to do a great optimization here. The successive - divisors in the mpn_divmod call below has more and more leading - words equal to its predecessor. Therefore the beginning of - each division will repeat the same work as did the last - division. If we could guarantee that the leading words of two - consecutive divisors are the same (i.e. in this case, a later - divisor has just more digits at the end) it would be a simple - matter of just using the old remainder of the last division in - a subsequent division, to take care of this optimization. This - idea would surely make a difference even for small arguments. */ - - /* Loop invariants: - - R <= shiftdown_to_same_size(floor(sqrt(OP))) < R + 1. - X - 1 < shiftdown_to_same_size(floor(sqrt(OP))) <= X. - R <= shiftdown_to_same_size(X). */ - - while (--i >= 0) - { - mp_limb_t cy; -#ifdef DEBUG - mp_limb_t old_least_sign_r = rp[0]; - mp_size_t old_rsize = rsize; - - printf ("R = "); - mpn_dump (rp, rsize); -#endif - tsize = tsizes[i]; - - /* Need to copy the numerator into temporary space, as - mpn_divmod overwrites its numerator argument with the - remainder (which we currently ignore). */ - MPN_COPY (ttp, t_end_ptr - tsize, tsize); - cy = mpn_divmod (xp, ttp, tsize, rp, rsize); - xsize = tsize - rsize; - -#ifdef DEBUG - printf ("X =%d ", cy); - mpn_dump (xp, xsize); -#endif - - /* Add X and R with the most significant limbs aligned, - temporarily ignoring at least one limb at the low end of X. */ - tmp = xsize - rsize; - cy += mpn_add_n (xp + tmp, rp, xp + tmp, rsize); - - /* If T begins with more than 2 x BITS_PER_MP_LIMB of ones, we get - intermediate roots that'd need an extra bit. We don't want to - handle that since it would make the subsequent divisor - non-normalized, so round such roots down to be only ones in the - current precision. */ - if (cy == 2) - { - mp_size_t j; - for (j = xsize; j >= 0; j--) - xp[j] = ~(mp_limb_t)0; - } - - /* Divide X by 2 and put the result in R. This is the new - approximation. Shift in the carry from the addition. */ - mpn_rshift (rp, xp, xsize, 1); - rp[xsize - 1] |= ((mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1)); - rsize = xsize; -#ifdef DEBUG - if (old_least_sign_r != rp[rsize - old_rsize]) - printf (">>>>>>>> %d: %0*lX, %0*lX <<<<<<<<\n", - i, 2 * BYTES_PER_MP_LIMB, old_least_sign_r, - 2 * BYTES_PER_MP_LIMB, rp[rsize - old_rsize]); -#endif - } - } - -#ifdef DEBUG - printf ("(final) R = "); - mpn_dump (rp, rsize); -#endif - - /* We computed the square root of OP * 2**(2*floor(cnt/2)). - This has resulted in R being 2**floor(cnt/2) to large. - Shift it down here to fix that. */ - if (cnt / 2 != 0) - { - mpn_rshift (rp, rp, rsize, cnt/2); - rsize -= rp[rsize - 1] == 0; - } - - /* Calculate the remainder. */ - mpn_mul_n (tp, rp, rp, rsize); - tsize = rsize + rsize; - tsize -= tp[tsize - 1] == 0; - if (op_size < tsize - || (op_size == tsize && mpn_cmp (op_ptr, tp, op_size) < 0)) - { - /* R is too large. Decrement it. */ - - /* These operations can't overflow. */ - cy_limb = mpn_sub_n (tp, tp, rp, rsize); - cy_limb += mpn_sub_n (tp, tp, rp, rsize); - mpn_sub_1 (tp + rsize, tp + rsize, tsize - rsize, cy_limb); - mpn_add_1 (tp, tp, tsize, (mp_limb_t) 1); - - mpn_sub_1 (rp, rp, rsize, (mp_limb_t) 1); - -#ifdef DEBUG - printf ("(adjusted) R = "); - mpn_dump (rp, rsize); -#endif - } - - if (rem_ptr != NULL) - { - cy_limb = mpn_sub (rem_ptr, op_ptr, op_size, tp, tsize); - MPN_NORMALIZE (rem_ptr, op_size); - TMP_FREE (marker); - return op_size; - } - else - { - int res; - res = op_size != tsize || mpn_cmp (op_ptr, tp, op_size); - TMP_FREE (marker); - return res; - } -} diff --git a/gnu/lib/libgmp/mpn/generic/sub_n.c b/gnu/lib/libgmp/mpn/generic/sub_n.c deleted file mode 100644 index 9d4b216..0000000 --- a/gnu/lib/libgmp/mpn/generic/sub_n.c +++ /dev/null @@ -1,62 +0,0 @@ -/* mpn_sub_n -- Subtract two limb vectors of equal, non-zero length. - -Copyright (C) 1992, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -mp_limb_t -#if __STDC__ -mpn_sub_n (mp_ptr res_ptr, mp_srcptr s1_ptr, mp_srcptr s2_ptr, mp_size_t size) -#else -mpn_sub_n (res_ptr, s1_ptr, s2_ptr, size) - register mp_ptr res_ptr; - register mp_srcptr s1_ptr; - register mp_srcptr s2_ptr; - mp_size_t size; -#endif -{ - register mp_limb_t x, y, cy; - register mp_size_t j; - - /* The loop counter and index J goes from -SIZE to -1. This way - the loop becomes faster. */ - j = -size; - - /* Offset the base pointers to compensate for the negative indices. */ - s1_ptr -= j; - s2_ptr -= j; - res_ptr -= j; - - cy = 0; - do - { - y = s2_ptr[j]; - x = s1_ptr[j]; - y += cy; /* add previous carry to subtrahend */ - cy = (y < cy); /* get out carry from that addition */ - y = x - y; /* main subtract */ - cy = (y > x) + cy; /* get out carry from the subtract, combine */ - res_ptr[j] = y; - } - while (++j != 0); - - return cy; -} diff --git a/gnu/lib/libgmp/mpn/generic/submul_1.c b/gnu/lib/libgmp/mpn/generic/submul_1.c deleted file mode 100644 index b144283..0000000 --- a/gnu/lib/libgmp/mpn/generic/submul_1.c +++ /dev/null @@ -1,65 +0,0 @@ -/* mpn_submul_1 -- multiply the S1_SIZE long limb vector pointed to by S1_PTR - by S2_LIMB, subtract the S1_SIZE least significant limbs of the product - from the limb vector pointed to by RES_PTR. Return the most significant - limb of the product, adjusted for carry-out from the subtraction. - -Copyright (C) 1992, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -mp_limb_t -mpn_submul_1 (res_ptr, s1_ptr, s1_size, s2_limb) - register mp_ptr res_ptr; - register mp_srcptr s1_ptr; - mp_size_t s1_size; - register mp_limb_t s2_limb; -{ - register mp_limb_t cy_limb; - register mp_size_t j; - register mp_limb_t prod_high, prod_low; - register mp_limb_t x; - - /* The loop counter and index J goes from -SIZE to -1. This way - the loop becomes faster. */ - j = -s1_size; - - /* Offset the base pointers to compensate for the negative indices. */ - res_ptr -= j; - s1_ptr -= j; - - cy_limb = 0; - do - { - umul_ppmm (prod_high, prod_low, s1_ptr[j], s2_limb); - - prod_low += cy_limb; - cy_limb = (prod_low < cy_limb) + prod_high; - - x = res_ptr[j]; - prod_low = x - prod_low; - cy_limb += (prod_low > x); - res_ptr[j] = prod_low; - } - while (++j != 0); - - return cy_limb; -} diff --git a/gnu/lib/libgmp/mpn/generic/udiv_w_sdiv.c b/gnu/lib/libgmp/mpn/generic/udiv_w_sdiv.c deleted file mode 100644 index d9e71b7..0000000 --- a/gnu/lib/libgmp/mpn/generic/udiv_w_sdiv.c +++ /dev/null @@ -1,125 +0,0 @@ -/* mpn_udiv_w_sdiv -- implement udiv_qrnnd on machines with only signed - division. - - Contributed by Peter L. Montgomery. - -Copyright (C) 1992, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -mp_limb_t -mpn_udiv_w_sdiv (rp, a1, a0, d) - mp_limb_t *rp, a1, a0, d; -{ - mp_limb_t q, r; - mp_limb_t c0, c1, b1; - - if ((mp_limb_signed_t) d >= 0) - { - if (a1 < d - a1 - (a0 >> (BITS_PER_MP_LIMB - 1))) - { - /* dividend, divisor, and quotient are nonnegative */ - sdiv_qrnnd (q, r, a1, a0, d); - } - else - { - /* Compute c1*2^32 + c0 = a1*2^32 + a0 - 2^31*d */ - sub_ddmmss (c1, c0, a1, a0, d >> 1, d << (BITS_PER_MP_LIMB - 1)); - /* Divide (c1*2^32 + c0) by d */ - sdiv_qrnnd (q, r, c1, c0, d); - /* Add 2^31 to quotient */ - q += (mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1); - } - } - else - { - b1 = d >> 1; /* d/2, between 2^30 and 2^31 - 1 */ - c1 = a1 >> 1; /* A/2 */ - c0 = (a1 << (BITS_PER_MP_LIMB - 1)) + (a0 >> 1); - - if (a1 < b1) /* A < 2^32*b1, so A/2 < 2^31*b1 */ - { - sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */ - - r = 2*r + (a0 & 1); /* Remainder from A/(2*b1) */ - if ((d & 1) != 0) - { - if (r >= q) - r = r - q; - else if (q - r <= d) - { - r = r - q + d; - q--; - } - else - { - r = r - q + 2*d; - q -= 2; - } - } - } - else if (c1 < b1) /* So 2^31 <= (A/2)/b1 < 2^32 */ - { - c1 = (b1 - 1) - c1; - c0 = ~c0; /* logical NOT */ - - sdiv_qrnnd (q, r, c1, c0, b1); /* (A/2) / (d/2) */ - - q = ~q; /* (A/2)/b1 */ - r = (b1 - 1) - r; - - r = 2*r + (a0 & 1); /* A/(2*b1) */ - - if ((d & 1) != 0) - { - if (r >= q) - r = r - q; - else if (q - r <= d) - { - r = r - q + d; - q--; - } - else - { - r = r - q + 2*d; - q -= 2; - } - } - } - else /* Implies c1 = b1 */ - { /* Hence a1 = d - 1 = 2*b1 - 1 */ - if (a0 >= -d) - { - q = -1; - r = a0 + d; - } - else - { - q = -2; - r = a0 + 2*d; - } - } - } - - *rp = r; - return q; -} diff --git a/gnu/lib/libgmp/mpn/mp_bases.c b/gnu/lib/libgmp/mpn/mp_bases.c deleted file mode 100644 index bbe39b0..0000000 --- a/gnu/lib/libgmp/mpn/mp_bases.c +++ /dev/null @@ -1,549 +0,0 @@ -/* __mp_bases -- Structure for conversion between internal binary - format and strings in base 2..255. The fields are explained in - gmp-impl.h. - - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -#if BITS_PER_MP_LIMB == 32 -const struct bases __mp_bases[256] = -{ - /* 0 */ {0, 0.0, 0, 0}, - /* 1 */ {0, 1e38, 0, 0}, - /* 2 */ {32, 1.00000000, 0x1, 0x0}, - /* 3 */ {20, 0.63092975, 0xcfd41b91, 0x3b563c24}, - /* 4 */ {16, 0.50000000, 0x2, 0x0}, - /* 5 */ {13, 0.43067656, 0x48c27395, 0xc25c2684}, - /* 6 */ {12, 0.38685281, 0x81bf1000, 0xf91bd1b6}, - /* 7 */ {11, 0.35620719, 0x75db9c97, 0x1607a2cb}, - /* 8 */ {10, 0.33333333, 0x3, 0x0}, - /* 9 */ {10, 0.31546488, 0xcfd41b91, 0x3b563c24}, - /* 10 */ {9, 0.30103000, 0x3b9aca00, 0x12e0be82}, - /* 11 */ {9, 0.28906483, 0x8c8b6d2b, 0xd24cde04}, - /* 12 */ {8, 0.27894295, 0x19a10000, 0x3fa39ab5}, - /* 13 */ {8, 0.27023815, 0x309f1021, 0x50f8ac5f}, - /* 14 */ {8, 0.26264954, 0x57f6c100, 0x74843b1e}, - /* 15 */ {8, 0.25595802, 0x98c29b81, 0xad0326c2}, - /* 16 */ {8, 0.25000000, 0x4, 0x0}, - /* 17 */ {7, 0.24465054, 0x18754571, 0x4ef0b6bd}, - /* 18 */ {7, 0.23981247, 0x247dbc80, 0xc0fc48a1}, - /* 19 */ {7, 0.23540891, 0x3547667b, 0x33838942}, - /* 20 */ {7, 0.23137821, 0x4c4b4000, 0xad7f29ab}, - /* 21 */ {7, 0.22767025, 0x6b5a6e1d, 0x313c3d15}, - /* 22 */ {7, 0.22424382, 0x94ace180, 0xb8cca9e0}, - /* 23 */ {7, 0.22106473, 0xcaf18367, 0x42ed6de9}, - /* 24 */ {6, 0.21810429, 0xb640000, 0x67980e0b}, - /* 25 */ {6, 0.21533828, 0xe8d4a51, 0x19799812}, - /* 26 */ {6, 0.21274605, 0x1269ae40, 0xbce85396}, - /* 27 */ {6, 0.21030992, 0x17179149, 0x62c103a9}, - /* 28 */ {6, 0.20801460, 0x1cb91000, 0x1d353d43}, - /* 29 */ {6, 0.20584683, 0x23744899, 0xce1decea}, - /* 30 */ {6, 0.20379505, 0x2b73a840, 0x790fc511}, - /* 31 */ {6, 0.20184909, 0x34e63b41, 0x35b865a0}, - /* 32 */ {6, 0.20000000, 0x5, 0x0}, - /* 33 */ {6, 0.19823986, 0x4cfa3cc1, 0xa9aed1b3}, - /* 34 */ {6, 0.19656163, 0x5c13d840, 0x63dfc229}, - /* 35 */ {6, 0.19495902, 0x6d91b519, 0x2b0fee30}, - /* 36 */ {6, 0.19342640, 0x81bf1000, 0xf91bd1b6}, - /* 37 */ {6, 0.19195872, 0x98ede0c9, 0xac89c3a9}, - /* 38 */ {6, 0.19055141, 0xb3773e40, 0x6d2c32fe}, - /* 39 */ {6, 0.18920036, 0xd1bbc4d1, 0x387907c9}, - /* 40 */ {6, 0.18790182, 0xf4240000, 0xc6f7a0b}, - /* 41 */ {5, 0.18665241, 0x6e7d349, 0x28928154}, - /* 42 */ {5, 0.18544902, 0x7ca30a0, 0x6e8629d}, - /* 43 */ {5, 0.18428883, 0x8c32bbb, 0xd373dca0}, - /* 44 */ {5, 0.18316925, 0x9d46c00, 0xa0b17895}, - /* 45 */ {5, 0.18208790, 0xaffacfd, 0x746811a5}, - /* 46 */ {5, 0.18104260, 0xc46bee0, 0x4da6500f}, - /* 47 */ {5, 0.18003133, 0xdab86ef, 0x2ba23582}, - /* 48 */ {5, 0.17905223, 0xf300000, 0xdb20a88}, - /* 49 */ {5, 0.17810359, 0x10d63af1, 0xe68d5ce4}, - /* 50 */ {5, 0.17718382, 0x12a05f20, 0xb7cdfd9d}, - /* 51 */ {5, 0.17629143, 0x1490aae3, 0x8e583933}, - /* 52 */ {5, 0.17542506, 0x16a97400, 0x697cc3ea}, - /* 53 */ {5, 0.17458343, 0x18ed2825, 0x48a5ca6c}, - /* 54 */ {5, 0.17376534, 0x1b5e4d60, 0x2b52db16}, - /* 55 */ {5, 0.17296969, 0x1dff8297, 0x111586a6}, - /* 56 */ {5, 0.17219543, 0x20d38000, 0xf31d2b36}, - /* 57 */ {5, 0.17144160, 0x23dd1799, 0xc8d76d19}, - /* 58 */ {5, 0.17070728, 0x271f35a0, 0xa2cb1eb4}, - /* 59 */ {5, 0.16999162, 0x2a9ce10b, 0x807c3ec3}, - /* 60 */ {5, 0.16929381, 0x2e593c00, 0x617ec8bf}, - /* 61 */ {5, 0.16861310, 0x3257844d, 0x45746cbe}, - /* 62 */ {5, 0.16794878, 0x369b13e0, 0x2c0aa273}, - /* 63 */ {5, 0.16730018, 0x3b27613f, 0x14f90805}, - /* 64 */ {5, 0.16666667, 0x6, 0x0}, - /* 65 */ {5, 0.16604765, 0x4528a141, 0xd9cf0829}, - /* 66 */ {5, 0.16544255, 0x4aa51420, 0xb6fc4841}, - /* 67 */ {5, 0.16485086, 0x50794633, 0x973054cb}, - /* 68 */ {5, 0.16427205, 0x56a94400, 0x7a1dbe4b}, - /* 69 */ {5, 0.16370566, 0x5d393975, 0x5f7fcd7f}, - /* 70 */ {5, 0.16315122, 0x642d7260, 0x47196c84}, - /* 71 */ {5, 0.16260831, 0x6b8a5ae7, 0x30b43635}, - /* 72 */ {5, 0.16207652, 0x73548000, 0x1c1fa5f6}, - /* 73 */ {5, 0.16155547, 0x7b908fe9, 0x930634a}, - /* 74 */ {5, 0.16104477, 0x84435aa0, 0xef7f4a3c}, - /* 75 */ {5, 0.16054409, 0x8d71d25b, 0xcf5552d2}, - /* 76 */ {5, 0.16005307, 0x97210c00, 0xb1a47c8e}, - /* 77 */ {5, 0.15957142, 0xa1563f9d, 0x9634b43e}, - /* 78 */ {5, 0.15909881, 0xac16c8e0, 0x7cd3817d}, - /* 79 */ {5, 0.15863496, 0xb768278f, 0x65536761}, - /* 80 */ {5, 0.15817959, 0xc3500000, 0x4f8b588e}, - /* 81 */ {5, 0.15773244, 0xcfd41b91, 0x3b563c24}, - /* 82 */ {5, 0.15729325, 0xdcfa6920, 0x28928154}, - /* 83 */ {5, 0.15686177, 0xeac8fd83, 0x1721bfb0}, - /* 84 */ {5, 0.15643779, 0xf9461400, 0x6e8629d}, - /* 85 */ {4, 0.15602107, 0x31c84b1, 0x491cc17c}, - /* 86 */ {4, 0.15561139, 0x342ab10, 0x3a11d83b}, - /* 87 */ {4, 0.15520856, 0x36a2c21, 0x2be074cd}, - /* 88 */ {4, 0.15481238, 0x3931000, 0x1e7a02e7}, - /* 89 */ {4, 0.15442266, 0x3bd5ee1, 0x11d10edd}, - /* 90 */ {4, 0.15403922, 0x3e92110, 0x5d92c68}, - /* 91 */ {4, 0.15366189, 0x4165ef1, 0xf50dbfb2}, - /* 92 */ {4, 0.15329049, 0x4452100, 0xdf9f1316}, - /* 93 */ {4, 0.15292487, 0x4756fd1, 0xcb52a684}, - /* 94 */ {4, 0.15256487, 0x4a75410, 0xb8163e97}, - /* 95 */ {4, 0.15221035, 0x4dad681, 0xa5d8f269}, - /* 96 */ {4, 0.15186115, 0x5100000, 0x948b0fcd}, - /* 97 */ {4, 0.15151715, 0x546d981, 0x841e0215}, - /* 98 */ {4, 0.15117821, 0x57f6c10, 0x74843b1e}, - /* 99 */ {4, 0.15084420, 0x5b9c0d1, 0x65b11e6e}, - /* 100 */ {4, 0.15051500, 0x5f5e100, 0x5798ee23}, - /* 101 */ {4, 0.15019048, 0x633d5f1, 0x4a30b99b}, - /* 102 */ {4, 0.14987054, 0x673a910, 0x3d6e4d94}, - /* 103 */ {4, 0.14955506, 0x6b563e1, 0x314825b0}, - /* 104 */ {4, 0.14924394, 0x6f91000, 0x25b55f2e}, - /* 105 */ {4, 0.14893706, 0x73eb721, 0x1aadaccb}, - /* 106 */ {4, 0.14863434, 0x7866310, 0x10294ba2}, - /* 107 */ {4, 0.14833567, 0x7d01db1, 0x620f8f6}, - /* 108 */ {4, 0.14804096, 0x81bf100, 0xf91bd1b6}, - /* 109 */ {4, 0.14775011, 0x869e711, 0xe6d37b2a}, - /* 110 */ {4, 0.14746305, 0x8ba0a10, 0xd55cff6e}, - /* 111 */ {4, 0.14717969, 0x90c6441, 0xc4ad2db2}, - /* 112 */ {4, 0.14689994, 0x9610000, 0xb4b985cf}, - /* 113 */ {4, 0.14662372, 0x9b7e7c1, 0xa5782bef}, - /* 114 */ {4, 0.14635096, 0xa112610, 0x96dfdd2a}, - /* 115 */ {4, 0.14608158, 0xa6cc591, 0x88e7e509}, - /* 116 */ {4, 0.14581551, 0xacad100, 0x7b8813d3}, - /* 117 */ {4, 0.14555268, 0xb2b5331, 0x6eb8b595}, - /* 118 */ {4, 0.14529302, 0xb8e5710, 0x627289db}, - /* 119 */ {4, 0.14503647, 0xbf3e7a1, 0x56aebc07}, - /* 120 */ {4, 0.14478295, 0xc5c1000, 0x4b66dc33}, - /* 121 */ {4, 0.14453241, 0xcc6db61, 0x4094d8a3}, - /* 122 */ {4, 0.14428479, 0xd345510, 0x3632f7a5}, - /* 123 */ {4, 0.14404003, 0xda48871, 0x2c3bd1f0}, - /* 124 */ {4, 0.14379807, 0xe178100, 0x22aa4d5f}, - /* 125 */ {4, 0.14355885, 0xe8d4a51, 0x19799812}, - /* 126 */ {4, 0.14332233, 0xf05f010, 0x10a523e5}, - /* 127 */ {4, 0.14308844, 0xf817e01, 0x828a237}, - /* 128 */ {4, 0.14285714, 0x7, 0x0}, - /* 129 */ {4, 0.14262838, 0x10818201, 0xf04ec452}, - /* 130 */ {4, 0.14240211, 0x11061010, 0xe136444a}, - /* 131 */ {4, 0.14217828, 0x118db651, 0xd2af9589}, - /* 132 */ {4, 0.14195685, 0x12188100, 0xc4b42a83}, - /* 133 */ {4, 0.14173777, 0x12a67c71, 0xb73dccf5}, - /* 134 */ {4, 0.14152100, 0x1337b510, 0xaa4698c5}, - /* 135 */ {4, 0.14130649, 0x13cc3761, 0x9dc8f729}, - /* 136 */ {4, 0.14109421, 0x14641000, 0x91bf9a30}, - /* 137 */ {4, 0.14088412, 0x14ff4ba1, 0x86257887}, - /* 138 */ {4, 0.14067617, 0x159df710, 0x7af5c98c}, - /* 139 */ {4, 0.14047033, 0x16401f31, 0x702c01a0}, - /* 140 */ {4, 0.14026656, 0x16e5d100, 0x65c3ceb1}, - /* 141 */ {4, 0.14006482, 0x178f1991, 0x5bb91502}, - /* 142 */ {4, 0.13986509, 0x183c0610, 0x5207ec23}, - /* 143 */ {4, 0.13966731, 0x18eca3c1, 0x48ac9c19}, - /* 144 */ {4, 0.13947147, 0x19a10000, 0x3fa39ab5}, - /* 145 */ {4, 0.13927753, 0x1a592841, 0x36e98912}, - /* 146 */ {4, 0.13908545, 0x1b152a10, 0x2e7b3140}, - /* 147 */ {4, 0.13889521, 0x1bd51311, 0x2655840b}, - /* 148 */ {4, 0.13870677, 0x1c98f100, 0x1e7596ea}, - /* 149 */ {4, 0.13852011, 0x1d60d1b1, 0x16d8a20d}, - /* 150 */ {4, 0.13833519, 0x1e2cc310, 0xf7bfe87}, - /* 151 */ {4, 0.13815199, 0x1efcd321, 0x85d2492}, - /* 152 */ {4, 0.13797047, 0x1fd11000, 0x179a9f4}, - /* 153 */ {4, 0.13779062, 0x20a987e1, 0xf59e80eb}, - /* 154 */ {4, 0.13761241, 0x21864910, 0xe8b768db}, - /* 155 */ {4, 0.13743580, 0x226761f1, 0xdc39d6d5}, - /* 156 */ {4, 0.13726078, 0x234ce100, 0xd021c5d1}, - /* 157 */ {4, 0.13708732, 0x2436d4d1, 0xc46b5e37}, - /* 158 */ {4, 0.13691539, 0x25254c10, 0xb912f39c}, - /* 159 */ {4, 0.13674498, 0x26185581, 0xae150294}, - /* 160 */ {4, 0.13657605, 0x27100000, 0xa36e2eb1}, - /* 161 */ {4, 0.13640859, 0x280c5a81, 0x991b4094}, - /* 162 */ {4, 0.13624257, 0x290d7410, 0x8f19241e}, - /* 163 */ {4, 0.13607797, 0x2a135bd1, 0x8564e6b7}, - /* 164 */ {4, 0.13591477, 0x2b1e2100, 0x7bfbb5b4}, - /* 165 */ {4, 0.13575295, 0x2c2dd2f1, 0x72dadcc8}, - /* 166 */ {4, 0.13559250, 0x2d428110, 0x69ffc498}, - /* 167 */ {4, 0.13543338, 0x2e5c3ae1, 0x6167f154}, - /* 168 */ {4, 0.13527558, 0x2f7b1000, 0x5911016e}, - /* 169 */ {4, 0.13511908, 0x309f1021, 0x50f8ac5f}, - /* 170 */ {4, 0.13496386, 0x31c84b10, 0x491cc17c}, - /* 171 */ {4, 0.13480991, 0x32f6d0b1, 0x417b26d8}, - /* 172 */ {4, 0.13465720, 0x342ab100, 0x3a11d83b}, - /* 173 */ {4, 0.13450572, 0x3563fc11, 0x32dee622}, - /* 174 */ {4, 0.13435545, 0x36a2c210, 0x2be074cd}, - /* 175 */ {4, 0.13420637, 0x37e71341, 0x2514bb58}, - /* 176 */ {4, 0.13405847, 0x39310000, 0x1e7a02e7}, - /* 177 */ {4, 0.13391173, 0x3a8098c1, 0x180ea5d0}, - /* 178 */ {4, 0.13376614, 0x3bd5ee10, 0x11d10edd}, - /* 179 */ {4, 0.13362168, 0x3d311091, 0xbbfb88e}, - /* 180 */ {4, 0.13347832, 0x3e921100, 0x5d92c68}, - /* 181 */ {4, 0.13333607, 0x3ff90031, 0x1c024c}, - /* 182 */ {4, 0.13319491, 0x4165ef10, 0xf50dbfb2}, - /* 183 */ {4, 0.13305481, 0x42d8eea1, 0xea30efa3}, - /* 184 */ {4, 0.13291577, 0x44521000, 0xdf9f1316}, - /* 185 */ {4, 0.13277777, 0x45d16461, 0xd555c0c9}, - /* 186 */ {4, 0.13264079, 0x4756fd10, 0xcb52a684}, - /* 187 */ {4, 0.13250483, 0x48e2eb71, 0xc193881f}, - /* 188 */ {4, 0.13236988, 0x4a754100, 0xb8163e97}, - /* 189 */ {4, 0.13223591, 0x4c0e0f51, 0xaed8b724}, - /* 190 */ {4, 0.13210292, 0x4dad6810, 0xa5d8f269}, - /* 191 */ {4, 0.13197089, 0x4f535d01, 0x9d15039d}, - /* 192 */ {4, 0.13183981, 0x51000000, 0x948b0fcd}, - /* 193 */ {4, 0.13170967, 0x52b36301, 0x8c394d1d}, - /* 194 */ {4, 0.13158046, 0x546d9810, 0x841e0215}, - /* 195 */ {4, 0.13145216, 0x562eb151, 0x7c3784f8}, - /* 196 */ {4, 0.13132477, 0x57f6c100, 0x74843b1e}, - /* 197 */ {4, 0.13119827, 0x59c5d971, 0x6d02985d}, - /* 198 */ {4, 0.13107265, 0x5b9c0d10, 0x65b11e6e}, - /* 199 */ {4, 0.13094791, 0x5d796e61, 0x5e8e5c64}, - /* 200 */ {4, 0.13082402, 0x5f5e1000, 0x5798ee23}, - /* 201 */ {4, 0.13070099, 0x614a04a1, 0x50cf7bde}, - /* 202 */ {4, 0.13057879, 0x633d5f10, 0x4a30b99b}, - /* 203 */ {4, 0.13045743, 0x65383231, 0x43bb66bd}, - /* 204 */ {4, 0.13033688, 0x673a9100, 0x3d6e4d94}, - /* 205 */ {4, 0.13021715, 0x69448e91, 0x374842ee}, - /* 206 */ {4, 0.13009822, 0x6b563e10, 0x314825b0}, - /* 207 */ {4, 0.12998007, 0x6d6fb2c1, 0x2b6cde75}, - /* 208 */ {4, 0.12986271, 0x6f910000, 0x25b55f2e}, - /* 209 */ {4, 0.12974613, 0x71ba3941, 0x2020a2c5}, - /* 210 */ {4, 0.12963031, 0x73eb7210, 0x1aadaccb}, - /* 211 */ {4, 0.12951524, 0x7624be11, 0x155b891f}, - /* 212 */ {4, 0.12940092, 0x78663100, 0x10294ba2}, - /* 213 */ {4, 0.12928734, 0x7aafdeb1, 0xb160fe9}, - /* 214 */ {4, 0.12917448, 0x7d01db10, 0x620f8f6}, - /* 215 */ {4, 0.12906235, 0x7f5c3a21, 0x14930ef}, - /* 216 */ {4, 0.12895094, 0x81bf1000, 0xf91bd1b6}, - /* 217 */ {4, 0.12884022, 0x842a70e1, 0xefdcb0c7}, - /* 218 */ {4, 0.12873021, 0x869e7110, 0xe6d37b2a}, - /* 219 */ {4, 0.12862089, 0x891b24f1, 0xddfeb94a}, - /* 220 */ {4, 0.12851224, 0x8ba0a100, 0xd55cff6e}, - /* 221 */ {4, 0.12840428, 0x8e2ef9d1, 0xcceced50}, - /* 222 */ {4, 0.12829698, 0x90c64410, 0xc4ad2db2}, - /* 223 */ {4, 0.12819034, 0x93669481, 0xbc9c75f9}, - /* 224 */ {4, 0.12808435, 0x96100000, 0xb4b985cf}, - /* 225 */ {4, 0.12797901, 0x98c29b81, 0xad0326c2}, - /* 226 */ {4, 0.12787431, 0x9b7e7c10, 0xa5782bef}, - /* 227 */ {4, 0.12777024, 0x9e43b6d1, 0x9e1771a9}, - /* 228 */ {4, 0.12766680, 0xa1126100, 0x96dfdd2a}, - /* 229 */ {4, 0.12756398, 0xa3ea8ff1, 0x8fd05c41}, - /* 230 */ {4, 0.12746176, 0xa6cc5910, 0x88e7e509}, - /* 231 */ {4, 0.12736016, 0xa9b7d1e1, 0x8225759d}, - /* 232 */ {4, 0.12725915, 0xacad1000, 0x7b8813d3}, - /* 233 */ {4, 0.12715874, 0xafac2921, 0x750eccf9}, - /* 234 */ {4, 0.12705891, 0xb2b53310, 0x6eb8b595}, - /* 235 */ {4, 0.12695967, 0xb5c843b1, 0x6884e923}, - /* 236 */ {4, 0.12686100, 0xb8e57100, 0x627289db}, - /* 237 */ {4, 0.12676290, 0xbc0cd111, 0x5c80c07b}, - /* 238 */ {4, 0.12666537, 0xbf3e7a10, 0x56aebc07}, - /* 239 */ {4, 0.12656839, 0xc27a8241, 0x50fbb19b}, - /* 240 */ {4, 0.12647197, 0xc5c10000, 0x4b66dc33}, - /* 241 */ {4, 0.12637609, 0xc91209c1, 0x45ef7c7c}, - /* 242 */ {4, 0.12628075, 0xcc6db610, 0x4094d8a3}, - /* 243 */ {4, 0.12618595, 0xcfd41b91, 0x3b563c24}, - /* 244 */ {4, 0.12609168, 0xd3455100, 0x3632f7a5}, - /* 245 */ {4, 0.12599794, 0xd6c16d31, 0x312a60c3}, - /* 246 */ {4, 0.12590471, 0xda488710, 0x2c3bd1f0}, - /* 247 */ {4, 0.12581200, 0xdddab5a1, 0x2766aa45}, - /* 248 */ {4, 0.12571980, 0xe1781000, 0x22aa4d5f}, - /* 249 */ {4, 0.12562811, 0xe520ad61, 0x1e06233c}, - /* 250 */ {4, 0.12553692, 0xe8d4a510, 0x19799812}, - /* 251 */ {4, 0.12544622, 0xec940e71, 0x15041c33}, - /* 252 */ {4, 0.12535601, 0xf05f0100, 0x10a523e5}, - /* 253 */ {4, 0.12526629, 0xf4359451, 0xc5c2749}, - /* 254 */ {4, 0.12517705, 0xf817e010, 0x828a237}, - /* 255 */ {4, 0.12508829, 0xfc05fc01, 0x40a1423}, -}; -#endif -#if BITS_PER_MP_LIMB == 64 -const struct bases __mp_bases[256] = -{ - /* 0 */ {0, 0.0, 0, 0}, - /* 1 */ {0, 1e38, 0, 0}, - /* 2 */ {64, 1.00000000, 0x1, 0x0}, - /* 3 */ {40, 0.63092975, 0xa8b8b452291fe821L, 0x846d550e37b5063dL}, - /* 4 */ {32, 0.50000000, 0x2L, 0x0L}, - /* 5 */ {27, 0.43067656, 0x6765c793fa10079dL, 0x3ce9a36f23c0fc90L}, - /* 6 */ {24, 0.38685281, 0x41c21cb8e1000000L, 0xf24f62335024a295L}, - /* 7 */ {22, 0.35620719, 0x3642798750226111L, 0x2df495ccaa57147bL}, - /* 8 */ {21, 0.33333333, 0x3L, 0x0L}, - /* 9 */ {20, 0.31546488, 0xa8b8b452291fe821L, 0x846d550e37b5063dL}, - /* 10 */ {19, 0.30103000, 0x8ac7230489e80000L, 0xd83c94fb6d2ac34aL}, - /* 11 */ {18, 0.28906483, 0x4d28cb56c33fa539L, 0xa8adf7ae45e7577bL}, - /* 12 */ {17, 0.27894295, 0x1eca170c00000000L, 0xa10c2bec5da8f8fL}, - /* 13 */ {17, 0.27023815, 0x780c7372621bd74dL, 0x10f4becafe412ec3L}, - /* 14 */ {16, 0.26264954, 0x1e39a5057d810000L, 0xf08480f672b4e86L}, - /* 15 */ {16, 0.25595802, 0x5b27ac993df97701L, 0x6779c7f90dc42f48L}, - /* 16 */ {16, 0.25000000, 0x4L, 0x0L}, - /* 17 */ {15, 0.24465054, 0x27b95e997e21d9f1L, 0x9c71e11bab279323L}, - /* 18 */ {15, 0.23981247, 0x5da0e1e53c5c8000L, 0x5dfaa697ec6f6a1cL}, - /* 19 */ {15, 0.23540891, 0xd2ae3299c1c4aedbL, 0x3711783f6be7e9ecL}, - /* 20 */ {14, 0.23137821, 0x16bcc41e90000000L, 0x6849b86a12b9b01eL}, - /* 21 */ {14, 0.22767025, 0x2d04b7fdd9c0ef49L, 0x6bf097ba5ca5e239L}, - /* 22 */ {14, 0.22424382, 0x5658597bcaa24000L, 0x7b8015c8d7af8f08L}, - /* 23 */ {14, 0.22106473, 0xa0e2073737609371L, 0x975a24b3a3151b38L}, - /* 24 */ {13, 0.21810429, 0xc29e98000000000L, 0x50bd367972689db1L}, - /* 25 */ {13, 0.21533828, 0x14adf4b7320334b9L, 0x8c240c4aecb13bb5L}, - /* 26 */ {13, 0.21274605, 0x226ed36478bfa000L, 0xdbd2e56854e118c9L}, - /* 27 */ {13, 0.21030992, 0x383d9170b85ff80bL, 0x2351ffcaa9c7c4aeL}, - /* 28 */ {13, 0.20801460, 0x5a3c23e39c000000L, 0x6b24188ca33b0636L}, - /* 29 */ {13, 0.20584683, 0x8e65137388122bcdL, 0xcc3dceaf2b8ba99dL}, - /* 30 */ {13, 0.20379505, 0xdd41bb36d259e000L, 0x2832e835c6c7d6b6L}, - /* 31 */ {12, 0.20184909, 0xaee5720ee830681L, 0x76b6aa272e1873c5L}, - /* 32 */ {12, 0.20000000, 0x5L, 0x0L}, - /* 33 */ {12, 0.19823986, 0x172588ad4f5f0981L, 0x61eaf5d402c7bf4fL}, - /* 34 */ {12, 0.19656163, 0x211e44f7d02c1000L, 0xeeb658123ffb27ecL}, - /* 35 */ {12, 0.19495902, 0x2ee56725f06e5c71L, 0x5d5e3762e6fdf509L}, - /* 36 */ {12, 0.19342640, 0x41c21cb8e1000000L, 0xf24f62335024a295L}, - /* 37 */ {12, 0.19195872, 0x5b5b57f8a98a5dd1L, 0x66ae7831762efb6fL}, - /* 38 */ {12, 0.19055141, 0x7dcff8986ea31000L, 0x47388865a00f544L}, - /* 39 */ {12, 0.18920036, 0xabd4211662a6b2a1L, 0x7d673c33a123b54cL}, - /* 40 */ {12, 0.18790182, 0xe8d4a51000000000L, 0x19799812dea11197L}, - /* 41 */ {11, 0.18665241, 0x7a32956ad081b79L, 0xc27e62e0686feaeL}, - /* 42 */ {11, 0.18544902, 0x9f49aaff0e86800L, 0x9b6e7507064ce7c7L}, - /* 43 */ {11, 0.18428883, 0xce583bb812d37b3L, 0x3d9ac2bf66cfed94L}, - /* 44 */ {11, 0.18316925, 0x109b79a654c00000L, 0xed46bc50ce59712aL}, - /* 45 */ {11, 0.18208790, 0x1543beff214c8b95L, 0x813d97e2c89b8d46L}, - /* 46 */ {11, 0.18104260, 0x1b149a79459a3800L, 0x2e81751956af8083L}, - /* 47 */ {11, 0.18003133, 0x224edfb5434a830fL, 0xdd8e0a95e30c0988L}, - /* 48 */ {11, 0.17905223, 0x2b3fb00000000000L, 0x7ad4dd48a0b5b167L}, - /* 49 */ {11, 0.17810359, 0x3642798750226111L, 0x2df495ccaa57147bL}, - /* 50 */ {11, 0.17718382, 0x43c33c1937564800L, 0xe392010175ee5962L}, - /* 51 */ {11, 0.17629143, 0x54411b2441c3cd8bL, 0x84eaf11b2fe7738eL}, - /* 52 */ {11, 0.17542506, 0x6851455acd400000L, 0x3a1e3971e008995dL}, - /* 53 */ {11, 0.17458343, 0x80a23b117c8feb6dL, 0xfd7a462344ffce25L}, - /* 54 */ {11, 0.17376534, 0x9dff7d32d5dc1800L, 0x9eca40b40ebcef8aL}, - /* 55 */ {11, 0.17296969, 0xc155af6faeffe6a7L, 0x52fa161a4a48e43dL}, - /* 56 */ {11, 0.17219543, 0xebb7392e00000000L, 0x1607a2cbacf930c1L}, - /* 57 */ {10, 0.17144160, 0x50633659656d971L, 0x97a014f8e3be55f1L}, - /* 58 */ {10, 0.17070728, 0x5fa8624c7fba400L, 0x568df8b76cbf212cL}, - /* 59 */ {10, 0.16999162, 0x717d9faa73c5679L, 0x20ba7c4b4e6ef492L}, - /* 60 */ {10, 0.16929381, 0x86430aac6100000L, 0xe81ee46b9ef492f5L}, - /* 61 */ {10, 0.16861310, 0x9e64d9944b57f29L, 0x9dc0d10d51940416L}, - /* 62 */ {10, 0.16794878, 0xba5ca5392cb0400L, 0x5fa8ed2f450272a5L}, - /* 63 */ {10, 0.16730018, 0xdab2ce1d022cd81L, 0x2ba9eb8c5e04e641L}, - /* 64 */ {10, 0.16666667, 0x6L, 0x0L}, - /* 65 */ {10, 0.16604765, 0x12aeed5fd3e2d281L, 0xb67759cc00287bf1L}, - /* 66 */ {10, 0.16544255, 0x15c3da1572d50400L, 0x78621feeb7f4ed33L}, - /* 67 */ {10, 0.16485086, 0x194c05534f75ee29L, 0x43d55b5f72943bc0L}, - /* 68 */ {10, 0.16427205, 0x1d56299ada100000L, 0x173decb64d1d4409L}, - /* 69 */ {10, 0.16370566, 0x21f2a089a4ff4f79L, 0xe29fb54fd6b6074fL}, - /* 70 */ {10, 0.16315122, 0x2733896c68d9a400L, 0xa1f1f5c210d54e62L}, - /* 71 */ {10, 0.16260831, 0x2d2cf2c33b533c71L, 0x6aac7f9bfafd57b2L}, - /* 72 */ {10, 0.16207652, 0x33f506e440000000L, 0x3b563c2478b72ee2L}, - /* 73 */ {10, 0.16155547, 0x3ba43bec1d062211L, 0x12b536b574e92d1bL}, - /* 74 */ {10, 0.16104477, 0x4455872d8fd4e400L, 0xdf86c03020404fa5L}, - /* 75 */ {10, 0.16054409, 0x4e2694539f2f6c59L, 0xa34adf02234eea8eL}, - /* 76 */ {10, 0.16005307, 0x5938006c18900000L, 0x6f46eb8574eb59ddL}, - /* 77 */ {10, 0.15957142, 0x65ad9912474aa649L, 0x42459b481df47cecL}, - /* 78 */ {10, 0.15909881, 0x73ae9ff4241ec400L, 0x1b424b95d80ca505L}, - /* 79 */ {10, 0.15863496, 0x836612ee9c4ce1e1L, 0xf2c1b982203a0dacL}, - /* 80 */ {10, 0.15817959, 0x9502f90000000000L, 0xb7cdfd9d7bdbab7dL}, - /* 81 */ {10, 0.15773244, 0xa8b8b452291fe821L, 0x846d550e37b5063dL}, - /* 82 */ {10, 0.15729325, 0xbebf59a07dab4400L, 0x57931eeaf85cf64fL}, - /* 83 */ {10, 0.15686177, 0xd7540d4093bc3109L, 0x305a944507c82f47L}, - /* 84 */ {10, 0.15643779, 0xf2b96616f1900000L, 0xe007ccc9c22781aL}, - /* 85 */ {9, 0.15602107, 0x336de62af2bca35L, 0x3e92c42e000eeed4L}, - /* 86 */ {9, 0.15561139, 0x39235ec33d49600L, 0x1ebe59130db2795eL}, - /* 87 */ {9, 0.15520856, 0x3f674e539585a17L, 0x268859e90f51b89L}, - /* 88 */ {9, 0.15481238, 0x4645b6958000000L, 0xd24cde0463108cfaL}, - /* 89 */ {9, 0.15442266, 0x4dcb74afbc49c19L, 0xa536009f37adc383L}, - /* 90 */ {9, 0.15403922, 0x56064e1d18d9a00L, 0x7cea06ce1c9ace10L}, - /* 91 */ {9, 0.15366189, 0x5f04fe2cd8a39fbL, 0x58db032e72e8ba43L}, - /* 92 */ {9, 0.15329049, 0x68d74421f5c0000L, 0x388cc17cae105447L}, - /* 93 */ {9, 0.15292487, 0x738df1f6ab4827dL, 0x1b92672857620ce0L}, - /* 94 */ {9, 0.15256487, 0x7f3afbc9cfb5e00L, 0x18c6a9575c2ade4L}, - /* 95 */ {9, 0.15221035, 0x8bf187fba88f35fL, 0xd44da7da8e44b24fL}, - /* 96 */ {9, 0.15186115, 0x99c600000000000L, 0xaa2f78f1b4cc6794L}, - /* 97 */ {9, 0.15151715, 0xa8ce21eb6531361L, 0x843c067d091ee4ccL}, - /* 98 */ {9, 0.15117821, 0xb92112c1a0b6200L, 0x62005e1e913356e3L}, - /* 99 */ {9, 0.15084420, 0xcad7718b8747c43L, 0x4316eed01dedd518L}, - /* 100 */ {9, 0.15051500, 0xde0b6b3a7640000L, 0x2725dd1d243aba0eL}, - /* 101 */ {9, 0.15019048, 0xf2d8cf5fe6d74c5L, 0xddd9057c24cb54fL}, - /* 102 */ {9, 0.14987054, 0x1095d25bfa712600L, 0xedeee175a736d2a1L}, - /* 103 */ {9, 0.14955506, 0x121b7c4c3698faa7L, 0xc4699f3df8b6b328L}, - /* 104 */ {9, 0.14924394, 0x13c09e8d68000000L, 0x9ebbe7d859cb5a7cL}, - /* 105 */ {9, 0.14893706, 0x15876ccb0b709ca9L, 0x7c828b9887eb2179L}, - /* 106 */ {9, 0.14863434, 0x17723c2976da2a00L, 0x5d652ab99001adcfL}, - /* 107 */ {9, 0.14833567, 0x198384e9c259048bL, 0x4114f1754e5d7b32L}, - /* 108 */ {9, 0.14804096, 0x1bbde41dfeec0000L, 0x274b7c902f7e0188L}, - /* 109 */ {9, 0.14775011, 0x1e241d6e3337910dL, 0xfc9e0fbb32e210cL}, - /* 110 */ {9, 0.14746305, 0x20b91cee9901ee00L, 0xf4afa3e594f8ea1fL}, - /* 111 */ {9, 0.14717969, 0x237ff9079863dfefL, 0xcd85c32e9e4437b0L}, - /* 112 */ {9, 0.14689994, 0x267bf47000000000L, 0xa9bbb147e0dd92a8L}, - /* 113 */ {9, 0.14662372, 0x29b08039fbeda7f1L, 0x8900447b70e8eb82L}, - /* 114 */ {9, 0.14635096, 0x2d213df34f65f200L, 0x6b0a92adaad5848aL}, - /* 115 */ {9, 0.14608158, 0x30d201d957a7c2d3L, 0x4f990ad8740f0ee5L}, - /* 116 */ {9, 0.14581551, 0x34c6d52160f40000L, 0x3670a9663a8d3610L}, - /* 117 */ {9, 0.14555268, 0x3903f855d8f4c755L, 0x1f5c44188057be3cL}, - /* 118 */ {9, 0.14529302, 0x3d8de5c8ec59b600L, 0xa2bea956c4e4977L}, - /* 119 */ {9, 0.14503647, 0x4269541d1ff01337L, 0xed68b23033c3637eL}, - /* 120 */ {9, 0.14478295, 0x479b38e478000000L, 0xc99cf624e50549c5L}, - /* 121 */ {9, 0.14453241, 0x4d28cb56c33fa539L, 0xa8adf7ae45e7577bL}, - /* 122 */ {9, 0.14428479, 0x5317871fa13aba00L, 0x8a5bc740b1c113e5L}, - /* 123 */ {9, 0.14404003, 0x596d2f44de9fa71bL, 0x6e6c7efb81cfbb9bL}, - /* 124 */ {9, 0.14379807, 0x602fd125c47c0000L, 0x54aba5c5cada5f10L}, - /* 125 */ {9, 0.14355885, 0x6765c793fa10079dL, 0x3ce9a36f23c0fc90L}, - /* 126 */ {9, 0.14332233, 0x6f15be069b847e00L, 0x26fb43de2c8cd2a8L}, - /* 127 */ {9, 0.14308844, 0x7746b3e82a77047fL, 0x12b94793db8486a1L}, - /* 128 */ {9, 0.14285714, 0x7L, 0x0L}, - /* 129 */ {9, 0.14262838, 0x894953f7ea890481L, 0xdd5deca404c0156dL}, - /* 130 */ {9, 0.14240211, 0x932abffea4848200L, 0xbd51373330291de0L}, - /* 131 */ {9, 0.14217828, 0x9dacb687d3d6a163L, 0x9fa4025d66f23085L}, - /* 132 */ {9, 0.14195685, 0xa8d8102a44840000L, 0x842530ee2db4949dL}, - /* 133 */ {9, 0.14173777, 0xb4b60f9d140541e5L, 0x6aa7f2766b03dc25L}, - /* 134 */ {9, 0.14152100, 0xc15065d4856e4600L, 0x53035ba7ebf32e8dL}, - /* 135 */ {9, 0.14130649, 0xceb1363f396d23c7L, 0x3d12091fc9fb4914L}, - /* 136 */ {9, 0.14109421, 0xdce31b2488000000L, 0x28b1cb81b1ef1849L}, - /* 137 */ {9, 0.14088412, 0xebf12a24bca135c9L, 0x15c35be67ae3e2c9L}, - /* 138 */ {9, 0.14067617, 0xfbe6f8dbf88f4a00L, 0x42a17bd09be1ff0L}, - /* 139 */ {8, 0.14047033, 0x1ef156c084ce761L, 0x8bf461f03cf0bbfL}, - /* 140 */ {8, 0.14026656, 0x20c4e3b94a10000L, 0xf3fbb43f68a32d05L}, - /* 141 */ {8, 0.14006482, 0x22b0695a08ba421L, 0xd84f44c48564dc19L}, - /* 142 */ {8, 0.13986509, 0x24b4f35d7a4c100L, 0xbe58ebcce7956abeL}, - /* 143 */ {8, 0.13966731, 0x26d397284975781L, 0xa5fac463c7c134b7L}, - /* 144 */ {8, 0.13947147, 0x290d74100000000L, 0x8f19241e28c7d757L}, - /* 145 */ {8, 0.13927753, 0x2b63b3a37866081L, 0x799a6d046c0ae1aeL}, - /* 146 */ {8, 0.13908545, 0x2dd789f4d894100L, 0x6566e37d746a9e40L}, - /* 147 */ {8, 0.13889521, 0x306a35e51b58721L, 0x526887dbfb5f788fL}, - /* 148 */ {8, 0.13870677, 0x331d01712e10000L, 0x408af3382b8efd3dL}, - /* 149 */ {8, 0.13852011, 0x35f14200a827c61L, 0x2fbb374806ec05f1L}, - /* 150 */ {8, 0.13833519, 0x38e858b62216100L, 0x1fe7c0f0afce87feL}, - /* 151 */ {8, 0.13815199, 0x3c03b2c13176a41L, 0x11003d517540d32eL}, - /* 152 */ {8, 0.13797047, 0x3f44c9b21000000L, 0x2f5810f98eff0dcL}, - /* 153 */ {8, 0.13779062, 0x42ad23cef3113c1L, 0xeb72e35e7840d910L}, - /* 154 */ {8, 0.13761241, 0x463e546b19a2100L, 0xd27de19593dc3614L}, - /* 155 */ {8, 0.13743580, 0x49f9fc3f96684e1L, 0xbaf391fd3e5e6fc2L}, - /* 156 */ {8, 0.13726078, 0x4de1c9c5dc10000L, 0xa4bd38c55228c81dL}, - /* 157 */ {8, 0.13708732, 0x51f77994116d2a1L, 0x8fc5a8de8e1de782L}, - /* 158 */ {8, 0.13691539, 0x563cd6bb3398100L, 0x7bf9265bea9d3a3bL}, - /* 159 */ {8, 0.13674498, 0x5ab3bb270beeb01L, 0x69454b325983dccdL}, - /* 160 */ {8, 0.13657605, 0x5f5e10000000000L, 0x5798ee2308c39df9L}, - /* 161 */ {8, 0.13640859, 0x643dce0ec16f501L, 0x46e40ba0fa66a753L}, - /* 162 */ {8, 0.13624257, 0x6954fe21e3e8100L, 0x3717b0870b0db3a7L}, - /* 163 */ {8, 0.13607797, 0x6ea5b9755f440a1L, 0x2825e6775d11cdebL}, - /* 164 */ {8, 0.13591477, 0x74322a1c0410000L, 0x1a01a1c09d1b4dacL}, - /* 165 */ {8, 0.13575295, 0x79fc8b6ae8a46e1L, 0xc9eb0a8bebc8f3eL}, - /* 166 */ {8, 0.13559250, 0x80072a66d512100L, 0xffe357ff59e6a004L}, - /* 167 */ {8, 0.13543338, 0x86546633b42b9c1L, 0xe7dfd1be05fa61a8L}, - /* 168 */ {8, 0.13527558, 0x8ce6b0861000000L, 0xd11ed6fc78f760e5L}, - /* 169 */ {8, 0.13511908, 0x93c08e16a022441L, 0xbb8db609dd29ebfeL}, - /* 170 */ {8, 0.13496386, 0x9ae49717f026100L, 0xa71aec8d1813d532L}, - /* 171 */ {8, 0.13480991, 0xa25577ae24c1a61L, 0x93b612a9f20fbc02L}, - /* 172 */ {8, 0.13465720, 0xaa15f068e610000L, 0x814fc7b19a67d317L}, - /* 173 */ {8, 0.13450572, 0xb228d6bf7577921L, 0x6fd9a03f2e0a4b7cL}, - /* 174 */ {8, 0.13435545, 0xba91158ef5c4100L, 0x5f4615a38d0d316eL}, - /* 175 */ {8, 0.13420637, 0xc351ad9aec0b681L, 0x4f8876863479a286L}, - /* 176 */ {8, 0.13405847, 0xcc6db6100000000L, 0x4094d8a3041b60ebL}, - /* 177 */ {8, 0.13391173, 0xd5e85d09025c181L, 0x32600b8ed883a09bL}, - /* 178 */ {8, 0.13376614, 0xdfc4e816401c100L, 0x24df8c6eb4b6d1f1L}, - /* 179 */ {8, 0.13362168, 0xea06b4c72947221L, 0x18097a8ee151acefL}, - /* 180 */ {8, 0.13347832, 0xf4b139365210000L, 0xbd48cc8ec1cd8e3L}, - /* 181 */ {8, 0.13333607, 0xffc80497d520961L, 0x3807a8d67485fbL}, - /* 182 */ {8, 0.13319491, 0x10b4ebfca1dee100L, 0xea5768860b62e8d8L}, - /* 183 */ {8, 0.13305481, 0x117492de921fc141L, 0xd54faf5b635c5005L}, - /* 184 */ {8, 0.13291577, 0x123bb2ce41000000L, 0xc14a56233a377926L}, - /* 185 */ {8, 0.13277777, 0x130a8b6157bdecc1L, 0xae39a88db7cd329fL}, - /* 186 */ {8, 0.13264079, 0x13e15dede0e8a100L, 0x9c10bde69efa7ab6L}, - /* 187 */ {8, 0.13250483, 0x14c06d941c0ca7e1L, 0x8ac36c42a2836497L}, - /* 188 */ {8, 0.13236988, 0x15a7ff487a810000L, 0x7a463c8b84f5ef67L}, - /* 189 */ {8, 0.13223591, 0x169859ddc5c697a1L, 0x6a8e5f5ad090fd4bL}, - /* 190 */ {8, 0.13210292, 0x1791c60f6fed0100L, 0x5b91a2943596fc56L}, - /* 191 */ {8, 0.13197089, 0x18948e8c0e6fba01L, 0x4d4667b1c468e8f0L}, - /* 192 */ {8, 0.13183981, 0x19a1000000000000L, 0x3fa39ab547994dafL}, - /* 193 */ {8, 0.13170967, 0x1ab769203dafc601L, 0x32a0a9b2faee1e2aL}, - /* 194 */ {8, 0.13158046, 0x1bd81ab557f30100L, 0x26357ceac0e96962L}, - /* 195 */ {8, 0.13145216, 0x1d0367a69fed1ba1L, 0x1a5a6f65caa5859eL}, - /* 196 */ {8, 0.13132477, 0x1e39a5057d810000L, 0xf08480f672b4e86L}, - /* 197 */ {8, 0.13119827, 0x1f7b2a18f29ac3e1L, 0x4383340615612caL}, - /* 198 */ {8, 0.13107265, 0x20c850694c2aa100L, 0xf3c77969ee4be5a2L}, - /* 199 */ {8, 0.13094791, 0x222173cc014980c1L, 0xe00993cc187c5ec9L}, - /* 200 */ {8, 0.13082402, 0x2386f26fc1000000L, 0xcd2b297d889bc2b6L}, - /* 201 */ {8, 0.13070099, 0x24f92ce8af296d41L, 0xbb214d5064862b22L}, - /* 202 */ {8, 0.13057879, 0x2678863cd0ece100L, 0xa9e1a7ca7ea10e20L}, - /* 203 */ {8, 0.13045743, 0x280563f0a9472d61L, 0x99626e72b39ea0cfL}, - /* 204 */ {8, 0.13033688, 0x29a02e1406210000L, 0x899a5ba9c13fafd9L}, - /* 205 */ {8, 0.13021715, 0x2b494f4efe6d2e21L, 0x7a80a705391e96ffL}, - /* 206 */ {8, 0.13009822, 0x2d0134ef21cbc100L, 0x6c0cfe23de23042aL}, - /* 207 */ {8, 0.12998007, 0x2ec84ef4da2ef581L, 0x5e377df359c944ddL}, - /* 208 */ {8, 0.12986271, 0x309f102100000000L, 0x50f8ac5fc8f53985L}, - /* 209 */ {8, 0.12974613, 0x3285ee02a1420281L, 0x44497266278e35b7L}, - /* 210 */ {8, 0.12963031, 0x347d6104fc324100L, 0x382316831f7ee175L}, - /* 211 */ {8, 0.12951524, 0x3685e47dade53d21L, 0x2c7f377833b8946eL}, - /* 212 */ {8, 0.12940092, 0x389ff6bb15610000L, 0x2157c761ab4163efL}, - /* 213 */ {8, 0.12928734, 0x3acc1912ebb57661L, 0x16a7071803cc49a9L}, - /* 214 */ {8, 0.12917448, 0x3d0acff111946100L, 0xc6781d80f8224fcL}, - /* 215 */ {8, 0.12906235, 0x3f5ca2e692eaf841L, 0x294092d370a900bL}, - /* 216 */ {8, 0.12895094, 0x41c21cb8e1000000L, 0xf24f62335024a295L}, - /* 217 */ {8, 0.12884022, 0x443bcb714399a5c1L, 0xe03b98f103fad6d2L}, - /* 218 */ {8, 0.12873021, 0x46ca406c81af2100L, 0xcee3d32cad2a9049L}, - /* 219 */ {8, 0.12862089, 0x496e106ac22aaae1L, 0xbe3f9df9277fdadaL}, - /* 220 */ {8, 0.12851224, 0x4c27d39fa5410000L, 0xae46f0d94c05e933L}, - /* 221 */ {8, 0.12840428, 0x4ef825c296e43ca1L, 0x9ef2280fb437a33dL}, - /* 222 */ {8, 0.12829698, 0x51dfa61f5ad88100L, 0x9039ff426d3f284bL}, - /* 223 */ {8, 0.12819034, 0x54def7a6d2f16901L, 0x82178c6d6b51f8f4L}, - /* 224 */ {8, 0.12808435, 0x57f6c10000000000L, 0x74843b1ee4c1e053L}, - /* 225 */ {8, 0.12797901, 0x5b27ac993df97701L, 0x6779c7f90dc42f48L}, - /* 226 */ {8, 0.12787431, 0x5e7268b9bbdf8100L, 0x5af23c74f9ad9fe9L}, - /* 227 */ {8, 0.12777024, 0x61d7a7932ff3d6a1L, 0x4ee7eae2acdc617eL}, - /* 228 */ {8, 0.12766680, 0x65581f53c8c10000L, 0x43556aa2ac262a0bL}, - /* 229 */ {8, 0.12756398, 0x68f48a385b8320e1L, 0x3835949593b8ddd1L}, - /* 230 */ {8, 0.12746176, 0x6cada69ed07c2100L, 0x2d837fbe78458762L}, - /* 231 */ {8, 0.12736016, 0x70843718cdbf27c1L, 0x233a7e150a54a555L}, - /* 232 */ {8, 0.12725915, 0x7479027ea1000000L, 0x19561984a50ff8feL}, - /* 233 */ {8, 0.12715874, 0x788cd40268f39641L, 0xfd211159fe3490fL}, - /* 234 */ {8, 0.12705891, 0x7cc07b437ecf6100L, 0x6aa563e655033e3L}, - /* 235 */ {8, 0.12695967, 0x8114cc6220762061L, 0xfbb614b3f2d3b14cL}, - /* 236 */ {8, 0.12686100, 0x858aa0135be10000L, 0xeac0f8837fb05773L}, - /* 237 */ {8, 0.12676290, 0x8a22d3b53c54c321L, 0xda6e4c10e8615ca5L}, - /* 238 */ {8, 0.12666537, 0x8ede496339f34100L, 0xcab755a8d01fa67fL}, - /* 239 */ {8, 0.12656839, 0x93bde80aec3a1481L, 0xbb95a9ae71aa3e0cL}, - /* 240 */ {8, 0.12647197, 0x98c29b8100000000L, 0xad0326c296b4f529L}, - /* 241 */ {8, 0.12637609, 0x9ded549671832381L, 0x9ef9f21eed31b7c1L}, - /* 242 */ {8, 0.12628075, 0xa33f092e0b1ac100L, 0x91747422be14b0b2L}, - /* 243 */ {8, 0.12618595, 0xa8b8b452291fe821L, 0x846d550e37b5063dL}, - /* 244 */ {8, 0.12609168, 0xae5b564ac3a10000L, 0x77df79e9a96c06f6L}, - /* 245 */ {8, 0.12599794, 0xb427f4b3be74c361L, 0x6bc6019636c7d0c2L}, - /* 246 */ {8, 0.12590471, 0xba1f9a938041e100L, 0x601c4205aebd9e47L}, - /* 247 */ {8, 0.12581200, 0xc0435871d1110f41L, 0x54ddc59756f05016L}, - /* 248 */ {8, 0.12571980, 0xc694446f01000000L, 0x4a0648979c838c18L}, - /* 249 */ {8, 0.12562811, 0xcd137a5b57ac3ec1L, 0x3f91b6e0bb3a053dL}, - /* 250 */ {8, 0.12553692, 0xd3c21bcecceda100L, 0x357c299a88ea76a5L}, - /* 251 */ {8, 0.12544622, 0xdaa150410b788de1L, 0x2bc1e517aecc56e3L}, - /* 252 */ {8, 0.12535601, 0xe1b24521be010000L, 0x225f56ceb3da9f5dL}, - /* 253 */ {8, 0.12526629, 0xe8f62df12777c1a1L, 0x1951136d53ad63acL}, - /* 254 */ {8, 0.12517705, 0xf06e445906fc0100L, 0x1093d504b3cd7d93L}, - /* 255 */ {8, 0.12508829, 0xf81bc845c81bf801L, 0x824794d1ec1814fL}, -}; -#endif diff --git a/gnu/lib/libgmp/mpn/tests/add_n.c b/gnu/lib/libgmp/mpn/tests/add_n.c deleted file mode 100644 index c27d347..0000000 --- a/gnu/lib/libgmp/mpn/tests/add_n.c +++ /dev/null @@ -1,211 +0,0 @@ -#include -#include "gmp.h" -#include "gmp-impl.h" - -#ifndef USG -#include -#include - -unsigned long -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#else -#include - -#ifndef CLOCKS_PER_SEC -#define CLOCKS_PER_SEC 1000000 -#endif - -#if CLOCKS_PER_SEC >= 10000 -#define CLOCK_TO_MILLISEC(cl) ((cl) / (CLOCKS_PER_SEC / 1000)) -#else -#define CLOCK_TO_MILLISEC(cl) ((cl) * 1000 / CLOCKS_PER_SEC) -#endif - -unsigned long -cputime () -{ - return CLOCK_TO_MILLISEC (clock ()); -} -#endif - -#define M * 1000000 - -#ifndef CLOCK -#if defined (__m88k__) -#define CLOCK 20 M -#elif defined (__i386__) -#define CLOCK (16.666667 M) -#elif defined (__m68k__) -#define CLOCK (20 M) -#elif defined (_IBMR2) -#define CLOCK (25 M) -#elif defined (__sparc__) -#define CLOCK (20 M) -#elif defined (__sun__) -#define CLOCK (20 M) -#elif defined (__mips) -#define CLOCK (40 M) -#elif defined (__hppa__) -#define CLOCK (50 M) -#elif defined (__alpha) -#define CLOCK (133 M) -#else -#error "Don't know CLOCK of your machine" -#endif -#endif - -#ifndef OPS -#define OPS 10000000 -#endif -#ifndef SIZE -#define SIZE 328 -#endif -#ifndef TIMES -#define TIMES OPS/SIZE -#else -#undef OPS -#define OPS (SIZE*TIMES) -#endif - - -mp_limb_t -#if __STDC__ -refmpn_add_n (mp_ptr res_ptr, - mp_srcptr s1_ptr, mp_srcptr s2_ptr, mp_size_t size) -#else -refmpn_add_n (res_ptr, s1_ptr, s2_ptr, size) - register mp_ptr res_ptr; - register mp_srcptr s1_ptr; - register mp_srcptr s2_ptr; - mp_size_t size; -#endif -{ - register mp_limb_t x, y, cy; - register mp_size_t j; - - /* The loop counter and index J goes from -SIZE to -1. This way - the loop becomes faster. */ - j = -size; - - /* Offset the base pointers to compensate for the negative indices. */ - s1_ptr -= j; - s2_ptr -= j; - res_ptr -= j; - - cy = 0; - do - { - y = s2_ptr[j]; - x = s1_ptr[j]; - y += cy; /* add previous carry to one addend */ - cy = (y < cy); /* get out carry from that addition */ - y = x + y; /* add other addend */ - cy = (y < x) + cy; /* get out carry from that add, combine */ - res_ptr[j] = y; - } - while (++j != 0); - - return cy; -} - -main (argc, argv) - int argc; - char **argv; -{ - mp_limb_t s1[SIZE]; - mp_limb_t s2[SIZE]; - mp_limb_t dx[SIZE+1]; - mp_limb_t dy[SIZE+1]; - int cyx, cyy; - int i; - long t0, t; - int test; - mp_size_t size; - - for (test = 0; ; test++) - { -#ifdef RANDOM - size = (random () % SIZE + 1); -#else - size = SIZE; -#endif - - mpn_random2 (s1, size); - mpn_random2 (s2, size); - - dx[size] = 0x12345678; - dy[size] = 0x12345678; - -#ifdef PRINT - mpn_print (s1, size); - mpn_print (s2, size); -#endif - t0 = cputime(); - for (i = 0; i < TIMES; i++) - cyx = refmpn_add_n (dx, s1, s2, size); - t = cputime() - t0; -#if TIMES != 1 - printf ("refmpn_add_n: %ldms (%.2f cycles/limb)\n", - t, - ((double) t * CLOCK) / (OPS * 1000.0)); -#endif -#ifdef PRINT - printf ("%d ", cyx); mpn_print (dx, size); -#endif - - t0 = cputime(); - for (i = 0; i < TIMES; i++) - cyx = mpn_add_n (dx, s1, s2, size); - t = cputime() - t0; -#if TIMES != 1 - printf ("mpn_add_n: %ldms (%.2f cycles/limb)\n", - t, - ((double) t * CLOCK) / (OPS * 1000.0)); -#endif -#ifdef PRINT - printf ("%d ", cyx); mpn_print (dx, size); -#endif - -#ifndef NOCHECK - /* Put garbage in the destination. */ - for (i = 0; i < size; i++) - { - dx[i] = 0x7654321; - dy[i] = 0x1234567; - } - - cyx = refmpn_add_n (dx, s1, s2, size); - cyy = mpn_add_n (dy, s1, s2, size); - if (cyx != cyy || mpn_cmp (dx, dy, size) != 0 - || dx[size] != 0x12345678 || dy[size] != 0x12345678) - { -#ifndef PRINT - printf ("%d ", cyx); mpn_print (dx, size); - printf ("%d ", cyy); mpn_print (dy, size); -#endif - abort(); - } -#endif - } -} - -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { - printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]); -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} diff --git a/gnu/lib/libgmp/mpn/tests/addmul_1.c b/gnu/lib/libgmp/mpn/tests/addmul_1.c deleted file mode 100644 index 23952a1..0000000 --- a/gnu/lib/libgmp/mpn/tests/addmul_1.c +++ /dev/null @@ -1,223 +0,0 @@ -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -#ifndef USG -#include -#include - -unsigned long -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#else -#include - -#ifndef CLOCKS_PER_SEC -#define CLOCKS_PER_SEC 1000000 -#endif - -#if CLOCKS_PER_SEC >= 10000 -#define CLOCK_TO_MILLISEC(cl) ((cl) / (CLOCKS_PER_SEC / 1000)) -#else -#define CLOCK_TO_MILLISEC(cl) ((cl) * 1000 / CLOCKS_PER_SEC) -#endif - -unsigned long -cputime () -{ - return CLOCK_TO_MILLISEC (clock ()); -} -#endif - -#define M * 1000000 - -#ifndef CLOCK -#if defined (__m88k__) -#define CLOCK 20 M -#elif defined (__i386__) -#define CLOCK (16.666667 M) -#elif defined (__m68k__) -#define CLOCK (20 M) -#elif defined (_IBMR2) -#define CLOCK (25 M) -#elif defined (__sparc__) -#define CLOCK (20 M) -#elif defined (__sun__) -#define CLOCK (20 M) -#elif defined (__mips) -#define CLOCK (40 M) -#elif defined (__hppa__) -#define CLOCK (50 M) -#elif defined (__alpha) -#define CLOCK (133 M) -#else -#error "Don't know CLOCK of your machine" -#endif -#endif - -#ifndef OPS -#define OPS 20000000 -#endif -#ifndef SIZE -#define SIZE 496 -#endif -#ifndef TIMES -#define TIMES OPS/SIZE -#else -#undef OPS -#define OPS (SIZE*TIMES) -#endif - -mp_limb_t -refmpn_addmul_1 (res_ptr, s1_ptr, s1_size, s2_limb) - register mp_ptr res_ptr; - register mp_srcptr s1_ptr; - mp_size_t s1_size; - register mp_limb_t s2_limb; -{ - register mp_limb_t cy_limb; - register mp_size_t j; - register mp_limb_t prod_high, prod_low; - register mp_limb_t x; - - /* The loop counter and index J goes from -SIZE to -1. This way - the loop becomes faster. */ - j = -s1_size; - - /* Offset the base pointers to compensate for the negative indices. */ - res_ptr -= j; - s1_ptr -= j; - - cy_limb = 0; - do - { - umul_ppmm (prod_high, prod_low, s1_ptr[j], s2_limb); - - prod_low += cy_limb; - cy_limb = (prod_low < cy_limb) + prod_high; - - x = res_ptr[j]; - prod_low = x + prod_low; - cy_limb += (prod_low < x); - res_ptr[j] = prod_low; - } - while (++j != 0); - - return cy_limb; -} - -main (argc, argv) - int argc; - char **argv; -{ - mp_limb_t s1[SIZE]; - mp_limb_t dx[SIZE+2]; - mp_limb_t dy[SIZE+2]; - mp_limb_t cyx, cyy; - int i; - long t0, t; - int test; - mp_limb_t xlimb; - mp_size_t size; - double cyc; - - for (test = 0; ; test++) - { -#ifdef RANDOM - size = (random () % SIZE + 1); -#else - size = SIZE; -#endif - - mpn_random2 (s1, size); - mpn_random2 (dy+1, size); - - if (random () % 0x100 == 0) - xlimb = 0; - else - mpn_random2 (&xlimb, 1); - - dy[size+1] = 0x12345678; - dy[0] = 0x87654321; - -#if defined (PRINT) || defined (XPRINT) - printf ("xlimb=%*lX\n", (int) (2 * sizeof(mp_limb_t)), xlimb); -#endif -#ifdef PRINT - mpn_print (dy+1, size); - mpn_print (s1, size); -#endif - - MPN_COPY (dx, dy, size+2); - t0 = cputime(); - for (i = 0; i < TIMES; i++) - cyx = refmpn_addmul_1 (dx+1, s1, size, xlimb); - t = cputime() - t0; -#if TIMES != 1 - cyc = ((double) t * CLOCK) / (OPS * 1000.0); - printf ("refmpn_addmul_1: %5ldms (%.2f cycles/limb) [%.2f Gb/s]\n", - t, - cyc, - CLOCK/cyc*BITS_PER_MP_LIMB*BITS_PER_MP_LIMB); -#endif - - MPN_COPY (dx, dy, size+2); - t0 = cputime(); - for (i = 0; i < TIMES; i++) - cyy = mpn_addmul_1 (dx+1, s1, size, xlimb); - t = cputime() - t0; -#if TIMES != 1 - cyc = ((double) t * CLOCK) / (OPS * 1000.0); - printf ("mpn_addmul_1: %5ldms (%.2f cycles/limb) [%.2f Gb/s]\n", - t, - cyc, - CLOCK/cyc*BITS_PER_MP_LIMB*BITS_PER_MP_LIMB); -#endif - - MPN_COPY (dx, dy, size+2); - cyx = refmpn_addmul_1 (dx+1, s1, size, xlimb); - cyy = mpn_addmul_1 (dy+1, s1, size, xlimb); - -#ifdef PRINT - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyx); - mpn_print (dx+1, size); - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyy); - mpn_print (dy+1, size); -#endif - -#ifndef NOCHECK - if (cyx != cyy || mpn_cmp (dx, dy, size+2) != 0 - || dx[size+1] != 0x12345678 || dx[0] != 0x87654321) - { -#ifndef PRINT - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyx); - mpn_print (dx+1, size); - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyy); - mpn_print (dy+1, size); -#endif - abort(); - } -#endif - } -} - -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { - printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]); -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} diff --git a/gnu/lib/libgmp/mpn/tests/divmod_1.c b/gnu/lib/libgmp/mpn/tests/divmod_1.c deleted file mode 100644 index f6b541e..0000000 --- a/gnu/lib/libgmp/mpn/tests/divmod_1.c +++ /dev/null @@ -1,120 +0,0 @@ -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -#ifndef USG -#include -#include - -unsigned long -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#else -#include - -#ifndef CLOCKS_PER_SEC -#define CLOCKS_PER_SEC 1000000 -#endif - -#if CLOCKS_PER_SEC >= 10000 -#define CLOCK_TO_MILLISEC(cl) ((cl) / (CLOCKS_PER_SEC / 1000)) -#else -#define CLOCK_TO_MILLISEC(cl) ((cl) * 1000 / CLOCKS_PER_SEC) -#endif - -unsigned long -cputime () -{ - return CLOCK_TO_MILLISEC (clock ()); -} -#endif - -#define M * 1000000 - -#ifndef CLOCK -#if defined (__m88k__) -#define CLOCK 20 M -#elif defined (__i386__) -#define CLOCK (16.666667 M) -#elif defined (__m68k__) -#define CLOCK (20 M) -#elif defined (_IBMR2) -#define CLOCK (25 M) -#elif defined (__sparc__) -#define CLOCK (20 M) -#elif defined (__sun__) -#define CLOCK (20 M) -#elif defined (__mips) -#define CLOCK (40 M) -#elif defined (__hppa__) -#define CLOCK (50 M) -#elif defined (__alpha) -#define CLOCK (133 M) -#else -#error "Don't know CLOCK of your machine" -#endif -#endif - -#ifndef OPS -#define OPS 20000000 -#endif -#ifndef SIZE -#define SIZE 1000 -#endif -#ifndef TIMES -#define TIMES OPS/SIZE -#else -#undef OPS -#define OPS (SIZE*TIMES) -#endif - -main () -{ - mp_limb_t nptr[SIZE]; - mp_limb_t qptr[SIZE]; - mp_limb_t pptr[SIZE]; - mp_limb_t dlimb, rlimb, plimb; - mp_size_t nsize, qsize, psize; - int test; - - for (test = 0; ; test++) - { -#ifdef RANDOM - nsize = random () % SIZE + 1; -#else - nsize = SIZE; -#endif - - mpn_random2 (nptr, nsize); - - mpn_random2 (&dlimb, 1); - if (dlimb == 0) - abort (); - - rlimb = mpn_divmod_1 (qptr, nptr, nsize, dlimb); - qsize = nsize - (qptr[nsize - 1] == 0); - if (qsize == 0) - { - plimb = rlimb; - psize = qsize; - } - else - { - plimb = mpn_mul_1 (pptr, qptr, qsize, dlimb); - psize = qsize; - plimb += mpn_add_1 (pptr, pptr, psize, rlimb); - } - if (plimb != 0) - pptr[psize++] = plimb; - - - if (nsize != psize || mpn_cmp (nptr, pptr, nsize) != 0) - abort (); - } -} diff --git a/gnu/lib/libgmp/mpn/tests/divrem.c b/gnu/lib/libgmp/mpn/tests/divrem.c deleted file mode 100644 index 6eafc99..0000000 --- a/gnu/lib/libgmp/mpn/tests/divrem.c +++ /dev/null @@ -1,129 +0,0 @@ -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -#ifndef USG -#include -#include - -unsigned long -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#else -#include - -#ifndef CLOCKS_PER_SEC -#define CLOCKS_PER_SEC 1000000 -#endif - -#if CLOCKS_PER_SEC >= 10000 -#define CLOCK_TO_MILLISEC(cl) ((cl) / (CLOCKS_PER_SEC / 1000)) -#else -#define CLOCK_TO_MILLISEC(cl) ((cl) * 1000 / CLOCKS_PER_SEC) -#endif - -unsigned long -cputime () -{ - return CLOCK_TO_MILLISEC (clock ()); -} -#endif - -#define M * 1000000 - -#ifndef CLOCK -#if defined (__m88k__) -#define CLOCK 20 M -#elif defined (__i386__) -#define CLOCK (16.666667 M) -#elif defined (__m68k__) -#define CLOCK (20 M) -#elif defined (_IBMR2) -#define CLOCK (25 M) -#elif defined (__sparc__) -#define CLOCK (20 M) -#elif defined (__sun__) -#define CLOCK (20 M) -#elif defined (__mips) -#define CLOCK (40 M) -#elif defined (__hppa__) -#define CLOCK (50 M) -#elif defined (__alpha) -#define CLOCK (133 M) -#else -#error "Don't know CLOCK of your machine" -#endif -#endif - -#ifndef OPS -#define OPS 20000000 -#endif -#ifndef SIZE -#define SIZE 100 -#endif -#ifndef TIMES -#define TIMES OPS/SIZE -#else -#undef OPS -#define OPS (SIZE*TIMES) -#endif - -main () -{ - mp_limb_t nptr[2 * SIZE]; - mp_limb_t dptr[SIZE]; - mp_limb_t qptr[2 * SIZE]; - mp_limb_t pptr[2 * SIZE]; - mp_limb_t rptr[2 * SIZE]; - mp_size_t nsize, dsize, qsize, rsize, psize; - int test; - mp_limb_t qlimb; - - for (test = 0; ; test++) - { -#ifdef RANDOM - nsize = random () % (2 * SIZE) + 1; - dsize = random () % nsize + 1; -#else - nsize = 2 * SIZE; - dsize = SIZE; -#endif - - mpn_random2 (nptr, nsize); - mpn_random2 (dptr, dsize); - dptr[dsize - 1] |= (mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1); - - MPN_COPY (rptr, nptr, nsize); - qlimb = mpn_divrem (qptr, (mp_size_t) 0, rptr, nsize, dptr, dsize); - rsize = dsize; - qsize = nsize - dsize; - qptr[qsize] = qlimb; - qsize += qlimb; - if (qsize == 0 || qsize > 2 * SIZE) - { - continue; /* bogus */ - } - else - { - mp_limb_t cy; - if (qsize > dsize) - mpn_mul (pptr, qptr, qsize, dptr, dsize); - else - mpn_mul (pptr, dptr, dsize, qptr, qsize); - psize = qsize + dsize; - psize -= pptr[psize - 1] == 0; - cy = mpn_add (pptr, pptr, psize, rptr, rsize); - pptr[psize] = cy; - psize += cy; - } - - if (nsize != psize || mpn_cmp (nptr, pptr, nsize) != 0) - abort (); - } -} diff --git a/gnu/lib/libgmp/mpn/tests/lshift.c b/gnu/lib/libgmp/mpn/tests/lshift.c deleted file mode 100644 index f50c5dc..0000000 --- a/gnu/lib/libgmp/mpn/tests/lshift.c +++ /dev/null @@ -1,226 +0,0 @@ -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -#ifndef USG -#include -#include - -unsigned long -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#else -#include - -#ifndef CLOCKS_PER_SEC -#define CLOCKS_PER_SEC 1000000 -#endif - -#if CLOCKS_PER_SEC >= 10000 -#define CLOCK_TO_MILLISEC(cl) ((cl) / (CLOCKS_PER_SEC / 1000)) -#else -#define CLOCK_TO_MILLISEC(cl) ((cl) * 1000 / CLOCKS_PER_SEC) -#endif - -unsigned long -cputime () -{ - return CLOCK_TO_MILLISEC (clock ()); -} -#endif - -#define M * 1000000 - -#ifndef CLOCK -#if defined (__m88k__) -#define CLOCK 20 M -#elif defined (__i386__) -#define CLOCK (16.666667 M) -#elif defined (__m68k__) -#define CLOCK (20 M) -#elif defined (_IBMR2) -#define CLOCK (25 M) -#elif defined (__sparc__) -#define CLOCK (20 M) -#elif defined (__sun__) -#define CLOCK (20 M) -#elif defined (__mips) -#define CLOCK (40 M) -#elif defined (__hppa__) -#define CLOCK (50 M) -#elif defined (__alpha) -#define CLOCK (133 M) -#else -#error "Don't know CLOCK of your machine" -#endif -#endif - -#ifndef OPS -#define OPS 10000000 -#endif -#ifndef SIZE -#define SIZE 496 -#endif -#ifndef TIMES -#define TIMES OPS/SIZE -#else -#undef OPS -#define OPS (SIZE*TIMES) -#endif - -mp_limb_t -refmpn_lshift (wp, up, usize, cnt) - register mp_ptr wp; - register mp_srcptr up; - mp_size_t usize; - register unsigned int cnt; -{ - register mp_limb_t high_limb, low_limb; - register unsigned sh_1, sh_2; - register mp_size_t i; - mp_limb_t retval; - -#ifdef DEBUG - if (usize == 0 || cnt == 0) - abort (); -#endif - - sh_1 = cnt; -#if 0 - if (sh_1 == 0) - { - if (wp != up) - { - /* Copy from high end to low end, to allow specified input/output - overlapping. */ - for (i = usize - 1; i >= 0; i--) - wp[i] = up[i]; - } - return 0; - } -#endif - - wp += 1; - sh_2 = BITS_PER_MP_LIMB - sh_1; - i = usize - 1; - low_limb = up[i]; - retval = low_limb >> sh_2; - high_limb = low_limb; - while (--i >= 0) - { - low_limb = up[i]; - wp[i] = (high_limb << sh_1) | (low_limb >> sh_2); - high_limb = low_limb; - } - wp[i] = high_limb << sh_1; - - return retval; -} - -#ifndef CNT -#define CNT 4 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mp_limb_t s1[SIZE]; - mp_limb_t dx[SIZE+2]; - mp_limb_t dy[SIZE+2]; - mp_limb_t cyx, cyy; - int i; - long t0, t; - int test; - int cnt = CNT; - mp_size_t size; - - for (test = 0; ; test++) - { -#ifdef RANDOM - size = (random () % SIZE + 1); -#else - size = SIZE; -#endif - mpn_random2 (s1, size); - - dx[size+1] = 0x12345678; - dy[size+1] = 0x12345678; - dx[0] = 0x87654321; - dy[0] = 0x87654321; - -#ifdef PRINT - mpn_print (s1, size); -#endif - t0 = cputime(); - for (i = 0; i < TIMES; i++) - cyx = refmpn_lshift (dx+1, s1, size, cnt); - t = cputime() - t0; -#if TIMES != 1 - printf ("refmpn_lshift: %5ldms (%.2f cycles/limb)\n", - t, - ((double) t * CLOCK) / (OPS * 1000.0)); -#endif -#ifdef PRINT - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyx); mpn_print (dx+1, size); -#endif - - t0 = cputime(); - for (i = 0; i < TIMES; i++) - cyy = mpn_lshift (dx+1, s1, size, cnt); - t = cputime() - t0; -#if TIMES != 1 - printf ("mpn_lshift: %5ldms (%.2f cycles/limb)\n", - t, - ((double) t * CLOCK) / (OPS * 1000.0)); -#endif -#ifdef PRINT - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyy); mpn_print (dx+1, size); -#endif - -#ifndef NOCHECK - /* Put garbage in the destination. */ - for (i = 1; i <= size; i++) - { - dx[i] = 0x7654321; - dy[i] = 0x1234567; - } - - cyx = refmpn_lshift (dx+1, s1, size, cnt); - cyy = mpn_lshift (dy+1, s1, size, cnt); - - if (cyx != cyy || mpn_cmp (dx, dy, size+2) != 0 - || dx[size+1] != 0x12345678 || dx[0] != 0x87654321) - { -#ifndef PRINT - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyx); - mpn_print (dx+1, size); - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyy); - mpn_print (dy+1, size); -#endif - abort(); - } -#endif - } -} - -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { - printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]); -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} diff --git a/gnu/lib/libgmp/mpn/tests/mul_1.c b/gnu/lib/libgmp/mpn/tests/mul_1.c deleted file mode 100644 index 2b522fa..0000000 --- a/gnu/lib/libgmp/mpn/tests/mul_1.c +++ /dev/null @@ -1,212 +0,0 @@ -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -#ifndef USG -#include -#include - -unsigned long -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#else -#include - -#ifndef CLOCKS_PER_SEC -#define CLOCKS_PER_SEC 1000000 -#endif - -#if CLOCKS_PER_SEC >= 10000 -#define CLOCK_TO_MILLISEC(cl) ((cl) / (CLOCKS_PER_SEC / 1000)) -#else -#define CLOCK_TO_MILLISEC(cl) ((cl) * 1000 / CLOCKS_PER_SEC) -#endif - -unsigned long -cputime () -{ - return CLOCK_TO_MILLISEC (clock ()); -} -#endif - -#define M * 1000000 - -#ifndef CLOCK -#if defined (__m88k__) -#define CLOCK 20 M -#elif defined (__i386__) -#define CLOCK (16.666667 M) -#elif defined (__m68k__) -#define CLOCK (20 M) -#elif defined (_IBMR2) -#define CLOCK (25 M) -#elif defined (__sparc__) -#define CLOCK (20 M) -#elif defined (__sun__) -#define CLOCK (20 M) -#elif defined (__mips) -#define CLOCK (40 M) -#elif defined (__hppa__) -#define CLOCK (50 M) -#elif defined (__alpha) -#define CLOCK (133 M) -#else -#error "Don't know CLOCK of your machine" -#endif -#endif - -#ifndef OPS -#define OPS 20000000 -#endif -#ifndef SIZE -#define SIZE 496 -#endif -#ifndef TIMES -#define TIMES OPS/SIZE -#else -#undef OPS -#define OPS (SIZE*TIMES) -#endif - -mp_limb_t -refmpn_mul_1 (res_ptr, s1_ptr, s1_size, s2_limb) - register mp_ptr res_ptr; - register mp_srcptr s1_ptr; - mp_size_t s1_size; - register mp_limb_t s2_limb; -{ - register mp_limb_t cy_limb; - register mp_size_t j; - register mp_limb_t prod_high, prod_low; - - /* The loop counter and index J goes from -S1_SIZE to -1. This way - the loop becomes faster. */ - j = -s1_size; - - /* Offset the base pointers to compensate for the negative indices. */ - s1_ptr -= j; - res_ptr -= j; - - cy_limb = 0; - do - { - umul_ppmm (prod_high, prod_low, s1_ptr[j], s2_limb); - - prod_low += cy_limb; - cy_limb = (prod_low < cy_limb) + prod_high; - - res_ptr[j] = prod_low; - } - while (++j != 0); - - return cy_limb; -} - -main (argc, argv) - int argc; - char **argv; -{ - mp_limb_t s1[SIZE]; - mp_limb_t dx[SIZE+2]; - mp_limb_t dy[SIZE+2]; - mp_limb_t cyx, cyy; - int i; - long t0, t; - int test; - mp_limb_t xlimb; - mp_size_t size; - - for (test = 0; ; test++) - { -#ifdef RANDOM - size = (random () % SIZE + 1); -#else - size = SIZE; -#endif - - mpn_random2 (s1, size); - mpn_random2 (dy+1, size); - - if (random () % 0x100 == 0) - xlimb = 0; - else - mpn_random2 (&xlimb, 1); - - dy[size+1] = 0x12345678; - dy[0] = 0x87654321; - -#if defined (PRINT) || defined (XPRINT) - printf ("xlimb=%*lX\n", (int) (2 * sizeof(mp_limb_t)), xlimb); -#endif -#ifdef PRINT - mpn_print (s1, size); -#endif - - MPN_COPY (dx, dy, size+2); - t0 = cputime(); - for (i = 0; i < TIMES; i++) - cyx = refmpn_mul_1 (dx+1, s1, size, xlimb); - t = cputime() - t0; -#if TIMES != 1 - printf ("refmpn_mul_1: %5ldms (%.2f cycles/limb)\n", - t, - ((double) t * CLOCK) / (OPS * 1000.0)); -#endif - - MPN_COPY (dx, dy, size+2); - t0 = cputime(); - for (i = 0; i < TIMES; i++) - cyy = mpn_mul_1 (dx+1, s1, size, xlimb); - t = cputime() - t0; -#if TIMES != 1 - printf ("mpn_mul_1: %5ldms (%.2f cycles/limb)\n", - t, - ((double) t * CLOCK) / (OPS * 1000.0)); -#endif - - cyx = refmpn_mul_1 (dx+1, s1, size, xlimb); - cyy = mpn_mul_1 (dy+1, s1, size, xlimb); - -#ifdef PRINT - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyx); - mpn_print (dx+1, size); - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyy); - mpn_print (dy+1, size); -#endif - -#ifndef NOCHECK - if (cyx != cyy || mpn_cmp (dx, dy, size+2) != 0 - || dx[size+1] != 0x12345678 || dx[0] != 0x87654321) - { -#ifndef PRINT - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyx); - mpn_print (dx+1, size); - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyy); - mpn_print (dy+1, size); -#endif - abort(); - } -#endif - } -} - -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { - printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]); -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} diff --git a/gnu/lib/libgmp/mpn/tests/rshift.c b/gnu/lib/libgmp/mpn/tests/rshift.c deleted file mode 100644 index 2482bf3..0000000 --- a/gnu/lib/libgmp/mpn/tests/rshift.c +++ /dev/null @@ -1,227 +0,0 @@ -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -#ifndef USG -#include -#include - -unsigned long -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#else -#include - -#ifndef CLOCKS_PER_SEC -#define CLOCKS_PER_SEC 1000000 -#endif - -#if CLOCKS_PER_SEC >= 10000 -#define CLOCK_TO_MILLISEC(cl) ((cl) / (CLOCKS_PER_SEC / 1000)) -#else -#define CLOCK_TO_MILLISEC(cl) ((cl) * 1000 / CLOCKS_PER_SEC) -#endif - -unsigned long -cputime () -{ - return CLOCK_TO_MILLISEC (clock ()); -} -#endif - -#define M * 1000000 - -#ifndef CLOCK -#if defined (__m88k__) -#define CLOCK 20 M -#elif defined (__i386__) -#define CLOCK (16.666667 M) -#elif defined (__m68k__) -#define CLOCK (20 M) -#elif defined (_IBMR2) -#define CLOCK (25 M) -#elif defined (__sparc__) -#define CLOCK (20 M) -#elif defined (__sun__) -#define CLOCK (20 M) -#elif defined (__mips) -#define CLOCK (40 M) -#elif defined (__hppa__) -#define CLOCK (50 M) -#elif defined (__alpha) -#define CLOCK (133 M) -#else -#error "Don't know CLOCK of your machine" -#endif -#endif - -#ifndef OPS -#define OPS 10000000 -#endif -#ifndef SIZE -#define SIZE 496 -#endif -#ifndef TIMES -#define TIMES OPS/SIZE -#else -#undef OPS -#define OPS (SIZE*TIMES) -#endif - -mp_limb_t -refmpn_rshift (wp, up, usize, cnt) - register mp_ptr wp; - register mp_srcptr up; - mp_size_t usize; - register unsigned int cnt; -{ - register mp_limb_t high_limb, low_limb; - register unsigned sh_1, sh_2; - register mp_size_t i; - mp_limb_t retval; - -#ifdef DEBUG - if (usize == 0 || cnt == 0) - abort (); -#endif - - sh_1 = cnt; -#if 0 - if (sh_1 == 0) - { - if (wp != up) - { - /* Copy from low end to high end, to allow specified input/output - overlapping. */ - for (i = 0; i < usize; i++) - wp[i] = up[i]; - } - return 0; - } -#endif - - wp -= 1; - sh_2 = BITS_PER_MP_LIMB - sh_1; - high_limb = up[0]; - retval = high_limb << sh_2; - low_limb = high_limb; - - for (i = 1; i < usize; i++) - { - high_limb = up[i]; - wp[i] = (low_limb >> sh_1) | (high_limb << sh_2); - low_limb = high_limb; - } - low_limb >>= sh_1; - wp[i] = low_limb; - - return retval; -} - -#ifndef CNT -#define CNT 4 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mp_limb_t s1[SIZE]; - mp_limb_t dx[SIZE+2]; - mp_limb_t dy[SIZE+2]; - mp_limb_t cyx, cyy; - int i; - long t0, t; - int test; - int cnt = CNT; - mp_size_t size; - - for (test = 0; ; test++) - { -#ifdef RANDOM - size = (random () % SIZE + 1); -#else - size = SIZE; -#endif - mpn_random2 (s1, size); - - dx[size+1] = 0x12345678; - dy[size+1] = 0x12345678; - dx[0] = 0x87654321; - dy[0] = 0x87654321; - -#ifdef PRINT - mpn_print (s1, size); -#endif - t0 = cputime(); - for (i = 0; i < TIMES; i++) - cyx = refmpn_rshift (dx+1, s1, size, cnt); - t = cputime() - t0; -#if TIMES != 1 - printf ("refmpn_rshift: %5ldms (%.2f cycles/limb)\n", - t, - ((double) t * CLOCK) / (OPS * 1000.0)); -#endif -#ifdef PRINT - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyx); mpn_print (dx+1, size); -#endif - - t0 = cputime(); - for (i = 0; i < TIMES; i++) - cyy = mpn_rshift (dx+1, s1, size, cnt); - t = cputime() - t0; -#if TIMES != 1 - printf ("mpn_rshift: %5ldms (%.2f cycles/limb)\n", - t, - ((double) t * CLOCK) / (OPS * 1000.0)); -#endif -#ifdef PRINT - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyy); mpn_print (dx+1, size); -#endif - -#ifndef NOCHECK - /* Put garbage in the destination. */ - for (i = 1; i <= size; i++) - { - dx[i] = 0x7654321; - dy[i] = 0x1234567; - } - - cyx = refmpn_rshift (dx+1, s1, size, cnt); - cyy = mpn_rshift (dy+1, s1, size, cnt); - - if (cyx != cyy || mpn_cmp (dx, dy, size+2) != 0 - || dx[size+1] != 0x12345678 || dx[0] != 0x87654321) - { -#ifndef PRINT - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyx); - mpn_print (dx+1, size); - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyy); - mpn_print (dy+1, size); -#endif - abort(); - } -#endif - } -} - -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { - printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]); -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} diff --git a/gnu/lib/libgmp/mpn/tests/sub_n.c b/gnu/lib/libgmp/mpn/tests/sub_n.c deleted file mode 100644 index 2b9031b..0000000 --- a/gnu/lib/libgmp/mpn/tests/sub_n.c +++ /dev/null @@ -1,211 +0,0 @@ -#include -#include "gmp.h" -#include "gmp-impl.h" - -#ifndef USG -#include -#include - -unsigned long -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#else -#include - -#ifndef CLOCKS_PER_SEC -#define CLOCKS_PER_SEC 1000000 -#endif - -#if CLOCKS_PER_SEC >= 10000 -#define CLOCK_TO_MILLISEC(cl) ((cl) / (CLOCKS_PER_SEC / 1000)) -#else -#define CLOCK_TO_MILLISEC(cl) ((cl) * 1000 / CLOCKS_PER_SEC) -#endif - -unsigned long -cputime () -{ - return CLOCK_TO_MILLISEC (clock ()); -} -#endif - -#define M * 1000000 - -#ifndef CLOCK -#if defined (__m88k__) -#define CLOCK 20 M -#elif defined (__i386__) -#define CLOCK (16.666667 M) -#elif defined (__m68k__) -#define CLOCK (20 M) -#elif defined (_IBMR2) -#define CLOCK (25 M) -#elif defined (__sparc__) -#define CLOCK (20 M) -#elif defined (__sun__) -#define CLOCK (20 M) -#elif defined (__mips) -#define CLOCK (40 M) -#elif defined (__hppa__) -#define CLOCK (50 M) -#elif defined (__alpha) -#define CLOCK (133 M) -#else -#error "Don't know CLOCK of your machine" -#endif -#endif - -#ifndef OPS -#define OPS 10000000 -#endif -#ifndef SIZE -#define SIZE 328 -#endif -#ifndef TIMES -#define TIMES OPS/SIZE -#else -#undef OPS -#define OPS (SIZE*TIMES) -#endif - - -mp_limb_t -#if __STDC__ -refmpn_sub_n (mp_ptr res_ptr, - mp_srcptr s1_ptr, mp_srcptr s2_ptr, mp_size_t size) -#else -refmpn_sub_n (res_ptr, s1_ptr, s2_ptr, size) - register mp_ptr res_ptr; - register mp_srcptr s1_ptr; - register mp_srcptr s2_ptr; - mp_size_t size; -#endif -{ - register mp_limb_t x, y, cy; - register mp_size_t j; - - /* The loop counter and index J goes from -SIZE to -1. This way - the loop becomes faster. */ - j = -size; - - /* Offset the base pointers to compensate for the negative indices. */ - s1_ptr -= j; - s2_ptr -= j; - res_ptr -= j; - - cy = 0; - do - { - y = s2_ptr[j]; - x = s1_ptr[j]; - y += cy; /* add previous carry to subtrahend */ - cy = (y < cy); /* get out carry from that addition */ - y = x - y; /* main subtract */ - cy = (y > x) + cy; /* get out carry from the subtract, combine */ - res_ptr[j] = y; - } - while (++j != 0); - - return cy; -} - -main (argc, argv) - int argc; - char **argv; -{ - mp_limb_t s1[SIZE]; - mp_limb_t s2[SIZE]; - mp_limb_t dx[SIZE+1]; - mp_limb_t dy[SIZE+1]; - int cyx, cyy; - int i; - long t0, t; - int test; - mp_size_t size; - - for (test = 0; ; test++) - { -#ifdef RANDOM - size = (random () % SIZE + 1); -#else - size = SIZE; -#endif - - mpn_random2 (s1, size); - mpn_random2 (s2, size); - - dx[size] = 0x12345678; - dy[size] = 0x12345678; - -#ifdef PRINT - mpn_print (s1, size); - mpn_print (s2, size); -#endif - t0 = cputime(); - for (i = 0; i < TIMES; i++) - cyx = refmpn_sub_n (dx, s1, s2, size); - t = cputime() - t0; -#if TIMES != 1 - printf ("refmpn_sub_n: %ldms (%.2f cycles/limb)\n", - t, - ((double) t * CLOCK) / (OPS * 1000.0)); -#endif -#ifdef PRINT - printf ("%d ", cyx); mpn_print (dx, size); -#endif - - t0 = cputime(); - for (i = 0; i < TIMES; i++) - cyx = mpn_sub_n (dx, s1, s2, size); - t = cputime() - t0; -#if TIMES != 1 - printf ("mpn_sub_n: %ldms (%.2f cycles/limb)\n", - t, - ((double) t * CLOCK) / (OPS * 1000.0)); -#endif -#ifdef PRINT - printf ("%d ", cyx); mpn_print (dx, size); -#endif - -#ifndef NOCHECK - /* Put garbage in the destination. */ - for (i = 0; i < size; i++) - { - dx[i] = 0x7654321; - dy[i] = 0x1234567; - } - - cyx = refmpn_sub_n (dx, s1, s2, size); - cyy = mpn_sub_n (dy, s1, s2, size); - if (cyx != cyy || mpn_cmp (dx, dy, size) != 0 - || dx[size] != 0x12345678 || dy[size] != 0x12345678) - { -#ifndef PRINT - printf ("%d ", cyx); mpn_print (dx, size); - printf ("%d ", cyy); mpn_print (dy, size); -#endif - abort(); - } -#endif - } -} - -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { - printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]); -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} diff --git a/gnu/lib/libgmp/mpn/tests/submul_1.c b/gnu/lib/libgmp/mpn/tests/submul_1.c deleted file mode 100644 index 0e464e6..0000000 --- a/gnu/lib/libgmp/mpn/tests/submul_1.c +++ /dev/null @@ -1,218 +0,0 @@ -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -#ifndef USG -#include -#include - -unsigned long -cputime () -{ - struct rusage rus; - - getrusage (0, &rus); - return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; -} -#else -#include - -#ifndef CLOCKS_PER_SEC -#define CLOCKS_PER_SEC 1000000 -#endif - -#if CLOCKS_PER_SEC >= 10000 -#define CLOCK_TO_MILLISEC(cl) ((cl) / (CLOCKS_PER_SEC / 1000)) -#else -#define CLOCK_TO_MILLISEC(cl) ((cl) * 1000 / CLOCKS_PER_SEC) -#endif - -unsigned long -cputime () -{ - return CLOCK_TO_MILLISEC (clock ()); -} -#endif - -#define M * 1000000 - -#ifndef CLOCK -#if defined (__m88k__) -#define CLOCK 20 M -#elif defined (__i386__) -#define CLOCK (16.666667 M) -#elif defined (__m68k__) -#define CLOCK (20 M) -#elif defined (_IBMR2) -#define CLOCK (25 M) -#elif defined (__sparc__) -#define CLOCK (20 M) -#elif defined (__sun__) -#define CLOCK (20 M) -#elif defined (__mips) -#define CLOCK (40 M) -#elif defined (__hppa__) -#define CLOCK (50 M) -#elif defined (__alpha) -#define CLOCK (133 M) -#else -#error "Don't know CLOCK of your machine" -#endif -#endif - -#ifndef OPS -#define OPS 20000000 -#endif -#ifndef SIZE -#define SIZE 496 -#endif -#ifndef TIMES -#define TIMES OPS/SIZE -#else -#undef OPS -#define OPS (SIZE*TIMES) -#endif - -mp_limb_t -refmpn_submul_1 (res_ptr, s1_ptr, s1_size, s2_limb) - register mp_ptr res_ptr; - register mp_srcptr s1_ptr; - mp_size_t s1_size; - register mp_limb_t s2_limb; -{ - register mp_limb_t cy_limb; - register mp_size_t j; - register mp_limb_t prod_high, prod_low; - register mp_limb_t x; - - /* The loop counter and index J goes from -SIZE to -1. This way - the loop becomes faster. */ - j = -s1_size; - - /* Offset the base pointers to compensate for the negative indices. */ - res_ptr -= j; - s1_ptr -= j; - - cy_limb = 0; - do - { - umul_ppmm (prod_high, prod_low, s1_ptr[j], s2_limb); - - prod_low += cy_limb; - cy_limb = (prod_low < cy_limb) + prod_high; - - x = res_ptr[j]; - prod_low = x - prod_low; - cy_limb += (prod_low > x); - res_ptr[j] = prod_low; - } - while (++j != 0); - - return cy_limb; -} - -main (argc, argv) - int argc; - char **argv; -{ - mp_limb_t s1[SIZE]; - mp_limb_t dx[SIZE+2]; - mp_limb_t dy[SIZE+2]; - mp_limb_t cyx, cyy; - int i; - long t0, t; - int test; - mp_limb_t xlimb; - mp_size_t size; - - for (test = 0; ; test++) - { -#ifdef RANDOM - size = (random () % SIZE + 1); -#else - size = SIZE; -#endif - - mpn_random2 (s1, size); - mpn_random2 (dy+1, size); - - if (random () % 0x100 == 0) - xlimb = 0; - else - mpn_random2 (&xlimb, 1); - - dy[size+1] = 0x12345678; - dy[0] = 0x87654321; - -#if defined (PRINT) || defined (XPRINT) - printf ("xlimb=%*lX\n", (int) (2 * sizeof(mp_limb_t)), xlimb); -#endif -#ifdef PRINT - mpn_print (dy+1, size); - mpn_print (s1, size); -#endif - - MPN_COPY (dx, dy, size+2); - t0 = cputime(); - for (i = 0; i < TIMES; i++) - cyx = refmpn_submul_1 (dx+1, s1, size, xlimb); - t = cputime() - t0; -#if TIMES != 1 - printf ("refmpn_submul_1: %5ldms (%.2f cycles/limb)\n", - t, - ((double) t * CLOCK) / (OPS * 1000.0)); -#endif - - MPN_COPY (dx, dy, size+2); - t0 = cputime(); - for (i = 0; i < TIMES; i++) - cyy = mpn_submul_1 (dx+1, s1, size, xlimb); - t = cputime() - t0; -#if TIMES != 1 - printf ("mpn_submul_1: %5ldms (%.2f cycles/limb)\n", - t, - ((double) t * CLOCK) / (OPS * 1000.0)); -#endif - - MPN_COPY (dx, dy, size+2); - cyx = refmpn_submul_1 (dx+1, s1, size, xlimb); - cyy = mpn_submul_1 (dy+1, s1, size, xlimb); - -#ifdef PRINT - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyx); - mpn_print (dx+1, size); - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyy); - mpn_print (dy+1, size); -#endif - -#ifndef NOCHECK - if (cyx != cyy || mpn_cmp (dx, dy, size+2) != 0 - || dx[size+1] != 0x12345678 || dx[0] != 0x87654321) - { -#ifndef PRINT - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyx); - mpn_print (dx+1, size); - printf ("%*lX ", (int) (2 * sizeof(mp_limb_t)), cyy); - mpn_print (dy+1, size); -#endif - abort(); - } -#endif - } -} - -mpn_print (mp_ptr p, mp_size_t size) -{ - mp_size_t i; - - for (i = size - 1; i >= 0; i--) - { - printf ("%0*lX", (int) (2 * sizeof(mp_limb_t)), p[i]); -#ifdef SPACE - if (i != 0) - printf (" "); -#endif - } - puts (""); -} diff --git a/gnu/lib/libgmp/mpn/tests/tst-addsub.c b/gnu/lib/libgmp/mpn/tests/tst-addsub.c deleted file mode 100644 index e02b9d5..0000000 --- a/gnu/lib/libgmp/mpn/tests/tst-addsub.c +++ /dev/null @@ -1,164 +0,0 @@ -#include -#include -#include "gmp.h" -#include "gmp-impl.h" - -#define ADD 1 -#define SUB 2 - -#ifndef METHOD -#define METHOD ADD -#endif - -#if METHOD == ADD -#define REFCALL refmpn_add_n -#define TESTCALL mpn_add_n -#endif - -#if METHOD == SUB -#define REFCALL refmpn_sub_n -#define TESTCALL mpn_sub_n -#endif - -mp_limb_t refmpn_add_n (); -mp_limb_t refmpn_sub_n (); - -#define SIZE 100 - -main (argc, argv) - int argc; - char **argv; -{ - mp_size_t alloc_size, max_size, size, i, cumul_size; - mp_ptr s1, s2, dx, dy; - int s1_align, s2_align, d_align; - long pass, n_passes; - mp_limb_t cx, cy; - - max_size = SIZE; - n_passes = 1000000; - - argc--; argv++; - if (argc) - { - max_size = atol (*argv); - argc--; argv++; - } - - alloc_size = max_size + 32; - s1 = malloc (alloc_size * BYTES_PER_MP_LIMB); - s2 = malloc (alloc_size * BYTES_PER_MP_LIMB); - dx = malloc (alloc_size * BYTES_PER_MP_LIMB); - dy = malloc (alloc_size * BYTES_PER_MP_LIMB); - - cumul_size = 0; - for (pass = 0; pass < n_passes; pass++) - { - cumul_size += size; - if (cumul_size >= 1000000) - { - cumul_size -= 1000000; - printf ("%d ", pass); fflush (stdout); - } - s1_align = random () % 32; - s2_align = random () % 32; - d_align = random () % 32; - - size = random () % max_size + 1; - - mpn_random2 (s1 + s1_align, size); - mpn_random2 (s2 + s2_align, size); - - for (i = 0; i < alloc_size; i++) - dx[i] = dy[i] = i + 0x9876500; - - cx = TESTCALL (dx + d_align, s1 + s1_align, s2 + s2_align, size); - cy = REFCALL (dy + d_align, s1 + s1_align, s2 + s2_align, size); - - if (cx != cy || mpn_cmp (dx, dy, alloc_size) != 0) - abort (); - } - - printf ("%d passes OK\n", n_passes); - exit (0); -} - -mp_limb_t -#if __STDC__ -refmpn_add_n (mp_ptr res_ptr, - mp_srcptr s1_ptr, mp_srcptr s2_ptr, mp_size_t size) -#else -refmpn_add_n (res_ptr, s1_ptr, s2_ptr, size) - register mp_ptr res_ptr; - register mp_srcptr s1_ptr; - register mp_srcptr s2_ptr; - mp_size_t size; -#endif -{ - register mp_limb_t x, y, cy; - register mp_size_t j; - - /* The loop counter and index J goes from -SIZE to -1. This way - the loop becomes faster. */ - j = -size; - - /* Offset the base pointers to compensate for the negative indices. */ - s1_ptr -= j; - s2_ptr -= j; - res_ptr -= j; - - cy = 0; - do - { - y = s2_ptr[j]; - x = s1_ptr[j]; - y += cy; /* add previous carry to one addend */ - cy = (y < cy); /* get out carry from that addition */ - y = x + y; /* add other addend */ - cy = (y < x) + cy; /* get out carry from that add, combine */ - res_ptr[j] = y; - } - while (++j != 0); - - return cy; -} - -mp_limb_t -#if __STDC__ -refmpn_sub_n (mp_ptr res_ptr, - mp_srcptr s1_ptr, mp_srcptr s2_ptr, mp_size_t size) -#else -refmpn_sub_n (res_ptr, s1_ptr, s2_ptr, size) - register mp_ptr res_ptr; - register mp_srcptr s1_ptr; - register mp_srcptr s2_ptr; - mp_size_t size; -#endif -{ - register mp_limb_t x, y, cy; - register mp_size_t j; - - /* The loop counter and index J goes from -SIZE to -1. This way - the loop becomes faster. */ - j = -size; - - /* Offset the base pointers to compensate for the negative indices. */ - s1_ptr -= j; - s2_ptr -= j; - res_ptr -= j; - - cy = 0; - do - { - y = s2_ptr[j]; - x = s1_ptr[j]; - y += cy; /* add previous carry to subtrahend */ - cy = (y < cy); /* get out carry from that addition */ - y = x - y; /* main subtract */ - cy = (y > x) + cy; /* get out carry from the subtract, combine */ - res_ptr[j] = y; - } - while (++j != 0); - - return cy; -} diff --git a/gnu/lib/libgmp/mpn/x86/add_n.S b/gnu/lib/libgmp/mpn/x86/add_n.S deleted file mode 100644 index 5bbbd0d..0000000 --- a/gnu/lib/libgmp/mpn/x86/add_n.S +++ /dev/null @@ -1,106 +0,0 @@ -/* i80386 __mpn_add_n -- Add two limb vectors of the same length > 0 and store -sum in a third limb vector. - -Copyright (C) 1992, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - s2_ptr (sp + 12) - size (sp + 16) -*/ - -#include "sysdep.h" -#include "asm-syntax.h" - -.text - ALIGN (3) - .globl C_SYMBOL_NAME(__mpn_add_n) -C_SYMBOL_NAME(__mpn_add_n:) - pushl %edi - pushl %esi - - movl 12(%esp),%edi /* res_ptr */ - movl 16(%esp),%esi /* s1_ptr */ - movl 20(%esp),%edx /* s2_ptr */ - movl 24(%esp),%ecx /* size */ - - movl %ecx,%eax - shrl $3,%ecx /* compute count for unrolled loop */ - negl %eax - andl $7,%eax /* get index where to start loop */ - jz Loop /* necessary special case for 0 */ - incl %ecx /* adjust loop count */ - shll $2,%eax /* adjustment for pointers... */ - subl %eax,%edi /* ... since they are offset ... */ - subl %eax,%esi /* ... by a constant when we ... */ - subl %eax,%edx /* ... enter the loop */ - shrl $2,%eax /* restore previous value */ -#ifdef PIC -/* Calculate start address in loop for PIC. Due to limitations in some - assemblers, Loop-L0-3 cannot be put into the leal */ - call L0 -L0: leal (%eax,%eax,8),%eax - addl (%esp),%eax - addl $(Loop-L0-3),%eax - addl $4,%esp -#else -/* Calculate start address in loop for non-PIC. */ - leal (Loop - 3)(%eax,%eax,8),%eax -#endif - jmp *%eax /* jump into loop */ - ALIGN (3) -Loop: movl (%esi),%eax - adcl (%edx),%eax - movl %eax,(%edi) - movl 4(%esi),%eax - adcl 4(%edx),%eax - movl %eax,4(%edi) - movl 8(%esi),%eax - adcl 8(%edx),%eax - movl %eax,8(%edi) - movl 12(%esi),%eax - adcl 12(%edx),%eax - movl %eax,12(%edi) - movl 16(%esi),%eax - adcl 16(%edx),%eax - movl %eax,16(%edi) - movl 20(%esi),%eax - adcl 20(%edx),%eax - movl %eax,20(%edi) - movl 24(%esi),%eax - adcl 24(%edx),%eax - movl %eax,24(%edi) - movl 28(%esi),%eax - adcl 28(%edx),%eax - movl %eax,28(%edi) - leal 32(%edi),%edi - leal 32(%esi),%esi - leal 32(%edx),%edx - decl %ecx - jnz Loop - - sbbl %eax,%eax - negl %eax - - popl %esi - popl %edi - ret diff --git a/gnu/lib/libgmp/mpn/x86/addmul_1.S b/gnu/lib/libgmp/mpn/x86/addmul_1.S deleted file mode 100644 index c11209d..0000000 --- a/gnu/lib/libgmp/mpn/x86/addmul_1.S +++ /dev/null @@ -1,76 +0,0 @@ -/* i80386 __mpn_addmul_1 -- Multiply a limb vector with a limb and add - the result to a second limb vector. - -Copyright (C) 1992, 1994 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - size (sp + 12) - s2_limb (sp + 16) -*/ - -#include "sysdep.h" -#include "asm-syntax.h" - -#define res_ptr edi -#define s1_ptr esi -#define size ecx -#define s2_limb ebp - - TEXT - ALIGN (3) - GLOBL C_SYMBOL_NAME(__mpn_addmul_1) -C_SYMBOL_NAME(__mpn_addmul_1:) - - INSN1(push,l ,R(edi)) - INSN1(push,l ,R(esi)) - INSN1(push,l ,R(ebx)) - INSN1(push,l ,R(ebp)) - - INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20)) - INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24)) - INSN2(mov,l ,R(size),MEM_DISP(esp,28)) - INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32)) - - INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4)) - INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4)) - INSN1(neg,l ,R(size)) - INSN2(xor,l ,R(ebx),R(ebx)) - ALIGN (3) -Loop: - INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4)) - INSN1(mul,l ,R(s2_limb)) - INSN2(add,l ,R(eax),R(ebx)) - INSN2(adc,l ,R(edx),$0) - INSN2(add,l ,MEM_INDEX(res_ptr,size,4),R(eax)) - INSN2(adc,l ,R(edx),$0) - INSN2(mov,l ,R(ebx),R(edx)) - - INSN1(inc,l ,R(size)) - INSN1(jnz, ,Loop) - INSN2(mov,l ,R(eax),R(ebx)) - - INSN1(pop,l ,R(ebp)) - INSN1(pop,l ,R(ebx)) - INSN1(pop,l ,R(esi)) - INSN1(pop,l ,R(edi)) - ret diff --git a/gnu/lib/libgmp/mpn/x86/lshift.S b/gnu/lib/libgmp/mpn/x86/lshift.S deleted file mode 100644 index 8173b92..0000000 --- a/gnu/lib/libgmp/mpn/x86/lshift.S +++ /dev/null @@ -1,85 +0,0 @@ -/* i80386 __mpn_lshift -- - -Copyright (C) 1992, 1994 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s_ptr (sp + 8) - size (sp + 12) - cnt (sp + 16) -*/ - -#include "sysdep.h" -#include "asm-syntax.h" - -.text - ALIGN (3) - .globl C_SYMBOL_NAME(__mpn_lshift) -C_SYMBOL_NAME(__mpn_lshift:) - pushl %edi - pushl %esi - pushl %ebx - - movl 16(%esp),%edi /* res_ptr */ - movl 20(%esp),%esi /* s_ptr */ - movl 24(%esp),%edx /* size */ - movl 28(%esp),%ecx /* cnt */ - - subl $4,%esi /* adjust s_ptr */ - - movl (%esi,%edx,4),%ebx /* read most significant limb */ - xorl %eax,%eax - shldl %cl,%ebx,%eax /* compute carry limb */ - decl %edx - jz Lend - pushl %eax /* push carry limb onto stack */ - testb $1,%edx - jnz L1 /* enter loop in the middle */ - movl %ebx,%eax - - ALIGN (3) -Loop: movl (%esi,%edx,4),%ebx /* load next lower limb */ - shldl %cl,%ebx,%eax /* compute result limb */ - movl %eax,(%edi,%edx,4) /* store it */ - decl %edx -L1: movl (%esi,%edx,4),%eax - shldl %cl,%eax,%ebx - movl %ebx,(%edi,%edx,4) - decl %edx - jnz Loop - - shll %cl,%eax /* compute least significant limb */ - movl %eax,(%edi) /* store it */ - - popl %eax /* pop carry limb */ - - popl %ebx - popl %esi - popl %edi - ret - -Lend: shll %cl,%ebx /* compute least significant limb */ - movl %ebx,(%edi) /* store it */ - - popl %ebx - popl %esi - popl %edi - ret diff --git a/gnu/lib/libgmp/mpn/x86/mul_1.S b/gnu/lib/libgmp/mpn/x86/mul_1.S deleted file mode 100644 index b271399..0000000 --- a/gnu/lib/libgmp/mpn/x86/mul_1.S +++ /dev/null @@ -1,75 +0,0 @@ -/* i80386 __mpn_mul_1 -- Multiply a limb vector with a limb and store - the result in a second limb vector. - -Copyright (C) 1992, 1994 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - size (sp + 12) - s2_limb (sp + 16) -*/ - -#include "sysdep.h" -#include "asm-syntax.h" - -#define res_ptr edi -#define s1_ptr esi -#define size ecx -#define s2_limb ebp - - TEXT - ALIGN (3) - GLOBL C_SYMBOL_NAME(__mpn_mul_1) -C_SYMBOL_NAME(__mpn_mul_1:) - - INSN1(push,l ,R(edi)) - INSN1(push,l ,R(esi)) - INSN1(push,l ,R(ebx)) - INSN1(push,l ,R(ebp)) - - INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20)) - INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24)) - INSN2(mov,l ,R(size),MEM_DISP(esp,28)) - INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32)) - - INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4)) - INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4)) - INSN1(neg,l ,R(size)) - INSN2(xor,l ,R(ebx),R(ebx)) - ALIGN (3) -Loop: - INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4)) - INSN1(mul,l ,R(s2_limb)) - INSN2(add,l ,R(eax),R(ebx)) - INSN2(mov,l ,MEM_INDEX(res_ptr,size,4),R(eax)) - INSN2(adc,l ,R(edx),$0) - INSN2(mov,l ,R(ebx),R(edx)) - - INSN1(inc,l ,R(size)) - INSN1(jnz, ,Loop) - INSN2(mov,l ,R(eax),R(ebx)) - - INSN1(pop,l ,R(ebp)) - INSN1(pop,l ,R(ebx)) - INSN1(pop,l ,R(esi)) - INSN1(pop,l ,R(edi)) - ret diff --git a/gnu/lib/libgmp/mpn/x86/pentium/README b/gnu/lib/libgmp/mpn/x86/pentium/README deleted file mode 100644 index d73b082..0000000 --- a/gnu/lib/libgmp/mpn/x86/pentium/README +++ /dev/null @@ -1,26 +0,0 @@ -This directory contains mpn functions optimized for Intel Pentium -processors. - -RELEVANT OPTIMIZATION ISSUES - -1. Pentium doesn't allocate cache lines on writes, unlike most other modern -processors. Since the functions in the mpn class do array writes, we have to -handle allocating the destination cache lines by reading a word from it in the -loops, to achieve the best performance. - -2. Pairing of memory operations requires that the two issued operations refer -to different cache banks. The simplest way to insure this is to read/write -two words from the same object. If we make operations on different objects, -they might or might not be to the same cache bank. - -STATUS - -1. mpn_lshift and mpn_rshift run at about 6 cycles/limb, but the Pentium -documentation indicates that they should take only 43/8 = 5.375 cycles/limb, -or 5 cycles/limb asymptotically. - -2. mpn_add_n and mpn_sub_n run at asymptotically 2 cycles/limb. Due to loop -overhead and other delays (cache refill?), they run at or near 2.5 cycles/limb. - -3. mpn_mul_1, mpn_addmul_1, mpn_submul_1 all run 1 cycle faster than they -should... diff --git a/gnu/lib/libgmp/mpn/x86/pentium/add_n.S b/gnu/lib/libgmp/mpn/x86/pentium/add_n.S deleted file mode 100644 index ac6f281..0000000 --- a/gnu/lib/libgmp/mpn/x86/pentium/add_n.S +++ /dev/null @@ -1,130 +0,0 @@ -/* Pentium __mpn_add_n -- Add two limb vectors of the same length > 0 and store - sum in a third limb vector. - -Copyright (C) 1992, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - s2_ptr (sp + 12) - size (sp + 16) -*/ - -#include "sysdep.h" -#include "asm-syntax.h" - -.text - ALIGN (3) - .globl C_SYMBOL_NAME(__mpn_add_n) -C_SYMBOL_NAME(__mpn_add_n:) - pushl %edi - pushl %esi - pushl %ebx - pushl %ebp - - movl 20(%esp),%edi /* res_ptr */ - movl 24(%esp),%esi /* s1_ptr */ - movl 28(%esp),%ebp /* s2_ptr */ - movl 32(%esp),%ecx /* size */ - - movl (%ebp),%ebx - - decl %ecx - movl %ecx,%edx - shrl $3,%ecx - andl $7,%edx - testl %ecx,%ecx /* zero carry flag */ - jz Lend - pushl %edx - - ALIGN (3) -Loop: movl 28(%edi),%eax /* fetch destination cache line */ - leal 32(%edi),%edi - -L1: movl (%esi),%eax - movl 4(%esi),%edx - adcl %ebx,%eax - movl 4(%ebp),%ebx - adcl %ebx,%edx - movl 8(%ebp),%ebx - movl %eax,-32(%edi) - movl %edx,-28(%edi) - -L2: movl 8(%esi),%eax - movl 12(%esi),%edx - adcl %ebx,%eax - movl 12(%ebp),%ebx - adcl %ebx,%edx - movl 16(%ebp),%ebx - movl %eax,-24(%edi) - movl %edx,-20(%edi) - -L3: movl 16(%esi),%eax - movl 20(%esi),%edx - adcl %ebx,%eax - movl 20(%ebp),%ebx - adcl %ebx,%edx - movl 24(%ebp),%ebx - movl %eax,-16(%edi) - movl %edx,-12(%edi) - -L4: movl 24(%esi),%eax - movl 28(%esi),%edx - adcl %ebx,%eax - movl 28(%ebp),%ebx - adcl %ebx,%edx - movl 32(%ebp),%ebx - movl %eax,-8(%edi) - movl %edx,-4(%edi) - - leal 32(%esi),%esi - leal 32(%ebp),%ebp - decl %ecx - jnz Loop - - popl %edx -Lend: - decl %edx /* test %edx w/o clobbering carry */ - js Lend2 - incl %edx -Loop2: - leal 4(%edi),%edi - movl (%esi),%eax - adcl %ebx,%eax - movl 4(%ebp),%ebx - movl %eax,-4(%edi) - leal 4(%esi),%esi - leal 4(%ebp),%ebp - decl %edx - jnz Loop2 -Lend2: - movl (%esi),%eax - adcl %ebx,%eax - movl %eax,(%edi) - - sbbl %eax,%eax - negl %eax - - popl %ebp - popl %ebx - popl %esi - popl %edi - ret diff --git a/gnu/lib/libgmp/mpn/x86/pentium/addmul_1.S b/gnu/lib/libgmp/mpn/x86/pentium/addmul_1.S deleted file mode 100644 index 7cfa5db..0000000 --- a/gnu/lib/libgmp/mpn/x86/pentium/addmul_1.S +++ /dev/null @@ -1,83 +0,0 @@ -/* Pentium __mpn_addmul_1 -- Multiply a limb vector with a limb and add - the result to a second limb vector. - -Copyright (C) 1992, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - size (sp + 12) - s2_limb (sp + 16) -*/ - -#include "sysdep.h" -#include "asm-syntax.h" - -#define res_ptr edi -#define s1_ptr esi -#define size ecx -#define s2_limb ebp - - TEXT - ALIGN (3) - GLOBL C_SYMBOL_NAME(__mpn_addmul_1) -C_SYMBOL_NAME(__mpn_addmul_1:) - - INSN1(push,l ,R(edi)) - INSN1(push,l ,R(esi)) - INSN1(push,l ,R(ebx)) - INSN1(push,l ,R(ebp)) - - INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20)) - INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24)) - INSN2(mov,l ,R(size),MEM_DISP(esp,28)) - INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32)) - - INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4)) - INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4)) - INSN1(neg,l ,R(size)) - INSN2(xor,l ,R(ebx),R(ebx)) - ALIGN (3) - -Loop: INSN2(adc,l ,R(ebx),$0) - INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4)) - - INSN1(mul,l ,R(s2_limb)) - - INSN2(add,l ,R(eax),R(ebx)) - INSN2(mov,l ,R(ebx),MEM_INDEX(res_ptr,size,4)) - - INSN2(adc,l ,R(edx),$0) - INSN2(add,l ,R(ebx),R(eax)) - - INSN2(mov,l ,MEM_INDEX(res_ptr,size,4),R(ebx)) - INSN1(inc,l ,R(size)) - - INSN2(mov,l ,R(ebx),R(edx)) - INSN1(jnz, ,Loop) - - INSN2(adc,l ,R(ebx),$0) - INSN2(mov,l ,R(eax),R(ebx)) - INSN1(pop,l ,R(ebp)) - INSN1(pop,l ,R(ebx)) - INSN1(pop,l ,R(esi)) - INSN1(pop,l ,R(edi)) - ret diff --git a/gnu/lib/libgmp/mpn/x86/pentium/lshift.S b/gnu/lib/libgmp/mpn/x86/pentium/lshift.S deleted file mode 100644 index b298983..0000000 --- a/gnu/lib/libgmp/mpn/x86/pentium/lshift.S +++ /dev/null @@ -1,217 +0,0 @@ -/* Pentium optimized __mpn_lshift -- - -Copyright (C) 1992, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s_ptr (sp + 8) - size (sp + 12) - cnt (sp + 16) -*/ - -#include "sysdep.h" -#include "asm-syntax.h" - -.text - ALIGN (3) - .globl C_SYMBOL_NAME(__mpn_lshift) -C_SYMBOL_NAME(__mpn_lshift:) - pushl %edi - pushl %esi - pushl %ebx - pushl %ebp - - movl 20(%esp),%edi /* res_ptr */ - movl 24(%esp),%esi /* s_ptr */ - movl 28(%esp),%ebp /* size */ - movl 32(%esp),%ecx /* cnt */ - -/* We can use faster code for shift-by-1 under certain conditions. */ - cmp $1,%ecx - jne Lnormal - leal 4(%esi),%eax - cmpl %edi,%eax - jnc Lspecial /* jump if s_ptr + 1 >= res_ptr */ - leal (%esi,%ebp,4),%eax - cmpl %eax,%edi - jnc Lspecial /* jump if res_ptr >= s_ptr + size */ - -Lnormal: - leal -4(%edi,%ebp,4),%edi - leal -4(%esi,%ebp,4),%esi - - movl (%esi),%edx - subl $4,%esi - xorl %eax,%eax - shldl %cl,%edx,%eax /* compute carry limb */ - pushl %eax /* push carry limb onto stack */ - - decl %ebp - pushl %ebp - shrl $3,%ebp - jz Lend - - movl (%edi),%eax /* fetch destination cache line */ - - ALIGN (2) -Loop: movl -28(%edi),%eax /* fetch destination cache line */ - movl %edx,%ebx - - movl (%esi),%eax - movl -4(%esi),%edx - shldl %cl,%eax,%ebx - shldl %cl,%edx,%eax - movl %ebx,(%edi) - movl %eax,-4(%edi) - - movl -8(%esi),%ebx - movl -12(%esi),%eax - shldl %cl,%ebx,%edx - shldl %cl,%eax,%ebx - movl %edx,-8(%edi) - movl %ebx,-12(%edi) - - movl -16(%esi),%edx - movl -20(%esi),%ebx - shldl %cl,%edx,%eax - shldl %cl,%ebx,%edx - movl %eax,-16(%edi) - movl %edx,-20(%edi) - - movl -24(%esi),%eax - movl -28(%esi),%edx - shldl %cl,%eax,%ebx - shldl %cl,%edx,%eax - movl %ebx,-24(%edi) - movl %eax,-28(%edi) - - subl $32,%esi - subl $32,%edi - decl %ebp - jnz Loop - -Lend: popl %ebp - andl $7,%ebp - jz Lend2 -Loop2: movl (%esi),%eax - shldl %cl,%eax,%edx - movl %edx,(%edi) - movl %eax,%edx - subl $4,%esi - subl $4,%edi - decl %ebp - jnz Loop2 - -Lend2: shll %cl,%edx /* compute least significant limb */ - movl %edx,(%edi) /* store it */ - - popl %eax /* pop carry limb */ - - popl %ebp - popl %ebx - popl %esi - popl %edi - ret - -/* We loop from least significant end of the arrays, which is only - permissable if the source and destination don't overlap, since the - function is documented to work for overlapping source and destination. -*/ - -Lspecial: - movl (%esi),%edx - addl $4,%esi - - decl %ebp - pushl %ebp - shrl $3,%ebp - - addl %edx,%edx - incl %ebp - decl %ebp - jz LLend - - movl (%edi),%eax /* fetch destination cache line */ - - ALIGN (2) -LLoop: movl 28(%edi),%eax /* fetch destination cache line */ - movl %edx,%ebx - - movl (%esi),%eax - movl 4(%esi),%edx - adcl %eax,%eax - movl %ebx,(%edi) - adcl %edx,%edx - movl %eax,4(%edi) - - movl 8(%esi),%ebx - movl 12(%esi),%eax - adcl %ebx,%ebx - movl %edx,8(%edi) - adcl %eax,%eax - movl %ebx,12(%edi) - - movl 16(%esi),%edx - movl 20(%esi),%ebx - adcl %edx,%edx - movl %eax,16(%edi) - adcl %ebx,%ebx - movl %edx,20(%edi) - - movl 24(%esi),%eax - movl 28(%esi),%edx - adcl %eax,%eax - movl %ebx,24(%edi) - adcl %edx,%edx - movl %eax,28(%edi) - - leal 32(%esi),%esi /* use leal not to clobber carry */ - leal 32(%edi),%edi - decl %ebp - jnz LLoop - -LLend: popl %ebp - sbbl %eax,%eax /* save carry in %eax */ - andl $7,%ebp - jz LLend2 - addl %eax,%eax /* restore carry from eax */ -LLoop2: movl %edx,%ebx - movl (%esi),%edx - adcl %edx,%edx - movl %ebx,(%edi) - - leal 4(%esi),%esi /* use leal not to clobber carry */ - leal 4(%edi),%edi - decl %ebp - jnz LLoop2 - - jmp LL1 -LLend2: addl %eax,%eax /* restore carry from eax */ -LL1: movl %edx,(%edi) /* store last limb */ - - sbbl %eax,%eax - negl %eax - - popl %ebp - popl %ebx - popl %esi - popl %edi - ret diff --git a/gnu/lib/libgmp/mpn/x86/pentium/mul_1.S b/gnu/lib/libgmp/mpn/x86/pentium/mul_1.S deleted file mode 100644 index 4ac3050..0000000 --- a/gnu/lib/libgmp/mpn/x86/pentium/mul_1.S +++ /dev/null @@ -1,79 +0,0 @@ -/* Pentium __mpn_mul_1 -- Multiply a limb vector with a limb and store - the result in a second limb vector. - -Copyright (C) 1992, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - size (sp + 12) - s2_limb (sp + 16) -*/ - -#include "sysdep.h" -#include "asm-syntax.h" - -#define res_ptr edi -#define s1_ptr esi -#define size ecx -#define s2_limb ebp - - TEXT - ALIGN (3) - GLOBL C_SYMBOL_NAME(__mpn_mul_1) -C_SYMBOL_NAME(__mpn_mul_1:) - - INSN1(push,l ,R(edi)) - INSN1(push,l ,R(esi)) - INSN1(push,l ,R(ebx)) - INSN1(push,l ,R(ebp)) - - INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20)) - INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24)) - INSN2(mov,l ,R(size),MEM_DISP(esp,28)) - INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32)) - - INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4)) - INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4)) - INSN1(neg,l ,R(size)) - INSN2(xor,l ,R(ebx),R(ebx)) - ALIGN (3) - -Loop: INSN2(adc,l ,R(ebx),$0) - INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4)) - - INSN1(mul,l ,R(s2_limb)) - - INSN2(add,l ,R(ebx),R(eax)) - - INSN2(mov,l ,MEM_INDEX(res_ptr,size,4),R(ebx)) - INSN1(inc,l ,R(size)) - - INSN2(mov,l ,R(ebx),R(edx)) - INSN1(jnz, ,Loop) - - INSN2(adc,l ,R(ebx),$0) - INSN2(mov,l ,R(eax),R(ebx)) - INSN1(pop,l ,R(ebp)) - INSN1(pop,l ,R(ebx)) - INSN1(pop,l ,R(esi)) - INSN1(pop,l ,R(edi)) - ret diff --git a/gnu/lib/libgmp/mpn/x86/pentium/rshift.S b/gnu/lib/libgmp/mpn/x86/pentium/rshift.S deleted file mode 100644 index 38398ed..0000000 --- a/gnu/lib/libgmp/mpn/x86/pentium/rshift.S +++ /dev/null @@ -1,217 +0,0 @@ -/* Pentium optimized __mpn_rshift -- - -Copyright (C) 1992, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s_ptr (sp + 8) - size (sp + 12) - cnt (sp + 16) -*/ - -#include "sysdep.h" -#include "asm-syntax.h" - -.text - ALIGN (3) - .globl C_SYMBOL_NAME(__mpn_rshift) -C_SYMBOL_NAME(__mpn_rshift:) - pushl %edi - pushl %esi - pushl %ebx - pushl %ebp - - movl 20(%esp),%edi /* res_ptr */ - movl 24(%esp),%esi /* s_ptr */ - movl 28(%esp),%ebp /* size */ - movl 32(%esp),%ecx /* cnt */ - -/* We can use faster code for shift-by-1 under certain conditions. */ - cmp $1,%ecx - jne Lnormal - leal 4(%edi),%eax - cmpl %esi,%eax - jnc Lspecial /* jump if res_ptr + 1 >= s_ptr */ - leal (%edi,%ebp,4),%eax - cmpl %eax,%esi - jnc Lspecial /* jump if s_ptr >= res_ptr + size */ - -Lnormal: - movl (%esi),%edx - addl $4,%esi - xorl %eax,%eax - shrdl %cl,%edx,%eax /* compute carry limb */ - pushl %eax /* push carry limb onto stack */ - - decl %ebp - pushl %ebp - shrl $3,%ebp - jz Lend - - movl (%edi),%eax /* fetch destination cache line */ - - ALIGN (2) -Loop: movl 28(%edi),%eax /* fetch destination cache line */ - movl %edx,%ebx - - movl (%esi),%eax - movl 4(%esi),%edx - shrdl %cl,%eax,%ebx - shrdl %cl,%edx,%eax - movl %ebx,(%edi) - movl %eax,4(%edi) - - movl 8(%esi),%ebx - movl 12(%esi),%eax - shrdl %cl,%ebx,%edx - shrdl %cl,%eax,%ebx - movl %edx,8(%edi) - movl %ebx,12(%edi) - - movl 16(%esi),%edx - movl 20(%esi),%ebx - shrdl %cl,%edx,%eax - shrdl %cl,%ebx,%edx - movl %eax,16(%edi) - movl %edx,20(%edi) - - movl 24(%esi),%eax - movl 28(%esi),%edx - shrdl %cl,%eax,%ebx - shrdl %cl,%edx,%eax - movl %ebx,24(%edi) - movl %eax,28(%edi) - - addl $32,%esi - addl $32,%edi - decl %ebp - jnz Loop - -Lend: popl %ebp - andl $7,%ebp - jz Lend2 -Loop2: movl (%esi),%eax - shrdl %cl,%eax,%edx /* compute result limb */ - movl %edx,(%edi) - movl %eax,%edx - addl $4,%esi - addl $4,%edi - decl %ebp - jnz Loop2 - -Lend2: shrl %cl,%edx /* compute most significant limb */ - movl %edx,(%edi) /* store it */ - - popl %eax /* pop carry limb */ - - popl %ebp - popl %ebx - popl %esi - popl %edi - ret - -/* We loop from least significant end of the arrays, which is only - permissable if the source and destination don't overlap, since the - function is documented to work for overlapping source and destination. -*/ - -Lspecial: - leal -4(%edi,%ebp,4),%edi - leal -4(%esi,%ebp,4),%esi - - movl (%esi),%edx - subl $4,%esi - - decl %ebp - pushl %ebp - shrl $3,%ebp - - shrl $1,%edx - incl %ebp - decl %ebp - jz LLend - - movl (%edi),%eax /* fetch destination cache line */ - - ALIGN (2) -LLoop: movl -28(%edi),%eax /* fetch destination cache line */ - movl %edx,%ebx - - movl (%esi),%eax - movl -4(%esi),%edx - rcrl $1,%eax - movl %ebx,(%edi) - rcrl $1,%edx - movl %eax,-4(%edi) - - movl -8(%esi),%ebx - movl -12(%esi),%eax - rcrl $1,%ebx - movl %edx,-8(%edi) - rcrl $1,%eax - movl %ebx,-12(%edi) - - movl -16(%esi),%edx - movl -20(%esi),%ebx - rcrl $1,%edx - movl %eax,-16(%edi) - rcrl $1,%ebx - movl %edx,-20(%edi) - - movl -24(%esi),%eax - movl -28(%esi),%edx - rcrl $1,%eax - movl %ebx,-24(%edi) - rcrl $1,%edx - movl %eax,-28(%edi) - - leal -32(%esi),%esi /* use leal not to clobber carry */ - leal -32(%edi),%edi - decl %ebp - jnz LLoop - -LLend: popl %ebp - sbbl %eax,%eax /* save carry in %eax */ - andl $7,%ebp - jz LLend2 - addl %eax,%eax /* restore carry from eax */ -LLoop2: movl %edx,%ebx - movl (%esi),%edx - rcrl $1,%edx - movl %ebx,(%edi) - - leal -4(%esi),%esi /* use leal not to clobber carry */ - leal -4(%edi),%edi - decl %ebp - jnz LLoop2 - - jmp LL1 -LLend2: addl %eax,%eax /* restore carry from eax */ -LL1: movl %edx,(%edi) /* store last limb */ - - movl $0,%eax - rcrl $1,%eax - - popl %ebp - popl %ebx - popl %esi - popl %edi - ret diff --git a/gnu/lib/libgmp/mpn/x86/pentium/sub_n.S b/gnu/lib/libgmp/mpn/x86/pentium/sub_n.S deleted file mode 100644 index d1a2bc0..0000000 --- a/gnu/lib/libgmp/mpn/x86/pentium/sub_n.S +++ /dev/null @@ -1,130 +0,0 @@ -/* Pentium __mpn_sub_n -- Subtract two limb vectors of the same length > 0 - and store difference in a third limb vector. - -Copyright (C) 1992, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - s2_ptr (sp + 12) - size (sp + 16) -*/ - -#include "sysdep.h" -#include "asm-syntax.h" - -.text - ALIGN (3) - .globl C_SYMBOL_NAME(__mpn_sub_n) -C_SYMBOL_NAME(__mpn_sub_n:) - pushl %edi - pushl %esi - pushl %ebx - pushl %ebp - - movl 20(%esp),%edi /* res_ptr */ - movl 24(%esp),%esi /* s1_ptr */ - movl 28(%esp),%ebp /* s2_ptr */ - movl 32(%esp),%ecx /* size */ - - movl (%ebp),%ebx - - decl %ecx - movl %ecx,%edx - shrl $3,%ecx - andl $7,%edx - testl %ecx,%ecx /* zero carry flag */ - jz Lend - pushl %edx - - ALIGN (3) -Loop: movl 28(%edi),%eax /* fetch destination cache line */ - leal 32(%edi),%edi - -L1: movl (%esi),%eax - movl 4(%esi),%edx - sbbl %ebx,%eax - movl 4(%ebp),%ebx - sbbl %ebx,%edx - movl 8(%ebp),%ebx - movl %eax,-32(%edi) - movl %edx,-28(%edi) - -L2: movl 8(%esi),%eax - movl 12(%esi),%edx - sbbl %ebx,%eax - movl 12(%ebp),%ebx - sbbl %ebx,%edx - movl 16(%ebp),%ebx - movl %eax,-24(%edi) - movl %edx,-20(%edi) - -L3: movl 16(%esi),%eax - movl 20(%esi),%edx - sbbl %ebx,%eax - movl 20(%ebp),%ebx - sbbl %ebx,%edx - movl 24(%ebp),%ebx - movl %eax,-16(%edi) - movl %edx,-12(%edi) - -L4: movl 24(%esi),%eax - movl 28(%esi),%edx - sbbl %ebx,%eax - movl 28(%ebp),%ebx - sbbl %ebx,%edx - movl 32(%ebp),%ebx - movl %eax,-8(%edi) - movl %edx,-4(%edi) - - leal 32(%esi),%esi - leal 32(%ebp),%ebp - decl %ecx - jnz Loop - - popl %edx -Lend: - decl %edx /* test %edx w/o clobbering carry */ - js Lend2 - incl %edx -Loop2: - leal 4(%edi),%edi - movl (%esi),%eax - sbbl %ebx,%eax - movl 4(%ebp),%ebx - movl %eax,-4(%edi) - leal 4(%esi),%esi - leal 4(%ebp),%ebp - decl %edx - jnz Loop2 -Lend2: - movl (%esi),%eax - sbbl %ebx,%eax - movl %eax,(%edi) - - sbbl %eax,%eax - negl %eax - - popl %ebp - popl %ebx - popl %esi - popl %edi - ret diff --git a/gnu/lib/libgmp/mpn/x86/pentium/submul_1.S b/gnu/lib/libgmp/mpn/x86/pentium/submul_1.S deleted file mode 100644 index adf2d63..0000000 --- a/gnu/lib/libgmp/mpn/x86/pentium/submul_1.S +++ /dev/null @@ -1,83 +0,0 @@ -/* Pentium __mpn_submul_1 -- Multiply a limb vector with a limb and subtract - the result from a second limb vector. - -Copyright (C) 1992, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - size (sp + 12) - s2_limb (sp + 16) -*/ - -#include "sysdep.h" -#include "asm-syntax.h" - -#define res_ptr edi -#define s1_ptr esi -#define size ecx -#define s2_limb ebp - - TEXT - ALIGN (3) - GLOBL C_SYMBOL_NAME(__mpn_submul_1) -C_SYMBOL_NAME(__mpn_submul_1:) - - INSN1(push,l ,R(edi)) - INSN1(push,l ,R(esi)) - INSN1(push,l ,R(ebx)) - INSN1(push,l ,R(ebp)) - - INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20)) - INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24)) - INSN2(mov,l ,R(size),MEM_DISP(esp,28)) - INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32)) - - INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4)) - INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4)) - INSN1(neg,l ,R(size)) - INSN2(xor,l ,R(ebx),R(ebx)) - ALIGN (3) - -Loop: INSN2(adc,l ,R(ebx),$0) - INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4)) - - INSN1(mul,l ,R(s2_limb)) - - INSN2(add,l ,R(eax),R(ebx)) - INSN2(mov,l ,R(ebx),MEM_INDEX(res_ptr,size,4)) - - INSN2(adc,l ,R(edx),$0) - INSN2(sub,l ,R(ebx),R(eax)) - - INSN2(mov,l ,MEM_INDEX(res_ptr,size,4),R(ebx)) - INSN1(inc,l ,R(size)) - - INSN2(mov,l ,R(ebx),R(edx)) - INSN1(jnz, ,Loop) - - INSN2(adc,l ,R(ebx),$0) - INSN2(mov,l ,R(eax),R(ebx)) - INSN1(pop,l ,R(ebp)) - INSN1(pop,l ,R(ebx)) - INSN1(pop,l ,R(esi)) - INSN1(pop,l ,R(edi)) - ret diff --git a/gnu/lib/libgmp/mpn/x86/rshift.S b/gnu/lib/libgmp/mpn/x86/rshift.S deleted file mode 100644 index 9abbf9a..0000000 --- a/gnu/lib/libgmp/mpn/x86/rshift.S +++ /dev/null @@ -1,87 +0,0 @@ -/* i80386 __mpn_rshift -- - -Copyright (C) 1992, 1994 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s_ptr (sp + 8) - size (sp + 12) - cnt (sp + 16) -*/ - -#include "sysdep.h" -#include "asm-syntax.h" - -.text - ALIGN (3) - .globl C_SYMBOL_NAME(__mpn_rshift) -C_SYMBOL_NAME(__mpn_rshift:) - pushl %edi - pushl %esi - pushl %ebx - - movl 16(%esp),%edi /* res_ptr */ - movl 20(%esp),%esi /* s_ptr */ - movl 24(%esp),%edx /* size */ - movl 28(%esp),%ecx /* cnt */ - - leal -4(%edi,%edx,4),%edi - leal (%esi,%edx,4),%esi - negl %edx - - movl (%esi,%edx,4),%ebx /* read least significant limb */ - xorl %eax,%eax - shrdl %cl,%ebx,%eax /* compute carry limb */ - incl %edx - jz Lend - pushl %eax /* push carry limb onto stack */ - testb $1,%edx - jnz L1 /* enter loop in the middle */ - movl %ebx,%eax - - ALIGN (3) -Loop: movl (%esi,%edx,4),%ebx /* load next higher limb */ - shrdl %cl,%ebx,%eax /* compute result limb */ - movl %eax,(%edi,%edx,4) /* store it */ - incl %edx -L1: movl (%esi,%edx,4),%eax - shrdl %cl,%eax,%ebx - movl %ebx,(%edi,%edx,4) - incl %edx - jnz Loop - - shrl %cl,%eax /* compute most significant limb */ - movl %eax,(%edi) /* store it */ - - popl %eax /* pop carry limb */ - - popl %ebx - popl %esi - popl %edi - ret - -Lend: shrl %cl,%ebx /* compute most significant limb */ - movl %ebx,(%edi) /* store it */ - - popl %ebx - popl %esi - popl %edi - ret diff --git a/gnu/lib/libgmp/mpn/x86/sub_n.S b/gnu/lib/libgmp/mpn/x86/sub_n.S deleted file mode 100644 index 1774f3a..0000000 --- a/gnu/lib/libgmp/mpn/x86/sub_n.S +++ /dev/null @@ -1,106 +0,0 @@ -/* i80386 __mpn_sub_n -- Add two limb vectors of the same length > 0 and store - sum in a third limb vector. - -Copyright (C) 1992, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - s2_ptr (sp + 12) - size (sp + 16) -*/ - -#include "sysdep.h" -#include "asm-syntax.h" - -.text - ALIGN (3) - .globl C_SYMBOL_NAME(__mpn_sub_n) -C_SYMBOL_NAME(__mpn_sub_n:) - pushl %edi - pushl %esi - - movl 12(%esp),%edi /* res_ptr */ - movl 16(%esp),%esi /* s1_ptr */ - movl 20(%esp),%edx /* s2_ptr */ - movl 24(%esp),%ecx /* size */ - - movl %ecx,%eax - shrl $3,%ecx /* compute count for unrolled loop */ - negl %eax - andl $7,%eax /* get index where to start loop */ - jz Loop /* necessary special case for 0 */ - incl %ecx /* adjust loop count */ - shll $2,%eax /* adjustment for pointers... */ - subl %eax,%edi /* ... since they are offset ... */ - subl %eax,%esi /* ... by a constant when we ... */ - subl %eax,%edx /* ... enter the loop */ - shrl $2,%eax /* restore previous value */ -#ifdef PIC -/* Calculate start address in loop for PIC. Due to limitations in some - assemblers, Loop-L0-3 cannot be put into the leal */ - call L0 -L0: leal (%eax,%eax,8),%eax - addl (%esp),%eax - addl $(Loop-L0-3),%eax - addl $4,%esp -#else -/* Calculate start address in loop for non-PIC. */ - leal (Loop - 3)(%eax,%eax,8),%eax -#endif - jmp *%eax /* jump into loop */ - ALIGN (3) -Loop: movl (%esi),%eax - sbbl (%edx),%eax - movl %eax,(%edi) - movl 4(%esi),%eax - sbbl 4(%edx),%eax - movl %eax,4(%edi) - movl 8(%esi),%eax - sbbl 8(%edx),%eax - movl %eax,8(%edi) - movl 12(%esi),%eax - sbbl 12(%edx),%eax - movl %eax,12(%edi) - movl 16(%esi),%eax - sbbl 16(%edx),%eax - movl %eax,16(%edi) - movl 20(%esi),%eax - sbbl 20(%edx),%eax - movl %eax,20(%edi) - movl 24(%esi),%eax - sbbl 24(%edx),%eax - movl %eax,24(%edi) - movl 28(%esi),%eax - sbbl 28(%edx),%eax - movl %eax,28(%edi) - leal 32(%edi),%edi - leal 32(%esi),%esi - leal 32(%edx),%edx - decl %ecx - jnz Loop - - sbbl %eax,%eax - negl %eax - - popl %esi - popl %edi - ret diff --git a/gnu/lib/libgmp/mpn/x86/submul_1.S b/gnu/lib/libgmp/mpn/x86/submul_1.S deleted file mode 100644 index 730e732..0000000 --- a/gnu/lib/libgmp/mpn/x86/submul_1.S +++ /dev/null @@ -1,76 +0,0 @@ -/* i80386 __mpn_submul_1 -- Multiply a limb vector with a limb and subtract - the result from a second limb vector. - -Copyright (C) 1992, 1994 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* - INPUT PARAMETERS - res_ptr (sp + 4) - s1_ptr (sp + 8) - size (sp + 12) - s2_limb (sp + 16) -*/ - -#include "sysdep.h" -#include "asm-syntax.h" - -#define res_ptr edi -#define s1_ptr esi -#define size ecx -#define s2_limb ebp - - TEXT - ALIGN (3) - GLOBL C_SYMBOL_NAME(__mpn_submul_1) -C_SYMBOL_NAME(__mpn_submul_1:) - - INSN1(push,l ,R(edi)) - INSN1(push,l ,R(esi)) - INSN1(push,l ,R(ebx)) - INSN1(push,l ,R(ebp)) - - INSN2(mov,l ,R(res_ptr),MEM_DISP(esp,20)) - INSN2(mov,l ,R(s1_ptr),MEM_DISP(esp,24)) - INSN2(mov,l ,R(size),MEM_DISP(esp,28)) - INSN2(mov,l ,R(s2_limb),MEM_DISP(esp,32)) - - INSN2(lea,l ,R(res_ptr),MEM_INDEX(res_ptr,size,4)) - INSN2(lea,l ,R(s1_ptr),MEM_INDEX(s1_ptr,size,4)) - INSN1(neg,l ,R(size)) - INSN2(xor,l ,R(ebx),R(ebx)) - ALIGN (3) -Loop: - INSN2(mov,l ,R(eax),MEM_INDEX(s1_ptr,size,4)) - INSN1(mul,l ,R(s2_limb)) - INSN2(add,l ,R(eax),R(ebx)) - INSN2(adc,l ,R(edx),$0) - INSN2(sub,l ,MEM_INDEX(res_ptr,size,4),R(eax)) - INSN2(adc,l ,R(edx),$0) - INSN2(mov,l ,R(ebx),R(edx)) - - INSN1(inc,l ,R(size)) - INSN1(jnz, ,Loop) - INSN2(mov,l ,R(eax),R(ebx)) - - INSN1(pop,l ,R(ebp)) - INSN1(pop,l ,R(ebx)) - INSN1(pop,l ,R(esi)) - INSN1(pop,l ,R(edi)) - ret diff --git a/gnu/lib/libgmp/mpn/x86/syntax.h b/gnu/lib/libgmp/mpn/x86/syntax.h deleted file mode 100644 index c53c73c..0000000 --- a/gnu/lib/libgmp/mpn/x86/syntax.h +++ /dev/null @@ -1,62 +0,0 @@ -/* asm.h -- Definitions for x86 syntax variations. - -Copyright (C) 1992, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - - -#undef ALIGN - -#if defined (BSD_SYNTAX) || defined (ELF_SYNTAX) -#define R(r) %r -#define MEM(base)(base) -#define MEM_DISP(base,displacement)displacement(R(base)) -#define MEM_INDEX(base,index,size)(R(base),R(index),size) -#ifdef __STDC__ -#define INSN1(mnemonic,size_suffix,dst)mnemonic##size_suffix dst -#define INSN2(mnemonic,size_suffix,dst,src)mnemonic##size_suffix src,dst -#else -#define INSN1(mnemonic,size_suffix,dst)mnemonic/**/size_suffix dst -#define INSN2(mnemonic,size_suffix,dst,src)mnemonic/**/size_suffix src,dst -#endif -#define TEXT .text -#if defined (BSD_SYNTAX) -#define ALIGN(log) .align log -#endif -#if defined (ELF_SYNTAX) -#define ALIGN(log) .align 1<<(log) -#endif -#define GLOBL .globl -#endif - -#ifdef INTEL_SYNTAX -#define R(r) r -#define MEM(base)[base] -#define MEM_DISP(base,displacement)[base+(displacement)] -#define MEM_INDEX(base,index,size)[base+index*size] -#define INSN1(mnemonic,size_suffix,dst)mnemonic dst -#define INSN2(mnemonic,size_suffix,dst,src)mnemonic dst,src -#define TEXT .text -#define ALIGN(log) .align log -#define GLOBL .globl -#endif - -#ifdef BROKEN_ALIGN -#undef ALIGN -#define ALIGN(log) .align log,0x90 -#endif diff --git a/gnu/lib/libgmp/mpq/Makefile.in b/gnu/lib/libgmp/mpq/Makefile.in deleted file mode 100644 index f34ffb9..0000000 --- a/gnu/lib/libgmp/mpq/Makefile.in +++ /dev/null @@ -1,81 +0,0 @@ -# Makefile for GNU MP/mpq functions -# Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -# the Free Software Foundation; either version 2 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 Library General Public -# License for more details. - -# You should have received a copy of the GNU Library General Public License -# along with the GNU MP Library; see the file COPYING.LIB. If not, write to -# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA. - -srcdir = . - -CC = gcc - -CFLAGS = -g -O -AR = ar -AR_FLAGS = rc -SHELL = /bin/sh - -#### host and target specific makefile fragments come in here. -### - -MPQ_SRCS = add.c canonicalize.c clear.c cmp.c cmp_ui.c div.c get_d.c \ - get_den.c get_num.c init.c inv.c mul.c neg.c set.c set_den.c set_num.c \ - set_si.c set_ui.c sub.c equal.c set_z.c -MPQ_OBJS = add.o canonicalize.o clear.o cmp.o cmp_ui.o div.o get_d.o \ - get_den.o get_num.o init.o inv.o mul.o neg.o set.o set_den.o set_num.o \ - set_si.o set_ui.o sub.o equal.o set_z.o - -INCLUDES = -I. -I.. -I../mpn -I$(srcdir)/.. - -libmpq.a: Makefile $(MPQ_OBJS) - rm -f $@ - $(AR) $(AR_FLAGS) $@ $(MPQ_OBJS) - -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(XCFLAGS) $< - -clean mostlyclean: - rm -f *.o libmpq.a - -cd tests; $(MAKE) $@ -distclean maintainer-clean: clean - rm -f Makefile config.status - -cd tests; $(MAKE) $@ - -Makefile: $(srcdir)/Makefile.in - $(SHELL) ./config.status - -H = $(srcdir)/../gmp.h $(srcdir)/../gmp-impl.h ../mpn/gmp-mparam.h - -add.o: $(srcdir)/add.c $(H) -canonicalize.o: $(srcdir)/canonicalize.c $(H) -clear.o: $(srcdir)/clear.c $(H) -cmp.o: $(srcdir)/cmp.c $(H) $(srcdir)/../longlong.h -cmp_ui.o: $(srcdir)/cmp_ui.c $(H) -div.o: $(srcdir)/div.c $(H) -equal.o: $(srcdir)/equal.c $(H) -get_d.o: $(srcdir)/get_d.c $(H) $(srcdir)/../longlong.h -get_den.o: $(srcdir)/get_den.c $(H) -get_num.o: $(srcdir)/get_num.c $(H) -init.o: $(srcdir)/init.c $(H) -inv.o: $(srcdir)/inv.c $(H) -mul.o: $(srcdir)/mul.c $(H) -neg.o: $(srcdir)/neg.c $(H) -set.o: $(srcdir)/set.c $(H) -set_den.o: $(srcdir)/set_den.c $(H) -set_num.o: $(srcdir)/set_num.c $(H) -set_si.o: $(srcdir)/set_si.c $(H) -set_ui.o: $(srcdir)/set_ui.c $(H) -set_z.o: $(srcdir)/set_z.c $(H) -sub.o: $(srcdir)/sub.c $(H) diff --git a/gnu/lib/libgmp/mpq/add.c b/gnu/lib/libgmp/mpq/add.c deleted file mode 100644 index 6b98b46..0000000 --- a/gnu/lib/libgmp/mpq/add.c +++ /dev/null @@ -1,85 +0,0 @@ -/* mpq_add -- add two rational numbers. - -Copyright (C) 1991, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_add (mpq_ptr rop, mpq_srcptr op1, mpq_srcptr op2) -#else -mpq_add (rop, op1, op2) - mpq_ptr rop; - mpq_srcptr op1; - mpq_srcptr op2; -#endif -{ - mpz_t gcd; - mpz_t tmp1, tmp2; - mp_size_t op1_num_size = ABS (op1->_mp_num._mp_size); - mp_size_t op1_den_size = ABS (op1->_mp_den._mp_size); - mp_size_t op2_num_size = ABS (op2->_mp_num._mp_size); - mp_size_t op2_den_size = ABS (op2->_mp_den._mp_size); - TMP_DECL (marker); - - TMP_MARK (marker); - MPZ_TMP_INIT (gcd, MIN (op1_den_size, op2_den_size)); - MPZ_TMP_INIT (tmp1, op1_num_size + op2_den_size); - MPZ_TMP_INIT (tmp2, op2_num_size + op1_den_size); - - /* ROP might be identical to either operand, so don't store the - result there until we are finished with the input operands. We - dare to overwrite the numerator of ROP when we are finished - with the numerators of OP1 and OP2. */ - - mpz_gcd (gcd, &(op1->_mp_den), &(op2->_mp_den)); - if (gcd->_mp_size > 1 || gcd->_mp_d[0] != 1) - { - mpz_t t; - - mpz_divexact (tmp1, &(op2->_mp_den), gcd); - mpz_mul (tmp1, &(op1->_mp_num), tmp1); - - mpz_divexact (tmp2, &(op1->_mp_den), gcd); - mpz_mul (tmp2, &(op2->_mp_num), tmp2); - - MPZ_TMP_INIT (t, MAX (ABS (tmp1->_mp_size), ABS (tmp2->_mp_size)) + 1); - - mpz_add (t, tmp1, tmp2); - mpz_divexact (tmp1, &(op1->_mp_den), gcd); - mpz_gcd (gcd, t, gcd); - - mpz_divexact (&(rop->_mp_num), t, gcd); - - mpz_divexact (tmp2, &(op2->_mp_den), gcd); - mpz_mul (&(rop->_mp_den), tmp1, tmp2); - } - else - { - /* The common divisor is 1. This is the case (for random input) with - probability 6/(pi**2). */ - mpz_mul (tmp1, &(op1->_mp_num), &(op2->_mp_den)); - mpz_mul (tmp2, &(op2->_mp_num), &(op1->_mp_den)); - mpz_add (&(rop->_mp_num), tmp1, tmp2); - mpz_mul (&(rop->_mp_den), &(op1->_mp_den), &(op2->_mp_den)); - } - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpq/canonicalize.c b/gnu/lib/libgmp/mpq/canonicalize.c deleted file mode 100644 index 901e6eb..0000000 --- a/gnu/lib/libgmp/mpq/canonicalize.c +++ /dev/null @@ -1,53 +0,0 @@ -/* mpq_canonicalize(op) -- Remove common factors of the denominator and - numerator in OP. - -Copyright (C) 1991, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_canonicalize (MP_RAT *op) -#else -mpq_canonicalize (op) - MP_RAT *op; -#endif -{ - mpz_t gcd; - TMP_DECL (marker); - - TMP_MARK (marker); - - /* ??? Dunno if the 1+ is needed. */ - MPZ_TMP_INIT (gcd, 1 + MAX (ABS (op->_mp_num._mp_size), - ABS (op->_mp_den._mp_size))); - - mpz_gcd (gcd, &(op->_mp_num), &(op->_mp_den)); - mpz_divexact (&(op->_mp_num), &(op->_mp_num), gcd); - mpz_divexact (&(op->_mp_den), &(op->_mp_den), gcd); - - if (op->_mp_den._mp_size < 0) - { - op->_mp_num._mp_size = -op->_mp_num._mp_size; - op->_mp_den._mp_size = -op->_mp_den._mp_size; - } - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpq/clear.c b/gnu/lib/libgmp/mpq/clear.c deleted file mode 100644 index 2837cf2..0000000 --- a/gnu/lib/libgmp/mpq/clear.c +++ /dev/null @@ -1,37 +0,0 @@ -/* mpq_clear -- free the space occupied by a MP_RAT. - -Copyright (C) 1991, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_clear (MP_RAT *m) -#else -mpq_clear (m) - MP_RAT *m; -#endif -{ - (*_mp_free_func) (m->_mp_num._mp_d, - m->_mp_num._mp_alloc * BYTES_PER_MP_LIMB); - (*_mp_free_func) (m->_mp_den._mp_d, - m->_mp_den._mp_alloc * BYTES_PER_MP_LIMB); -} diff --git a/gnu/lib/libgmp/mpq/cmp.c b/gnu/lib/libgmp/mpq/cmp.c deleted file mode 100644 index fc530e3..0000000 --- a/gnu/lib/libgmp/mpq/cmp.c +++ /dev/null @@ -1,120 +0,0 @@ -/* mpq_cmp(u,v) -- Compare U, V. Return postive, zero, or negative - based on if U > V, U == V, or U < V. - -Copyright (C) 1991, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -int -#if __STDC__ -mpq_cmp (const MP_RAT *op1, const MP_RAT *op2) -#else -mpq_cmp (op1, op2) - const MP_RAT *op1; - const MP_RAT *op2; -#endif -{ - mp_size_t num1_size = op1->_mp_num._mp_size; - mp_size_t den1_size = op1->_mp_den._mp_size; - mp_size_t num2_size = op2->_mp_num._mp_size; - mp_size_t den2_size = op2->_mp_den._mp_size; - mp_size_t tmp1_size, tmp2_size; - mp_ptr tmp1_ptr, tmp2_ptr; - mp_size_t num1_sign; - int cc; - TMP_DECL (marker); - - if (num1_size == 0) - return -num2_size; - if (num2_size == 0) - return num1_size; - if ((num1_size ^ num2_size) < 0) /* I.e. are the signs different? */ - return num1_size; - - num1_sign = num1_size; - num1_size = ABS (num1_size); - num2_size = ABS (num2_size); - - tmp1_size = num1_size + den2_size; - tmp2_size = num2_size + den1_size; - - /* 1. Check to see if we can tell which operand is larger by just looking at - the number of limbs. */ - - /* NUM1 x DEN2 is either TMP1_SIZE limbs or TMP1_SIZE-1 limbs. - Same for NUM1 x DEN1 with respect to TMP2_SIZE. */ - if (tmp1_size > tmp2_size + 1) - /* NUM1 x DEN2 is surely larger in magnitude than NUM2 x DEN1. */ - return num1_sign; - if (tmp2_size > tmp1_size + 1) - /* NUM1 x DEN2 is surely smaller in magnitude than NUM2 x DEN1. */ - return -num1_sign; - - /* 2. Same, but compare the number of significant bits. */ - { - int cnt1, cnt2; - unsigned long int bits1, bits2; - - count_leading_zeros (cnt1, op1->_mp_num._mp_d[num1_size - 1]); - count_leading_zeros (cnt2, op2->_mp_den._mp_d[den2_size - 1]); - bits1 = tmp1_size * BITS_PER_MP_LIMB - cnt1 - cnt2; - - count_leading_zeros (cnt1, op2->_mp_num._mp_d[num2_size - 1]); - count_leading_zeros (cnt2, op1->_mp_den._mp_d[den1_size - 1]); - bits2 = tmp2_size * BITS_PER_MP_LIMB - cnt1 - cnt2; - - if (bits1 > bits2 + 1) - return num1_sign; - if (bits2 > bits1 + 1) - return -num1_sign; - } - - /* 3. Finally, cross multiply and compare. */ - - TMP_MARK (marker); - tmp1_ptr = (mp_ptr) TMP_ALLOC (tmp1_size * BYTES_PER_MP_LIMB); - tmp2_ptr = (mp_ptr) TMP_ALLOC (tmp2_size * BYTES_PER_MP_LIMB); - - if (num1_size >= den2_size) - tmp1_size -= 0 == mpn_mul (tmp1_ptr, - op1->_mp_num._mp_d, num1_size, - op2->_mp_den._mp_d, den2_size); - else - tmp1_size -= 0 == mpn_mul (tmp1_ptr, - op2->_mp_den._mp_d, den2_size, - op1->_mp_num._mp_d, num1_size); - - if (num2_size >= den1_size) - tmp2_size -= 0 == mpn_mul (tmp2_ptr, - op2->_mp_num._mp_d, num2_size, - op1->_mp_den._mp_d, den1_size); - else - tmp2_size -= 0 == mpn_mul (tmp2_ptr, - op1->_mp_den._mp_d, den1_size, - op2->_mp_num._mp_d, num2_size); - - - cc = tmp1_size - tmp2_size != 0 - ? tmp1_size - tmp2_size : mpn_cmp (tmp1_ptr, tmp2_ptr, tmp1_size); - TMP_FREE (marker); - return num1_sign < 0 ? -cc : cc; -} diff --git a/gnu/lib/libgmp/mpq/cmp_ui.c b/gnu/lib/libgmp/mpq/cmp_ui.c deleted file mode 100644 index bdecec5..0000000 --- a/gnu/lib/libgmp/mpq/cmp_ui.c +++ /dev/null @@ -1,84 +0,0 @@ -/* mpq_cmp_ui(u,vn,vd) -- Compare U with Vn/Vd. Return positive, zero, or - negative based on if U > V, U == V, or U < V. Vn and Vd may have - common factors. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -/* gmp.h defines a macro for mpq_cmp_ui. */ -#undef mpq_cmp_ui - -int -#if __STDC__ -mpq_cmp_ui (const MP_RAT *op1, unsigned long int num2, unsigned long int den2) -#else -mpq_cmp_ui (op1, num2, den2) - const MP_RAT *op1; - unsigned long int num2; - unsigned long int den2; -#endif -{ - mp_size_t num1_size = op1->_mp_num._mp_size; - mp_size_t den1_size = op1->_mp_den._mp_size; - mp_size_t tmp1_size, tmp2_size; - mp_ptr tmp1_ptr, tmp2_ptr; - mp_size_t num1_sign; - mp_limb_t cy_limb; - int cc; - TMP_DECL (marker); - - if (num1_size == 0) - return -(num2 != 0); - if (num1_size < 0) - return num1_size; - if (num2 == 0) - return num1_size; - - num1_sign = num1_size; - num1_size = ABS (num1_size); - - /* NUM1 x DEN2 is either TMP1_SIZE limbs or TMP1_SIZE-1 limbs. - Same for NUM1 x DEN1 with respect to TMP2_SIZE. */ - if (num1_size > den1_size + 1) - /* NUM1 x DEN2 is surely larger in magnitude than NUM2 x DEN1. */ - return num1_sign; - if (den1_size > num1_sign + 1) - /* NUM1 x DEN2 is surely smaller in magnitude than NUM2 x DEN1. */ - return -num1_sign; - - TMP_MARK (marker); - tmp1_ptr = (mp_ptr) TMP_ALLOC ((num1_size + 1) * BYTES_PER_MP_LIMB); - tmp2_ptr = (mp_ptr) TMP_ALLOC ((den1_size + 1) * BYTES_PER_MP_LIMB); - - cy_limb = mpn_mul_1 (tmp1_ptr, op1->_mp_num._mp_d, num1_size, den2); - tmp1_ptr[num1_size] = cy_limb; - tmp1_size = num1_size + (cy_limb != 0); - - cy_limb = mpn_mul_1 (tmp2_ptr, op1->_mp_den._mp_d, den1_size, num2); - tmp2_ptr[den1_size] = cy_limb; - tmp2_size = den1_size + (cy_limb != 0); - - cc = tmp1_size - tmp2_size != 0 - ? tmp1_size - tmp2_size : mpn_cmp (tmp1_ptr, tmp2_ptr, tmp1_size); - TMP_FREE (marker); - return (num1_sign < 0) ? -cc : cc; -} diff --git a/gnu/lib/libgmp/mpq/configure.in b/gnu/lib/libgmp/mpq/configure.in deleted file mode 100644 index b5d501c..0000000 --- a/gnu/lib/libgmp/mpq/configure.in +++ /dev/null @@ -1,12 +0,0 @@ -# This file is a shell script fragment that supplies the information -# necessary for a configure script to process the program in -# this directory. For more information, look at ../configure. - -configdirs=tests -srctrigger=cmp_ui.c -srcname="GNU Multi-Precision library/mpq" - -# per-host: - -# per-target: - diff --git a/gnu/lib/libgmp/mpq/div.c b/gnu/lib/libgmp/mpq/div.c deleted file mode 100644 index cd1f3881..0000000 --- a/gnu/lib/libgmp/mpq/div.c +++ /dev/null @@ -1,93 +0,0 @@ -/* mpq_div -- divide two rational numbers. - -Copyright (C) 1991, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_div (mpq_ptr quot, mpq_srcptr op1, mpq_srcptr op2) -#else -mpq_div (quot, op1, op2) - mpq_ptr quot; - mpq_srcptr op1; - mpq_srcptr op2; -#endif -{ - mpz_t gcd1, gcd2; - mpz_t tmp1, tmp2; - mpz_t numtmp; - - mpz_init (gcd1); - mpz_init (gcd2); - mpz_init (tmp1); - mpz_init (tmp2); - mpz_init (numtmp); - - /* QUOT might be identical to either operand, so don't store the - result there until we are finished with the input operands. We - dare to overwrite the numerator of QUOT when we are finished - with the numerators of OP1 and OP2. */ - - mpz_gcd (gcd1, &(op1->_mp_num), &(op2->_mp_num)); - mpz_gcd (gcd2, &(op2->_mp_den), &(op1->_mp_den)); - - if (gcd1->_mp_size > 1 || gcd1->_mp_d[0] != 1) - mpz_divexact (tmp1, &(op1->_mp_num), gcd1); - else - mpz_set (tmp1, &(op1->_mp_num)); - - if (gcd2->_mp_size > 1 || gcd2->_mp_d[0] != 1) - mpz_divexact (tmp2, &(op2->_mp_den), gcd2); - else - mpz_set (tmp2, &(op2->_mp_den)); - - mpz_mul (numtmp, tmp1, tmp2); - - if (gcd1->_mp_size > 1 || gcd1->_mp_d[0] != 1) - mpz_divexact (tmp1, &(op2->_mp_num), gcd1); - else - mpz_set (tmp1, &(op2->_mp_num)); - - if (gcd2->_mp_size > 1 || gcd2->_mp_d[0] != 1) - mpz_divexact (tmp2, &(op1->_mp_den), gcd2); - else - mpz_set (tmp2, &(op1->_mp_den)); - - mpz_mul (&(quot->_mp_den), tmp1, tmp2); - - /* We needed to go via NUMTMP to take care of QUOT being the same - as either input operands. Now move NUMTMP to QUOT->_mp_num. */ - mpz_set (&(quot->_mp_num), numtmp); - - /* Keep the denominator positive. */ - if (quot->_mp_den._mp_size < 0) - { - quot->_mp_den._mp_size = -quot->_mp_den._mp_size; - quot->_mp_num._mp_size = -quot->_mp_num._mp_size; - } - - mpz_clear (numtmp); - mpz_clear (tmp2); - mpz_clear (tmp1); - mpz_clear (gcd2); - mpz_clear (gcd1); -} diff --git a/gnu/lib/libgmp/mpq/equal.c b/gnu/lib/libgmp/mpq/equal.c deleted file mode 100644 index 2b4bb5b..0000000 --- a/gnu/lib/libgmp/mpq/equal.c +++ /dev/null @@ -1,43 +0,0 @@ -/* mpq_equal(u,v) -- Compare U, V. Return non-zero if they are equal, zero - if they are non-equal. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -int -#if __STDC__ -mpq_equal (mpq_srcptr op1, mpq_srcptr op2) -#else -mpq_equal (op1, op2) - mpq_srcptr op1; - mpq_srcptr op2; -#endif -{ - mp_size_t num1_size = op1->_mp_num._mp_size; - mp_size_t den1_size = op1->_mp_den._mp_size; - mp_size_t num2_size = op2->_mp_num._mp_size; - mp_size_t den2_size = op2->_mp_den._mp_size; - - return (num1_size == num2_size && den1_size == den2_size - && mpn_cmp (op1->_mp_num._mp_d, op2->_mp_num._mp_d, num1_size) == 0 - && mpn_cmp (op1->_mp_den._mp_d, op2->_mp_den._mp_d, den1_size) == 0); -} diff --git a/gnu/lib/libgmp/mpq/get_d.c b/gnu/lib/libgmp/mpq/get_d.c deleted file mode 100644 index cb4e800..0000000 --- a/gnu/lib/libgmp/mpq/get_d.c +++ /dev/null @@ -1,151 +0,0 @@ -/* double mpq_get_d (mpq_t src) -- Return the double approximation to SRC. - -Copyright (C) 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -/* Algorithm: - 1. Develop >= n bits of src.num / src.den, where n is the number of bits - in a double. This (partial) division will use all bits from the - denominator. - 2. Use the remainder to determine how to round the result. - 3. Assign the integral result to a temporary double. - 4. Scale the temporary double, and return the result. - - An alternative algorithm, that would be faster: - 0. Let n be somewhat larger than the number of significant bits in a double. - 1. Extract the most significant n bits of the denominator, and an equal - number of bits from the numerator. - 2. Interpret the extracted numbers as integers, call them a and b - respectively, and develop n bits of the fractions ((a + 1) / b) and - (a / (b + 1)) using mpn_divrem. - 3. If the computed values are identical UP TO THE POSITION WE CARE ABOUT, - we are done. If they are different, repeat the algorithm from step 1, - but first let n = n * 2. - 4. If we end up using all bits from the numerator and denominator, fall - back to the first algorithm above. - 5. Just to make life harder, The computation of a + 1 and b + 1 above - might give carry-out... Needs special handling. It might work to - subtract 1 in both cases instead. -*/ - -double -#if __STDC__ -mpq_get_d (const MP_RAT *src) -#else -mpq_get_d (src) - const MP_RAT *src; -#endif -{ - mp_ptr np, dp; - mp_ptr rp; - mp_size_t nsize = src->_mp_num._mp_size; - mp_size_t dsize = src->_mp_den._mp_size; - mp_size_t qsize, rsize; - mp_size_t sign_quotient = nsize ^ dsize; - unsigned normalization_steps; - mp_limb_t qlimb; -#define N_QLIMBS (1 + (sizeof (double) + BYTES_PER_MP_LIMB-1) / BYTES_PER_MP_LIMB) - mp_limb_t qp[N_QLIMBS + 1]; - TMP_DECL (marker); - - if (nsize == 0) - return 0.0; - - TMP_MARK (marker); - nsize = ABS (nsize); - dsize = ABS (dsize); - np = src->_mp_num._mp_d; - dp = src->_mp_den._mp_d; - - rsize = dsize + N_QLIMBS; - rp = (mp_ptr) TMP_ALLOC ((rsize + 1) * BYTES_PER_MP_LIMB); - - count_leading_zeros (normalization_steps, dp[dsize - 1]); - - /* Normalize the denominator, i.e. make its most significant bit set by - shifting it NORMALIZATION_STEPS bits to the left. Also shift the - numerator the same number of steps (to keep the quotient the same!). */ - if (normalization_steps != 0) - { - mp_ptr tp; - mp_limb_t nlimb; - - /* Shift up the denominator setting the most significant bit of - the most significant limb. Use temporary storage not to clobber - the original contents of the denominator. */ - tp = (mp_ptr) TMP_ALLOC (dsize * BYTES_PER_MP_LIMB); - mpn_lshift (tp, dp, dsize, normalization_steps); - dp = tp; - - if (rsize > nsize) - { - MPN_ZERO (rp, rsize - nsize); - nlimb = mpn_lshift (rp + (rsize - nsize), - np, nsize, normalization_steps); - } - else - { - nlimb = mpn_lshift (rp, np + (nsize - rsize), - rsize, normalization_steps); - } - if (nlimb != 0) - { - rp[rsize] = nlimb; - rsize++; - } - } - else - { - if (rsize > nsize) - { - MPN_ZERO (rp, rsize - nsize); - MPN_COPY (rp + (rsize - nsize), np, nsize); - } - else - { - MPN_COPY (rp, np + (nsize - rsize), rsize); - } - } - - qlimb = mpn_divmod (qp, rp, rsize, dp, dsize); - qsize = rsize - dsize; - if (qlimb) - { - qp[qsize] = qlimb; - qsize++; - } - - { - double res; - mp_size_t i; - - res = qp[qsize - 1]; - for (i = qsize - 2; i >= 0; i--) - res = res * MP_BASE_AS_DOUBLE + qp[i]; - - res = __gmp_scale2 (res, BITS_PER_MP_LIMB * (nsize - dsize - N_QLIMBS)); - - TMP_FREE (marker); - return sign_quotient >= 0 ? res : -res; - } -} diff --git a/gnu/lib/libgmp/mpq/get_den.c b/gnu/lib/libgmp/mpq/get_den.c deleted file mode 100644 index fc5e387..0000000 --- a/gnu/lib/libgmp/mpq/get_den.c +++ /dev/null @@ -1,41 +0,0 @@ -/* mpq_get_den(den,rat_src) -- Set DEN to the denominator of RAT_SRC. - -Copyright (C) 1991, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_get_den (MP_INT *den, const MP_RAT *src) -#else -mpq_get_den (den, src) - MP_INT *den; - const MP_RAT *src; -#endif -{ - mp_size_t size = src->_mp_den._mp_size; - - if (den->_mp_alloc < size) - _mpz_realloc (den, size); - - MPN_COPY (den->_mp_d, src->_mp_den._mp_d, size); - den->_mp_size = size; -} diff --git a/gnu/lib/libgmp/mpq/get_num.c b/gnu/lib/libgmp/mpq/get_num.c deleted file mode 100644 index 61f812f..0000000 --- a/gnu/lib/libgmp/mpq/get_num.c +++ /dev/null @@ -1,42 +0,0 @@ - /* mpq_get_num(num,rat_src) -- Set NUM to the numerator of RAT_SRC. - -Copyright (C) 1991, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_get_num (MP_INT *num, const MP_RAT *src) -#else -mpq_get_num (num, src) - MP_INT *num; - const MP_RAT *src; -#endif -{ - mp_size_t size = src->_mp_num._mp_size; - mp_size_t abs_size = ABS (size); - - if (num->_mp_alloc < abs_size) - _mpz_realloc (num, abs_size); - - MPN_COPY (num->_mp_d, src->_mp_num._mp_d, abs_size); - num->_mp_size = size; -} diff --git a/gnu/lib/libgmp/mpq/init.c b/gnu/lib/libgmp/mpq/init.c deleted file mode 100644 index ae6d8b3..0000000 --- a/gnu/lib/libgmp/mpq/init.c +++ /dev/null @@ -1,40 +0,0 @@ -/* mpq_init -- Make a new rational number with value 0/1. - -Copyright (C) 1991, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_init (MP_RAT *x) -#else -mpq_init (x) - MP_RAT *x; -#endif -{ - x->_mp_num._mp_alloc = 1; - x->_mp_num._mp_d = (mp_ptr) (*_mp_allocate_func) (BYTES_PER_MP_LIMB); - x->_mp_num._mp_size = 0; - x->_mp_den._mp_alloc = 1; - x->_mp_den._mp_d = (mp_ptr) (*_mp_allocate_func) (BYTES_PER_MP_LIMB); - x->_mp_den._mp_d[0] = 1; - x->_mp_den._mp_size = 1; -} diff --git a/gnu/lib/libgmp/mpq/inv.c b/gnu/lib/libgmp/mpq/inv.c deleted file mode 100644 index 745c78d..0000000 --- a/gnu/lib/libgmp/mpq/inv.c +++ /dev/null @@ -1,75 +0,0 @@ -/* mpq_inv(dest,src) -- invert a rational number, i.e. set DEST to SRC - with the numerator and denominator swapped. - -Copyright (C) 1991, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_inv (MP_RAT *dest, const MP_RAT *src) -#else -mpq_inv (dest, src) - MP_RAT *dest; - const MP_RAT *src; -#endif -{ - mp_size_t num_size = src->_mp_num._mp_size; - mp_size_t den_size = src->_mp_den._mp_size; - - if (num_size == 0) - num_size = 1 / num_size; /* Divide by zero! */ - - if (num_size < 0) - { - num_size = -num_size; - den_size = -den_size; - } - dest->_mp_den._mp_size = num_size; - dest->_mp_num._mp_size = den_size; - - /* If dest == src we may just swap the numerator and denominator, but - we have to ensure the new denominator is positive. */ - - if (dest == src) - { - mp_size_t alloc = dest->_mp_num._mp_alloc; - mp_ptr limb_ptr = dest->_mp_num._mp_d; - - dest->_mp_num._mp_alloc = dest->_mp_den._mp_alloc; - dest->_mp_num._mp_d = dest->_mp_den._mp_d; - - dest->_mp_den._mp_alloc = alloc; - dest->_mp_den._mp_d = limb_ptr; - } - else - { - den_size = ABS (den_size); - if (dest->_mp_num._mp_alloc < den_size) - _mpz_realloc (&(dest->_mp_num), den_size); - - if (dest->_mp_den._mp_alloc < num_size) - _mpz_realloc (&(dest->_mp_den), num_size); - - MPN_COPY (dest->_mp_num._mp_d, src->_mp_den._mp_d, den_size); - MPN_COPY (dest->_mp_den._mp_d, src->_mp_num._mp_d, num_size); - } -} diff --git a/gnu/lib/libgmp/mpq/mul.c b/gnu/lib/libgmp/mpq/mul.c deleted file mode 100644 index 35f960c..0000000 --- a/gnu/lib/libgmp/mpq/mul.c +++ /dev/null @@ -1,79 +0,0 @@ -/* mpq_mul -- mutiply two rational numbers. - -Copyright (C) 1991, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_mul (mpq_ptr prod, mpq_srcptr op1, mpq_srcptr op2) -#else -mpq_mul (prod, op1, op2) - mpq_ptr prod; - mpq_srcptr op1; - mpq_srcptr op2; -#endif -{ - mpz_t gcd1, gcd2; - mpz_t tmp1, tmp2; - - mpz_init (gcd1); - mpz_init (gcd2); - mpz_init (tmp1); - mpz_init (tmp2); - - /* PROD might be identical to either operand, so don't store the - result there until we are finished with the input operands. We - dare to overwrite the numerator of PROD when we are finished - with the numerators of OP1 and OP2. */ - - mpz_gcd (gcd1, &(op1->_mp_num), &(op2->_mp_den)); - mpz_gcd (gcd2, &(op2->_mp_num), &(op1->_mp_den)); - - if (gcd1->_mp_size > 1 || gcd1->_mp_d[0] != 1) - mpz_divexact (tmp1, &(op1->_mp_num), gcd1); - else - mpz_set (tmp1, &(op1->_mp_num)); - - if (gcd2->_mp_size > 1 || gcd2->_mp_d[0] != 1) - mpz_divexact (tmp2, &(op2->_mp_num), gcd2); - else - mpz_set (tmp2, &(op2->_mp_num)); - - mpz_mul (&(prod->_mp_num), tmp1, tmp2); - - if (gcd1->_mp_size > 1 || gcd1->_mp_d[0] != 1) - mpz_divexact (tmp1, &(op2->_mp_den), gcd1); - else - mpz_set (tmp1, &(op2->_mp_den)); - - if (gcd2->_mp_size > 1 || gcd2->_mp_d[0] != 1) - mpz_divexact (tmp2, &(op1->_mp_den), gcd2); - else - mpz_set (tmp2, &(op1->_mp_den)); - - mpz_mul (&(prod->_mp_den), tmp1, tmp2); - - mpz_clear (tmp2); - mpz_clear (tmp1); - mpz_clear (gcd2); - mpz_clear (gcd1); -} diff --git a/gnu/lib/libgmp/mpq/neg.c b/gnu/lib/libgmp/mpq/neg.c deleted file mode 100644 index ac54d27..0000000 --- a/gnu/lib/libgmp/mpq/neg.c +++ /dev/null @@ -1,36 +0,0 @@ -/* mpq_neg(dst, src) -- Assign the negated value of SRC to DST. - -Copyright (C) 1991, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_neg (MP_RAT *dst, const MP_RAT *src) -#else -mpq_neg (dst, src) - MP_RAT *dst; - const MP_RAT *src; -#endif -{ - mpz_neg (&dst->_mp_num, &src->_mp_num); - mpz_set (&dst->_mp_den, &src->_mp_den); -} diff --git a/gnu/lib/libgmp/mpq/set.c b/gnu/lib/libgmp/mpq/set.c deleted file mode 100644 index ef85639..0000000 --- a/gnu/lib/libgmp/mpq/set.c +++ /dev/null @@ -1,49 +0,0 @@ -/* mpq_set(dest,src) -- Set DEST to SRC. - -Copyright (C) 1991, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_set (MP_RAT *dest, const MP_RAT *src) -#else -mpq_set (dest, src) - MP_RAT *dest; - const MP_RAT *src; -#endif -{ - mp_size_t num_size, den_size; - mp_size_t abs_num_size; - - num_size = src->_mp_num._mp_size; - abs_num_size = ABS (num_size); - if (dest->_mp_num._mp_alloc < abs_num_size) - _mpz_realloc (&(dest->_mp_num), abs_num_size); - MPN_COPY (dest->_mp_num._mp_d, src->_mp_num._mp_d, abs_num_size); - dest->_mp_num._mp_size = num_size; - - den_size = src->_mp_den._mp_size; - if (dest->_mp_den._mp_alloc < den_size) - _mpz_realloc (&(dest->_mp_den), den_size); - MPN_COPY (dest->_mp_den._mp_d, src->_mp_den._mp_d, den_size); - dest->_mp_den._mp_size = den_size; -} diff --git a/gnu/lib/libgmp/mpq/set_den.c b/gnu/lib/libgmp/mpq/set_den.c deleted file mode 100644 index 4586c89..0000000 --- a/gnu/lib/libgmp/mpq/set_den.c +++ /dev/null @@ -1,42 +0,0 @@ -/* mpq_set_den(dest,den) -- Set the denominator of DEST from DEN. - -Copyright (C) 1991, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_set_den (MP_RAT *dest, const MP_INT *den) -#else -mpq_set_den (dest, den) - MP_RAT *dest; - const MP_INT *den; -#endif -{ - mp_size_t size = den->_mp_size; - mp_size_t abs_size = ABS (size); - - if (dest->_mp_den._mp_alloc < abs_size) - _mpz_realloc (&(dest->_mp_den), abs_size); - - MPN_COPY (dest->_mp_den._mp_d, den->_mp_d, abs_size); - dest->_mp_den._mp_size = abs_size; -} diff --git a/gnu/lib/libgmp/mpq/set_num.c b/gnu/lib/libgmp/mpq/set_num.c deleted file mode 100644 index ce918ce..0000000 --- a/gnu/lib/libgmp/mpq/set_num.c +++ /dev/null @@ -1,42 +0,0 @@ -/* mpq_set_num(dest,num) -- Set the numerator of DEST from NUM. - -Copyright (C) 1991, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_set_num (MP_RAT *dest, const MP_INT *num) -#else -mpq_set_num (dest, num) - MP_RAT *dest; - const MP_INT *num; -#endif -{ - mp_size_t size = num->_mp_size; - mp_size_t abs_size = ABS (size); - - if (dest->_mp_num._mp_alloc < abs_size) - _mpz_realloc (&(dest->_mp_num), abs_size); - - MPN_COPY (dest->_mp_num._mp_d, num->_mp_d, abs_size); - dest->_mp_num._mp_size = size; -} diff --git a/gnu/lib/libgmp/mpq/set_si.c b/gnu/lib/libgmp/mpq/set_si.c deleted file mode 100644 index cf1f9f0..0000000 --- a/gnu/lib/libgmp/mpq/set_si.c +++ /dev/null @@ -1,54 +0,0 @@ -/* mpq_set_si(dest,ulong_num,ulong_den) -- Set DEST to the retional number - ULONG_NUM/ULONG_DEN. - -Copyright (C) 1991, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_set_si (MP_RAT *dest, signed long int num, unsigned long int den) -#else -mpq_set_si (dest, num, den) - MP_RAT *dest; - signed long int num; - unsigned long int den; -#endif -{ - unsigned long int abs_num; - - abs_num = ABS (num); - - if (num == 0) - { - /* Canonicalize 0/d to 0/1. */ - den = 1; - dest->_mp_num._mp_size = 0; - } - else - { - dest->_mp_num._mp_d[0] = abs_num; - dest->_mp_num._mp_size = num > 0 ? 1 : -1; - } - - dest->_mp_den._mp_d[0] = den; - dest->_mp_den._mp_size = 1; -} diff --git a/gnu/lib/libgmp/mpq/set_ui.c b/gnu/lib/libgmp/mpq/set_ui.c deleted file mode 100644 index aaa9fc2..0000000 --- a/gnu/lib/libgmp/mpq/set_ui.c +++ /dev/null @@ -1,50 +0,0 @@ -/* mpq_set_ui(dest,ulong_num,ulong_den) -- Set DEST to the retional number - ULONG_NUM/ULONG_DEN. - -Copyright (C) 1991, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_set_ui (MP_RAT *dest, unsigned long int num, unsigned long int den) -#else -mpq_set_ui (dest, num, den) - MP_RAT *dest; - unsigned long int num; - unsigned long int den; -#endif -{ - if (num == 0) - { - /* Canonicalize 0/n to 0/1. */ - den = 1; - dest->_mp_num._mp_size = 0; - } - else - { - dest->_mp_num._mp_d[0] = num; - dest->_mp_num._mp_size = 1; - } - - dest->_mp_den._mp_d[0] = den; - dest->_mp_den._mp_size = 1; -} diff --git a/gnu/lib/libgmp/mpq/set_z.c b/gnu/lib/libgmp/mpq/set_z.c deleted file mode 100644 index ca638f3..0000000 --- a/gnu/lib/libgmp/mpq/set_z.c +++ /dev/null @@ -1,46 +0,0 @@ -/* mpq_set_z (dest,src) -- Set DEST to SRC. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_set_z (mpq_ptr dest, mpz_srcptr src) -#else -mpq_set_z (dest, src) - mpq_ptr dest; - mpz_srcptr src; -#endif -{ - mp_size_t num_size; - mp_size_t abs_num_size; - - num_size = src->_mp_size; - abs_num_size = ABS (num_size); - if (dest->_mp_num._mp_alloc < abs_num_size) - _mpz_realloc (&(dest->_mp_num), abs_num_size); - MPN_COPY (dest->_mp_num._mp_d, src->_mp_d, abs_num_size); - dest->_mp_num._mp_size = num_size; - - dest->_mp_den._mp_d[0] = 1; - dest->_mp_den._mp_size = 1; -} diff --git a/gnu/lib/libgmp/mpq/sub.c b/gnu/lib/libgmp/mpq/sub.c deleted file mode 100644 index 9274ff8..0000000 --- a/gnu/lib/libgmp/mpq/sub.c +++ /dev/null @@ -1,85 +0,0 @@ -/* mpq_sub -- subtract two rational numbers. - -Copyright (C) 1991, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpq_sub (mpq_ptr rop, mpq_srcptr op1, mpq_srcptr op2) -#else -mpq_sub (rop, op1, op2) - mpq_ptr rop; - mpq_srcptr op1; - mpq_srcptr op2; -#endif -{ - mpz_t gcd; - mpz_t tmp1, tmp2; - mp_size_t op1_num_size = ABS (op1->_mp_num._mp_size); - mp_size_t op1_den_size = ABS (op1->_mp_den._mp_size); - mp_size_t op2_num_size = ABS (op2->_mp_num._mp_size); - mp_size_t op2_den_size = ABS (op2->_mp_den._mp_size); - TMP_DECL (marker); - - TMP_MARK (marker); - MPZ_TMP_INIT (gcd, MIN (op1_den_size, op2_den_size)); - MPZ_TMP_INIT (tmp1, op1_num_size + op2_den_size); - MPZ_TMP_INIT (tmp2, op2_num_size + op1_den_size); - - /* ROP might be identical to either operand, so don't store the - result there until we are finished with the input operands. We - dare to overwrite the numerator of ROP when we are finished - with the numerators of OP1 and OP2. */ - - mpz_gcd (gcd, &(op1->_mp_den), &(op2->_mp_den)); - if (gcd->_mp_size > 1 || gcd->_mp_d[0] != 1) - { - mpz_t t; - - mpz_divexact (tmp1, &(op2->_mp_den), gcd); - mpz_mul (tmp1, &(op1->_mp_num), tmp1); - - mpz_divexact (tmp2, &(op1->_mp_den), gcd); - mpz_mul (tmp2, &(op2->_mp_num), tmp2); - - MPZ_TMP_INIT (t, MAX (ABS (tmp1->_mp_size), ABS (tmp2->_mp_size)) + 1); - - mpz_sub (t, tmp1, tmp2); - mpz_divexact (tmp1, &(op1->_mp_den), gcd); - mpz_gcd (gcd, t, gcd); - - mpz_divexact (&(rop->_mp_num), t, gcd); - - mpz_divexact (tmp2, &(op2->_mp_den), gcd); - mpz_mul (&(rop->_mp_den), tmp1, tmp2); - } - else - { - /* The common divisor is 1. This is the case (for random input) with - probability 6/(pi**2). */ - mpz_mul (tmp1, &(op1->_mp_num), &(op2->_mp_den)); - mpz_mul (tmp2, &(op2->_mp_num), &(op1->_mp_den)); - mpz_sub (&(rop->_mp_num), tmp1, tmp2); - mpz_mul (&(rop->_mp_den), &(op1->_mp_den), &(op2->_mp_den)); - } - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpq/tests/Makefile.in b/gnu/lib/libgmp/mpq/tests/Makefile.in deleted file mode 100644 index d7921c0..0000000 --- a/gnu/lib/libgmp/mpq/tests/Makefile.in +++ /dev/null @@ -1,48 +0,0 @@ -# Makefile for mpq/tests for GNU MP - -srcdir = . - -CC = gcc - -TEST_LIBS = ../../libgmp.a -INCLUDES = -I../../mpn -I$(srcdir)/../.. -CFLAGS = -g -O - -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(XCFLAGS) $< - -TEST_SRCS = t-cmp.c t-cmp_ui.c t-get_d.c -TEST_OBJS = t-cmp.o t-cmp_ui.o t-get_d.o -TESTS = t-cmp t-cmp_ui t-get_d - -check: Makefile st-cmp st-cmp_ui st-get_d - @echo "The tests passed." - -st-cmp: t-cmp - ./t-cmp - touch $@ -st-cmp_ui: t-cmp_ui - ./t-cmp_ui - touch $@ -st-get_d: t-get_d - ./t-get_d - touch $@ - -t-cmp: t-cmp.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -t-cmp_ui: t-cmp_ui.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -t-get_d: t-get_d.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) - -t-cmp.o: $(srcdir)/t-cmp.c -t-cmp_ui.o: $(srcdir)/t-cmp_ui.c -t-get_d.o: $(srcdir)/t-get_d.c - -clean mostlyclean: - rm -f *.o st-* $(TESTS) -distclean maintainer-clean: clean - rm -f Makefile config.status - -Makefile: $(srcdir)/Makefile.in - $(SHELL) ./config.status diff --git a/gnu/lib/libgmp/mpq/tests/configure.in b/gnu/lib/libgmp/mpq/tests/configure.in deleted file mode 100644 index 5ee2138..0000000 --- a/gnu/lib/libgmp/mpq/tests/configure.in +++ /dev/null @@ -1,11 +0,0 @@ -# This file is a shell script that supplies the information necessary -# to tailor a template configure script into the configure script -# appropriate for this directory. For more information, check any -# existing configure script. - -srctrigger=t-cmp.c -srcname="gmp/mpq/tests" - -# per-host: - -# per-target: diff --git a/gnu/lib/libgmp/mpq/tests/t-cmp.c b/gnu/lib/libgmp/mpq/tests/t-cmp.c deleted file mode 100644 index 77e46f2..0000000 --- a/gnu/lib/libgmp/mpq/tests/t-cmp.c +++ /dev/null @@ -1,109 +0,0 @@ -/* Test mpq_cmp. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -#define NUM(x) (&((x)->_mp_num)) -#define DEN(x) (&((x)->_mp_den)) - -#define SGN(x) ((x) < 0 ? -1 : (x) > 0 ? 1 : 0) - -ref_mpq_cmp (a, b) - mpq_t a, b; -{ - mpz_t ai, bi; - int cc; - - mpz_init (ai); - mpz_init (bi); - - mpz_mul (ai, NUM (a), DEN (b)); - mpz_mul (bi, NUM (b), DEN (a)); - cc = mpz_cmp (ai, bi); - mpz_clear (ai); - mpz_clear (bi); - return cc; -} - -#ifndef SIZE -#define SIZE 8 /* increasing this lowers the probabilty of finding an error */ -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpq_t a, b; - mp_size_t size; - int reps = 100000; - int i; - int cc, ccref; - - if (argc == 2) - reps = atoi (argv[1]); - - mpq_init (a); - mpq_init (b); - - for (i = 0; i < reps; i++) - { - size = urandom () % SIZE - SIZE/2; - mpz_random2 (NUM (a), size); - do - { - size = urandom () % SIZE - SIZE/2; - mpz_random2 (DEN (a), size); - } - while (mpz_cmp_ui (DEN (a), 0) == 0); - - size = urandom () % SIZE - SIZE/2; - mpz_random2 (NUM (b), size); - do - { - size = urandom () % SIZE - SIZE/2; - mpz_random2 (DEN (b), size); - } - while (mpz_cmp_ui (DEN (b), 0) == 0); - - mpq_canonicalize (a); - mpq_canonicalize (b); - - ccref = ref_mpq_cmp (a, b); - cc = mpq_cmp (a, b); - - if (SGN (ccref) != SGN (cc)) - abort (); - } - - exit (0); -} - -dump (x) - mpq_t x; -{ - mpz_out_str (stdout, 10, NUM (x)); - printf ("/"); - mpz_out_str (stdout, 10, DEN (x)); - printf ("\n"); -} diff --git a/gnu/lib/libgmp/mpq/tests/t-cmp_ui.c b/gnu/lib/libgmp/mpq/tests/t-cmp_ui.c deleted file mode 100644 index f7b92ad..0000000 --- a/gnu/lib/libgmp/mpq/tests/t-cmp_ui.c +++ /dev/null @@ -1,102 +0,0 @@ -/* Test mpq_cmp_ui. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -#define NUM(x) (&((x)->_mp_num)) -#define DEN(x) (&((x)->_mp_den)) - -#define SGN(x) ((x) < 0 ? -1 : (x) > 0 ? 1 : 0) - -ref_mpq_cmp_ui (a, bn, bd) - mpq_t a; - unsigned long int bn, bd; -{ - mpz_t ai, bi; - int cc; - - mpz_init (ai); - mpz_init (bi); - - mpz_mul_ui (ai, NUM (a), bd); - mpz_mul_ui (bi, DEN (a), bn); - cc = mpz_cmp (ai, bi); - mpz_clear (ai); - mpz_clear (bi); - return cc; -} - -#ifndef SIZE -#define SIZE 8 /* increasing this lowers the probabilty of finding an error */ -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpq_t a, b; - mp_size_t size; - int reps = 100000; - int i; - int cc, ccref; - unsigned long int bn, bd; - - if (argc == 2) - reps = atoi (argv[1]); - - mpq_init (a); - mpq_init (b); - - for (i = 0; i < reps; i++) - { - size = urandom () % SIZE - SIZE/2; - mpz_random2 (NUM (a), size); - do - { - size = urandom () % SIZE - SIZE/2; - mpz_random2 (DEN (a), size); - } - while (mpz_cmp_ui (DEN (a), 0) == 0); - - mpz_random2 (NUM (b), 1); - do - { - mpz_random2 (DEN (b), 1); - } - while (mpz_cmp_ui (DEN (b), 0) == 0); - - mpq_canonicalize (a); - mpq_canonicalize (b); - - bn = mpz_get_ui (NUM (b)); - bd = mpz_get_ui (DEN (b)); - - ccref = ref_mpq_cmp_ui (a, bn, bd); - cc = mpq_cmp_ui (a, bn, bd); - - if (SGN (ccref) != SGN (cc)) - abort (); - } - - exit (0); -} diff --git a/gnu/lib/libgmp/mpq/tests/t-get_d.c b/gnu/lib/libgmp/mpq/tests/t-get_d.c deleted file mode 100644 index db4f926..0000000 --- a/gnu/lib/libgmp/mpq/tests/t-get_d.c +++ /dev/null @@ -1,88 +0,0 @@ -/* Test mpq_get_d - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -#ifndef SIZE -#define SIZE 8 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpq_t a; - mp_size_t size; - int reps = 10000; - int i, j; - double last_d, new_d; - mpz_t eps; - - if (argc == 2) - reps = atoi (argv[1]); - - /* The idea here is to test the monotonousness of mpq_get_d by adding - numbers to the numerator and denominator. */ - - mpq_init (a); - mpz_init (eps); - - for (i = 0; i < reps; i++) - { - size = urandom () % SIZE - SIZE/2; - mpz_random2 (mpq_numref (a), size); - do - { - size = urandom () % SIZE - SIZE/2; - mpz_random2 (mpq_denref (a), size); - } - while (mpz_cmp_ui (mpq_denref (a), 0) == 0); - - mpq_canonicalize (a); - - last_d = mpq_get_d (a); - for (j = 0; j < 10; j++) - { - size = urandom () % SIZE; - mpz_random2 (eps, size); - mpz_add (mpq_numref (a), mpq_numref (a), eps); - mpq_canonicalize (a); - new_d = mpq_get_d (a); - if (last_d > new_d) - abort (); - last_d = new_d; - } - } - - exit (0); -} - -dump (x) - mpq_t x; -{ - mpz_out_str (stdout, 10, mpq_numref (x)); - printf ("/"); - mpz_out_str (stdout, 10, mpq_denref (x)); - printf ("\n"); -} diff --git a/gnu/lib/libgmp/mpz/Makefile.in b/gnu/lib/libgmp/mpz/Makefile.in deleted file mode 100644 index 497f09c..0000000 --- a/gnu/lib/libgmp/mpz/Makefile.in +++ /dev/null @@ -1,180 +0,0 @@ -# Makefile for GNU MP/mpz functions -# Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -# the Free Software Foundation; either version 2 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 Library General Public -# License for more details. - -# You should have received a copy of the GNU Library General Public License -# along with the GNU MP Library; see the file COPYING.LIB. If not, write to -# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -# MA 02111-1307, USA. - -srcdir = . - -CC = gcc - -# If you cross compile on a machine with the same sizes of the integral -# types ("int", "long int", "short int", and "char") define this as the -# local compiler. Otherwise, you need to look for the uses of LOCAL_CC below, -# and handle those cases manually. -LOCAL_CC = $(CC) -CFLAGS = -g -O -AR = ar -AR_FLAGS = rc -SHELL = /bin/sh - -#### host and target specific makefile fragments come in here. -### - -MPZ_SRCS = init.c set.c set_ui.c set_si.c set_str.c set_d.c set_f.c set_q.c \ - iset.c iset_ui.c iset_si.c iset_str.c iset_d.c clear.c \ - get_ui.c get_si.c get_str.c get_d.c size.c sizeinbase.c \ - add.c add_ui.c sub.c sub_ui.c mul.c mul_ui.c \ - gcd.c gcd_ui.c gcdext.c sqrt.c sqrtrem.c powm.c powm_ui.c \ - cmp.c cmp_ui.c cmp_si.c mul_2exp.c fdiv_q_2exp.c fdiv_r_2exp.c \ - tdiv_q_2exp.c tdiv_r_2exp.c abs.c neg.c com.c and.c ior.c \ - inp_raw.c inp_str.c out_raw.c out_str.c \ - perfsqr.c random.c random2.c pow_ui.c ui_pow_ui.c setbit.c \ - clrbit.c fac_ui.c pprime_p.c realloc.c getlimbn.c popcount.c hamdist.c \ - cdiv_qr.c cdiv_q.c cdiv_r.c cdiv_qr_ui.c cdiv_q_ui.c cdiv_r_ui.c cdiv_ui.c \ - fdiv_qr.c fdiv_q.c fdiv_r.c fdiv_qr_ui.c fdiv_q_ui.c fdiv_r_ui.c fdiv_ui.c \ - tdiv_qr.c tdiv_q.c tdiv_r.c tdiv_qr_ui.c tdiv_q_ui.c tdiv_r_ui.c \ - mod.c divexact.c array_init.c scan0.c scan1.c \ - jacobi.c legendre.c invert.c -MPZ_OBJS = init.o set.o set_ui.o set_si.o set_str.o set_d.o set_f.o set_q.o \ - iset.o iset_ui.o iset_si.o iset_str.o iset_d.o clear.o \ - get_ui.o get_si.o get_str.o get_d.o size.o sizeinbase.o \ - add.o add_ui.o sub.o sub_ui.o mul.o mul_ui.o \ - gcd.o gcd_ui.o gcdext.o sqrt.o sqrtrem.o powm.o powm_ui.o \ - cmp.o cmp_ui.o cmp_si.o mul_2exp.o fdiv_q_2exp.o fdiv_r_2exp.o \ - tdiv_q_2exp.o tdiv_r_2exp.o abs.o neg.o com.o and.o ior.o \ - inp_raw.o inp_str.o out_raw.o out_str.o \ - perfsqr.o random.o random2.o pow_ui.o ui_pow_ui.o setbit.o \ - clrbit.o fac_ui.o pprime_p.o realloc.o getlimbn.o popcount.o hamdist.o \ - cdiv_qr.o cdiv_q.o cdiv_r.o cdiv_qr_ui.o cdiv_q_ui.o cdiv_r_ui.o cdiv_ui.o \ - fdiv_qr.o fdiv_q.o fdiv_r.o fdiv_qr_ui.o fdiv_q_ui.o fdiv_r_ui.o fdiv_ui.o \ - tdiv_qr.o tdiv_q.o tdiv_r.o tdiv_qr_ui.o tdiv_q_ui.o tdiv_r_ui.o \ - mod.o divexact.o array_init.o scan0.o scan1.o \ - jacobi.o legendre.o invert.o - -INCLUDES = -I. -I.. -I../mpn -I$(srcdir)/.. - -libmpz.a: Makefile $(MPZ_OBJS) - rm -f $@ - $(AR) $(AR_FLAGS) $@ $(MPZ_OBJS) - -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(XCFLAGS) $< - -clean mostlyclean: - rm -f *.o libmpz.a - -cd tests; $(MAKE) $@ -distclean maintainer-clean: clean - rm -f Makefile config.status - -cd tests; $(MAKE) $@ - -Makefile: $(srcdir)/Makefile.in - $(SHELL) ./config.status - -H = $(srcdir)/../gmp.h $(srcdir)/../gmp-impl.h ../mpn/gmp-mparam.h - -abs.o: $(srcdir)/abs.c $(H) -add.o: $(srcdir)/add.c $(H) -add_ui.o: $(srcdir)/add_ui.c $(H) -and.o: $(srcdir)/and.c $(H) -array_init.o: $(srcdir)/array_init.c $(H) -cdiv_q.o: $(srcdir)/cdiv_q.c $(H) -cdiv_q_ui.o: $(srcdir)/cdiv_q_ui.c $(H) -cdiv_qr.o: $(srcdir)/cdiv_qr.c $(H) -cdiv_qr_ui.o: $(srcdir)/cdiv_qr_ui.c $(H) -cdiv_r.o: $(srcdir)/cdiv_r.c $(H) -cdiv_r_ui.o: $(srcdir)/cdiv_r_ui.c $(H) -cdiv_ui.o: $(srcdir)/cdiv_ui.c $(H) -clear.o: $(srcdir)/clear.c $(H) -clrbit.o: $(srcdir)/clrbit.c $(H) -cmp.o: $(srcdir)/cmp.c $(H) -cmp_si.o: $(srcdir)/cmp_si.c $(H) -cmp_ui.o: $(srcdir)/cmp_ui.c $(H) -com.o: $(srcdir)/com.c $(H) -fdiv_q_2exp.o: $(srcdir)/fdiv_q_2exp.c $(H) -fdiv_r_2exp.o: $(srcdir)/fdiv_r_2exp.c $(H) -divexact.o: $(srcdir)/divexact.c $(H) $(srcdir)/../longlong.h -fac_ui.o: $(srcdir)/fac_ui.c $(H) $(srcdir)/../longlong.h -fdiv_q.o: $(srcdir)/fdiv_q.c $(H) -fdiv_q_ui.o: $(srcdir)/fdiv_q_ui.c $(H) -fdiv_qr.o: $(srcdir)/fdiv_qr.c $(H) -fdiv_qr_ui.o: $(srcdir)/fdiv_qr_ui.c $(H) -fdiv_r.o: $(srcdir)/fdiv_r.c $(H) -fdiv_r_ui.o: $(srcdir)/fdiv_r_ui.c $(H) -fdiv_ui.o: $(srcdir)/fdiv_ui.c $(H) -gcd.o: $(srcdir)/gcd.c $(H) $(srcdir)/../longlong.h -gcd_ui.o: $(srcdir)/gcd_ui.c $(H) -gcdext.o: $(srcdir)/gcdext.c $(H) -get_d.o: $(srcdir)/get_d.c $(H) -get_si.o: $(srcdir)/get_si.c $(H) -get_str.o: $(srcdir)/get_str.c $(H) -get_ui.o: $(srcdir)/get_ui.c $(H) -getlimbn.o: $(srcdir)/getlimbn.c $(H) -hamdist.o: $(srcdir)/hamdist.c $(H) -init.o: $(srcdir)/init.c $(H) -inp_raw.o: $(srcdir)/inp_raw.c $(H) -inp_str.o: $(srcdir)/inp_str.c $(H) -invert.o: $(srcdir)/invert.c $(H) -ior.o: $(srcdir)/ior.c $(H) -iset.o: $(srcdir)/iset.c $(H) -iset_d.o: $(srcdir)/iset_d.c $(H) -iset_si.o: $(srcdir)/iset_si.c $(H) -iset_str.o: $(srcdir)/iset_str.c $(H) -iset_ui.o: $(srcdir)/iset_ui.c $(H) -jacobi.o: $(srcdir)/jacobi.c $(H) -legendre.o: $(srcdir)/legendre.c $(H) -mod.o: $(srcdir)/mod.c $(H) -tdiv_q_2exp.o: $(srcdir)/tdiv_q_2exp.c $(H) -tdiv_r_2exp.o: $(srcdir)/tdiv_r_2exp.c $(H) -mul.o: $(srcdir)/mul.c $(H) -mul_2exp.o: $(srcdir)/mul_2exp.c $(H) -mul_ui.o: $(srcdir)/mul_ui.c $(H) -neg.o: $(srcdir)/neg.c $(H) -out_raw.o: $(srcdir)/out_raw.c $(H) -out_str.o: $(srcdir)/out_str.c $(H) -perfsqr.o: $(srcdir)/perfsqr.c $(H) -popcount.o: $(srcdir)/popcount.c $(H) -pow_ui.o: $(srcdir)/pow_ui.c $(H) $(srcdir)/../longlong.h -powm.o: $(srcdir)/powm.c $(H) $(srcdir)/../longlong.h -powm_ui.o: $(srcdir)/powm_ui.c $(H) $(srcdir)/../longlong.h -pprime_p.o: $(srcdir)/pprime_p.c $(H) -random.o: $(srcdir)/random.c $(H) $(srcdir)/../urandom.h -random2.o: $(srcdir)/random2.c $(H) -realloc.o: $(srcdir)/realloc.c $(H) -scan0.o: $(srcdir)/scan0.c $(H) -scan1.o: $(srcdir)/scan1.c $(H) -set.o: $(srcdir)/set.c $(H) -set_d.o: $(srcdir)/set_d.c $(H) -set_f.o: $(srcdir)/set_f.c $(H) -set_q.o: $(srcdir)/set_q.c $(H) -set_si.o: $(srcdir)/set_si.c $(H) -set_str.o: $(srcdir)/set_str.c $(H) $(srcdir)/../longlong.h -set_ui.o: $(srcdir)/set_ui.c $(H) -setbit.o: $(srcdir)/setbit.c $(H) -size.o: $(srcdir)/size.c $(H) -sizeinbase.o: $(srcdir)/sizeinbase.c $(H) $(srcdir)/../longlong.h -sqrt.o: $(srcdir)/sqrt.c $(H) -sqrtrem.o: $(srcdir)/sqrtrem.c $(H) -sub.o: $(srcdir)/sub.c $(H) -sub_ui.o: $(srcdir)/sub_ui.c $(H) -tdiv_q.o: $(srcdir)/tdiv_q.c $(H) $(srcdir)/../longlong.h -tdiv_q_ui.o: $(srcdir)/tdiv_q_ui.c $(H) -tdiv_qr.o: $(srcdir)/tdiv_qr.c $(H) $(srcdir)/../longlong.h $(srcdir)/dmincl.c $(H) -tdiv_qr_ui.o: $(srcdir)/tdiv_qr_ui.c $(H) -tdiv_r.o: $(srcdir)/tdiv_r.c $(H) $(srcdir)/../longlong.h $(srcdir)/dmincl.c $(H) -tdiv_r_ui.o: $(srcdir)/tdiv_r_ui.c $(H) -ui_pow_ui.o: $(srcdir)/ui_pow_ui.c $(H) $(srcdir)/../longlong.h diff --git a/gnu/lib/libgmp/mpz/abs.c b/gnu/lib/libgmp/mpz/abs.c deleted file mode 100644 index 080cac6..0000000 --- a/gnu/lib/libgmp/mpz/abs.c +++ /dev/null @@ -1,51 +0,0 @@ -/* mpz_abs(dst, src) -- Assign the absolute value of SRC to DST. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_abs (mpz_ptr w, mpz_srcptr u) -#else -mpz_abs (w, u) - mpz_ptr w; - mpz_srcptr u; -#endif -{ - mp_ptr wp, up; - mp_size_t size; - - size = ABS (u->_mp_size); - - if (u != w) - { - if (w->_mp_alloc < size) - _mpz_realloc (w, size); - - wp = w->_mp_d; - up = u->_mp_d; - - MPN_COPY (wp, up, size); - } - - w->_mp_size = size; -} diff --git a/gnu/lib/libgmp/mpz/add.c b/gnu/lib/libgmp/mpz/add.c deleted file mode 100644 index 10dd970..0000000 --- a/gnu/lib/libgmp/mpz/add.c +++ /dev/null @@ -1,120 +0,0 @@ -/* mpz_add -- Add two integers. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -#ifndef BERKELEY_MP -void -#if __STDC__ -mpz_add (mpz_ptr w, mpz_srcptr u, mpz_srcptr v) -#else -mpz_add (w, u, v) - mpz_ptr w; - mpz_srcptr u; - mpz_srcptr v; -#endif -#else /* BERKELEY_MP */ -void -#if __STDC__ -madd (mpz_srcptr u, mpz_srcptr v, mpz_ptr w) -#else -madd (u, v, w) - mpz_srcptr u; - mpz_srcptr v; - mpz_ptr w; -#endif -#endif /* BERKELEY_MP */ -{ - mp_srcptr up, vp; - mp_ptr wp; - mp_size_t usize, vsize, wsize; - mp_size_t abs_usize; - mp_size_t abs_vsize; - - usize = u->_mp_size; - vsize = v->_mp_size; - abs_usize = ABS (usize); - abs_vsize = ABS (vsize); - - if (abs_usize < abs_vsize) - { - /* Swap U and V. */ - {const __mpz_struct *t = u; u = v; v = t;} - {mp_size_t t = usize; usize = vsize; vsize = t;} - {mp_size_t t = abs_usize; abs_usize = abs_vsize; abs_vsize = t;} - } - - /* True: ABS_USIZE >= ABS_VSIZE. */ - - /* If not space for w (and possible carry), increase space. */ - wsize = abs_usize + 1; - if (w->_mp_alloc < wsize) - _mpz_realloc (w, wsize); - - /* These must be after realloc (u or v may be the same as w). */ - up = u->_mp_d; - vp = v->_mp_d; - wp = w->_mp_d; - - if ((usize ^ vsize) < 0) - { - /* U and V have different sign. Need to compare them to determine - which operand to subtract from which. */ - - /* This test is right since ABS_USIZE >= ABS_VSIZE. */ - if (abs_usize != abs_vsize) - { - mpn_sub (wp, up, abs_usize, vp, abs_vsize); - wsize = abs_usize; - MPN_NORMALIZE (wp, wsize); - if (usize < 0) - wsize = -wsize; - } - else if (mpn_cmp (up, vp, abs_usize) < 0) - { - mpn_sub_n (wp, vp, up, abs_usize); - wsize = abs_usize; - MPN_NORMALIZE (wp, wsize); - if (usize >= 0) - wsize = -wsize; - } - else - { - mpn_sub_n (wp, up, vp, abs_usize); - wsize = abs_usize; - MPN_NORMALIZE (wp, wsize); - if (usize < 0) - wsize = -wsize; - } - } - else - { - /* U and V have same sign. Add them. */ - mp_limb_t cy_limb = mpn_add (wp, up, abs_usize, vp, abs_vsize); - wp[abs_usize] = cy_limb; - wsize = abs_usize + cy_limb; - if (usize < 0) - wsize = -wsize; - } - - w->_mp_size = wsize; -} diff --git a/gnu/lib/libgmp/mpz/add_ui.c b/gnu/lib/libgmp/mpz/add_ui.c deleted file mode 100644 index a1e4306..0000000 --- a/gnu/lib/libgmp/mpz/add_ui.c +++ /dev/null @@ -1,84 +0,0 @@ -/* mpz_add_ui -- Add an mpz_t and an unsigned one-word integer. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_add_ui (mpz_ptr w, mpz_srcptr u, unsigned long int v) -#else -mpz_add_ui (w, u, v) - mpz_ptr w; - mpz_srcptr u; - unsigned long int v; -#endif -{ - mp_srcptr up; - mp_ptr wp; - mp_size_t usize, wsize; - mp_size_t abs_usize; - - usize = u->_mp_size; - abs_usize = ABS (usize); - - /* If not space for W (and possible carry), increase space. */ - wsize = abs_usize + 1; - if (w->_mp_alloc < wsize) - _mpz_realloc (w, wsize); - - /* These must be after realloc (U may be the same as W). */ - up = u->_mp_d; - wp = w->_mp_d; - - if (abs_usize == 0) - { - wp[0] = v; - w->_mp_size = v != 0; - return; - } - - if (usize >= 0) - { - mp_limb_t cy; - cy = mpn_add_1 (wp, up, abs_usize, v); - wp[abs_usize] = cy; - wsize = abs_usize + cy; - } - else - { - /* The signs are different. Need exact comparison to determine - which operand to subtract from which. */ - if (abs_usize == 1 && up[0] < v) - { - wp[0] = v - up[0]; - wsize = 1; - } - else - { - mpn_sub_1 (wp, up, abs_usize, v); - /* Size can decrease with at most one limb. */ - wsize = -(abs_usize - (wp[abs_usize - 1] == 0)); - } - } - - w->_mp_size = wsize; -} diff --git a/gnu/lib/libgmp/mpz/and.c b/gnu/lib/libgmp/mpz/and.c deleted file mode 100644 index 838d4b1..0000000 --- a/gnu/lib/libgmp/mpz/and.c +++ /dev/null @@ -1,278 +0,0 @@ -/* mpz_and -- Logical and. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_and (mpz_ptr res, mpz_srcptr op1, mpz_srcptr op2) -#else -mpz_and (res, op1, op2) - mpz_ptr res; - mpz_srcptr op1; - mpz_srcptr op2; -#endif -{ - mp_srcptr op1_ptr, op2_ptr; - mp_size_t op1_size, op2_size; - mp_ptr res_ptr; - mp_size_t res_size; - mp_size_t i; - TMP_DECL (marker); - - TMP_MARK (marker); - op1_size = op1->_mp_size; - op2_size = op2->_mp_size; - - op1_ptr = op1->_mp_d; - op2_ptr = op2->_mp_d; - res_ptr = res->_mp_d; - - if (op1_size >= 0) - { - if (op2_size >= 0) - { - res_size = MIN (op1_size, op2_size); - /* First loop finds the size of the result. */ - for (i = res_size - 1; i >= 0; i--) - if ((op1_ptr[i] & op2_ptr[i]) != 0) - break; - res_size = i + 1; - - /* Handle allocation, now then we know exactly how much space is - needed for the result. */ - if (res->_mp_alloc < res_size) - { - _mpz_realloc (res, res_size); - op1_ptr = op1->_mp_d; - op2_ptr = op2->_mp_d; - res_ptr = res->_mp_d; - } - - /* Second loop computes the real result. */ - for (i = res_size - 1; i >= 0; i--) - res_ptr[i] = op1_ptr[i] & op2_ptr[i]; - - res->_mp_size = res_size; - return; - } - else /* op2_size < 0 */ - { - /* Fall through to the code at the end of the function. */ - } - } - else - { - if (op2_size < 0) - { - mp_ptr opx; - mp_limb_t cy; - mp_size_t res_alloc; - - /* Both operands are negative, so will be the result. - -((-OP1) & (-OP2)) = -(~(OP1 - 1) & ~(OP2 - 1)) = - = ~(~(OP1 - 1) & ~(OP2 - 1)) + 1 = - = ((OP1 - 1) | (OP2 - 1)) + 1 */ - - /* It might seem as we could end up with an (invalid) result with - a leading zero-limb here when one of the operands is of the - type 1,,0,,..,,.0. But some analysis shows that we surely - would get carry into the zero-limb in this situation... */ - - op1_size = -op1_size; - op2_size = -op2_size; - - res_alloc = 1 + MAX (op1_size, op2_size); - - opx = (mp_ptr) TMP_ALLOC (op1_size * BYTES_PER_MP_LIMB); - mpn_sub_1 (opx, op1_ptr, op1_size, (mp_limb_t) 1); - op1_ptr = opx; - - opx = (mp_ptr) TMP_ALLOC (op2_size * BYTES_PER_MP_LIMB); - mpn_sub_1 (opx, op2_ptr, op2_size, (mp_limb_t) 1); - op2_ptr = opx; - - if (res->_mp_alloc < res_alloc) - { - _mpz_realloc (res, res_alloc); - res_ptr = res->_mp_d; - /* Don't re-read OP1_PTR and OP2_PTR. They point to - temporary space--never to the space RES->_mp_D used - to point to before reallocation. */ - } - - if (op1_size >= op2_size) - { - MPN_COPY (res_ptr + op2_size, op1_ptr + op2_size, - op1_size - op2_size); - for (i = op2_size - 1; i >= 0; i--) - res_ptr[i] = op1_ptr[i] | op2_ptr[i]; - res_size = op1_size; - } - else - { - MPN_COPY (res_ptr + op1_size, op2_ptr + op1_size, - op2_size - op1_size); - for (i = op1_size - 1; i >= 0; i--) - res_ptr[i] = op1_ptr[i] | op2_ptr[i]; - res_size = op2_size; - } - - cy = mpn_add_1 (res_ptr, res_ptr, res_size, (mp_limb_t) 1); - if (cy) - { - res_ptr[res_size] = cy; - res_size++; - } - - res->_mp_size = -res_size; - TMP_FREE (marker); - return; - } - else - { - /* We should compute -OP1 & OP2. Swap OP1 and OP2 and fall - through to the code that handles OP1 & -OP2. */ - {mpz_srcptr t = op1; op1 = op2; op2 = t;} - {mp_srcptr t = op1_ptr; op1_ptr = op2_ptr; op2_ptr = t;} - {mp_size_t t = op1_size; op1_size = op2_size; op2_size = t;} - } - - } - - { -#if ANDNEW - mp_size_t op2_lim; - mp_size_t count; - - /* OP2 must be negated as with infinite precision. - - Scan from the low end for a non-zero limb. The first non-zero - limb is simply negated (two's complement). Any subsequent - limbs are one's complemented. Of course, we don't need to - handle more limbs than there are limbs in the other, positive - operand as the result for those limbs is going to become zero - anyway. */ - - /* Scan for the least significant. non-zero OP2 limb, and zero the - result meanwhile for those limb positions. (We will surely - find a non-zero limb, so we can write the loop with one - termination condition only.) */ - for (i = 0; op2_ptr[i] == 0; i++) - res_ptr[i] = 0; - op2_lim = i; - - op2_size = -op2_size; - - if (op1_size <= op2_size) - { - /* The ones-extended OP2 is >= than the zero-extended OP1. - RES_SIZE <= OP1_SIZE. Find the exact size. */ - for (i = op1_size - 1; i > op2_lim; i--) - if ((op1_ptr[i] & ~op2_ptr[i]) != 0) - break; - res_size = i + 1; - for (i = res_size - 1; i > op2_lim; i--) - res_ptr[i] = op1_ptr[i] & ~op2_ptr[i]; - res_ptr[op2_lim] = op1_ptr[op2_lim] & -op2_ptr[op2_lim]; - /* Yes, this *can* happen! */ - MPN_NORMALIZE (res_ptr, res_size); - } - else - { - /* The ones-extended OP2 is < than the zero-extended OP1. - RES_SIZE == OP1_SIZE, since OP1 is normalized. */ - res_size = op1_size; - MPN_COPY (res_ptr + op2_size, op1_ptr + op2_size, op1_size - op2_size); - for (i = op2_size - 1; i > op2_lim; i--) - res_ptr[i] = op1_ptr[i] & ~op2_ptr[i]; - res_ptr[op2_lim] = op1_ptr[op2_lim] & -op2_ptr[op2_lim]; - } - - res->_mp_size = res_size; -#else - - /* OP1 is positive and zero-extended, - OP2 is negative and ones-extended. - The result will be positive. - OP1 & -OP2 = OP1 & ~(OP2 - 1). */ - - mp_ptr opx; - - op2_size = -op2_size; - opx = (mp_ptr) TMP_ALLOC (op2_size * BYTES_PER_MP_LIMB); - mpn_sub_1 (opx, op2_ptr, op2_size, (mp_limb_t) 1); - op2_ptr = opx; - - if (op1_size > op2_size) - { - /* The result has the same size as OP1, since OP1 is normalized - and longer than the ones-extended OP2. */ - res_size = op1_size; - - /* Handle allocation, now then we know exactly how much space is - needed for the result. */ - if (res->_mp_alloc < res_size) - { - _mpz_realloc (res, res_size); - res_ptr = res->_mp_d; - op1_ptr = op1->_mp_d; - /* Don't re-read OP2_PTR. It points to temporary space--never - to the space RES->_mp_D used to point to before reallocation. */ - } - - MPN_COPY (res_ptr + op2_size, op1_ptr + op2_size, - res_size - op2_size); - for (i = op2_size - 1; i >= 0; i--) - res_ptr[i] = op1_ptr[i] & ~op2_ptr[i]; - - res->_mp_size = res_size; - } - else - { - /* Find out the exact result size. Ignore the high limbs of OP2, - OP1 is zero-extended and would make the result zero. */ - for (i = op1_size - 1; i >= 0; i--) - if ((op1_ptr[i] & ~op2_ptr[i]) != 0) - break; - res_size = i + 1; - - /* Handle allocation, now then we know exactly how much space is - needed for the result. */ - if (res->_mp_alloc < res_size) - { - _mpz_realloc (res, res_size); - res_ptr = res->_mp_d; - op1_ptr = op1->_mp_d; - /* Don't re-read OP2_PTR. It points to temporary space--never - to the space RES->_mp_D used to point to before reallocation. */ - } - - for (i = res_size - 1; i >= 0; i--) - res_ptr[i] = op1_ptr[i] & ~op2_ptr[i]; - - res->_mp_size = res_size; - } -#endif - } - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/array_init.c b/gnu/lib/libgmp/mpz/array_init.c deleted file mode 100644 index 8b2e85c..0000000 --- a/gnu/lib/libgmp/mpz/array_init.c +++ /dev/null @@ -1,48 +0,0 @@ -/* mpz_array_init (array, array_size, size_per_elem) -- - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_array_init (mpz_ptr arr, mp_size_t arr_size, mp_size_t nbits) -#else -mpz_array_init (arr, arr_size, nbits) - mpz_ptr arr; - mp_size_t arr_size; - mp_size_t nbits; -#endif -{ - register mp_ptr p; - register size_t i; - mp_size_t nlimbs; - - nlimbs = (nbits + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB; - p = (mp_ptr) (*_mp_allocate_func) (arr_size * nlimbs * BYTES_PER_MP_LIMB); - - for (i = 0; i < arr_size; i++) - { - arr[i]._mp_alloc = nlimbs + 1; /* Yes, lie a little... */ - arr[i]._mp_size = 0; - arr[i]._mp_d = p + i * nlimbs; - } -} diff --git a/gnu/lib/libgmp/mpz/cdiv_q.c b/gnu/lib/libgmp/mpz/cdiv_q.c deleted file mode 100644 index 860a232..0000000 --- a/gnu/lib/libgmp/mpz/cdiv_q.c +++ /dev/null @@ -1,51 +0,0 @@ -/* mpz_cdiv_q -- Division rounding the quotient towards +infinity. The - remainder gets the opposite sign as the denominator. - -Copyright (C) 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_cdiv_q (mpz_ptr quot, mpz_srcptr dividend, mpz_srcptr divisor) -#else -mpz_cdiv_q (quot, dividend, divisor) - mpz_ptr quot; - mpz_srcptr dividend; - mpz_srcptr divisor; -#endif -{ - mp_size_t dividend_size = dividend->_mp_size; - mp_size_t divisor_size = divisor->_mp_size; - mpz_t rem; - TMP_DECL (marker); - - TMP_MARK (marker); - - MPZ_TMP_INIT (rem, 1 + ABS (dividend_size)); - - mpz_tdiv_qr (quot, rem, dividend, divisor); - - if ((divisor_size ^ dividend_size) >= 0 && rem->_mp_size != 0) - mpz_add_ui (quot, quot, 1L); - - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/cdiv_q_ui.c b/gnu/lib/libgmp/mpz/cdiv_q_ui.c deleted file mode 100644 index 7b6cfd7..0000000 --- a/gnu/lib/libgmp/mpz/cdiv_q_ui.c +++ /dev/null @@ -1,64 +0,0 @@ -/* mpz_cdiv_q_ui -- Division rounding the quotient towards +infinity. The - remainder gets the opposite sign as the denominator. In order to make it - always fit into the return type, the negative of the true remainder is - returned. - -Copyright (C) 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -unsigned long int -#if __STDC__ -mpz_cdiv_q_ui (mpz_ptr quot, mpz_srcptr dividend, unsigned long int divisor) -#else -mpz_cdiv_q_ui (quot, dividend, divisor) - mpz_ptr quot; - mpz_srcptr dividend; - unsigned long int divisor; -#endif -{ - mp_size_t dividend_size; - mp_size_t size; - mp_ptr quot_ptr; - mp_limb_t remainder_limb; - - dividend_size = dividend->_mp_size; - size = ABS (dividend_size); - - if (quot->_mp_alloc < size) - _mpz_realloc (quot, size); - - quot_ptr = quot->_mp_d; - - remainder_limb = mpn_divmod_1 (quot_ptr, dividend->_mp_d, size, - (mp_limb_t) divisor); - - if (remainder_limb != 0 && dividend_size >= 0) - { - mpn_add_1 (quot_ptr, quot_ptr, size, (mp_limb_t) 1); - remainder_limb = divisor - remainder_limb; - } - - size -= size != 0 && quot_ptr[size - 1] == 0; - quot->_mp_size = dividend_size >= 0 ? size : -size; - - return remainder_limb; -} diff --git a/gnu/lib/libgmp/mpz/cdiv_qr.c b/gnu/lib/libgmp/mpz/cdiv_qr.c deleted file mode 100644 index bf7d6da..0000000 --- a/gnu/lib/libgmp/mpz/cdiv_qr.c +++ /dev/null @@ -1,62 +0,0 @@ -/* mpz_cdiv_qr -- Division rounding the quotient towards +infinity. The - remainder gets the opposite sign as the denominator. - -Copyright (C) 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_cdiv_qr (mpz_ptr quot, mpz_ptr rem, mpz_srcptr dividend, mpz_srcptr divisor) -#else -mpz_cdiv_qr (quot, rem, dividend, divisor) - mpz_ptr quot; - mpz_ptr rem; - mpz_srcptr dividend; - mpz_srcptr divisor; -#endif -{ - mp_size_t divisor_size = divisor->_mp_size; - mpz_t temp_divisor; /* N.B.: lives until function returns! */ - TMP_DECL (marker); - - TMP_MARK (marker); - - /* We need the original value of the divisor after the quotient and - remainder have been preliminary calculated. We have to copy it to - temporary space if it's the same variable as either QUOT or REM. */ - if (quot == divisor || rem == divisor) - { - MPZ_TMP_INIT (temp_divisor, ABS (divisor_size)); - mpz_set (temp_divisor, divisor); - divisor = temp_divisor; - } - - mpz_tdiv_qr (quot, rem, dividend, divisor); - - if ((divisor_size ^ dividend->_mp_size) >= 0 && rem->_mp_size != 0) - { - mpz_add_ui (quot, quot, 1L); - mpz_sub (rem, rem, divisor); - } - - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/cdiv_qr_ui.c b/gnu/lib/libgmp/mpz/cdiv_qr_ui.c deleted file mode 100644 index a780e77..0000000 --- a/gnu/lib/libgmp/mpz/cdiv_qr_ui.c +++ /dev/null @@ -1,68 +0,0 @@ -/* mpz_cdiv_qr_ui -- Division rounding the quotient towards +infinity. The - remainder gets the opposite sign as the denominator. In order to make it - always fit into the return type, the negative of the true remainder is - returned. - -Copyright (C) 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -unsigned long int -#if __STDC__ -mpz_cdiv_qr_ui (mpz_ptr quot, mpz_ptr rem, mpz_srcptr dividend, unsigned long int divisor) -#else -mpz_cdiv_qr_ui (quot, rem, dividend, divisor) - mpz_ptr quot; - mpz_ptr rem; - mpz_srcptr dividend; - unsigned long int divisor; -#endif -{ - mp_size_t dividend_size; - mp_size_t size; - mp_ptr quot_ptr; - mp_limb_t remainder_limb; - - dividend_size = dividend->_mp_size; - size = ABS (dividend_size); - - if (quot->_mp_alloc < size) - _mpz_realloc (quot, size); - - quot_ptr = quot->_mp_d; - - remainder_limb = mpn_divmod_1 (quot_ptr, dividend->_mp_d, size, - (mp_limb_t) divisor); - - if (remainder_limb != 0 && dividend_size >= 0) - { - mpn_add_1 (quot_ptr, quot_ptr, size, (mp_limb_t) 1); - remainder_limb = divisor - remainder_limb; - } - - size -= size != 0 && quot_ptr[size - 1] == 0; - quot->_mp_size = dividend_size >= 0 ? size : -size; - - rem->_mp_d[0] = remainder_limb; - rem->_mp_size = -(remainder_limb != 0); - - return remainder_limb; -} diff --git a/gnu/lib/libgmp/mpz/cdiv_r.c b/gnu/lib/libgmp/mpz/cdiv_r.c deleted file mode 100644 index d34d138..0000000 --- a/gnu/lib/libgmp/mpz/cdiv_r.c +++ /dev/null @@ -1,59 +0,0 @@ -/* mpz_cdiv_r -- Division rounding the quotient towards +infinity. The - remainder gets the opposite sign as the denominator. - -Copyright (C) 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_cdiv_r (mpz_ptr rem, mpz_srcptr dividend, mpz_srcptr divisor) -#else -mpz_cdiv_r (rem, dividend, divisor) - mpz_ptr rem; - mpz_srcptr dividend; - mpz_srcptr divisor; -#endif -{ - mp_size_t divisor_size = divisor->_mp_size; - mpz_t temp_divisor; /* N.B.: lives until function returns! */ - TMP_DECL (marker); - - TMP_MARK (marker); - - /* We need the original value of the divisor after the remainder has been - preliminary calculated. We have to copy it to temporary space if it's - the same variable as REM. */ - if (rem == divisor) - { - - MPZ_TMP_INIT (temp_divisor, ABS (divisor_size)); - mpz_set (temp_divisor, divisor); - divisor = temp_divisor; - } - - mpz_tdiv_r (rem, dividend, divisor); - - if ((divisor_size ^ dividend->_mp_size) >= 0 && rem->_mp_size != 0) - mpz_sub (rem, rem, divisor); - - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/cdiv_r_ui.c b/gnu/lib/libgmp/mpz/cdiv_r_ui.c deleted file mode 100644 index 757a3f5..0000000 --- a/gnu/lib/libgmp/mpz/cdiv_r_ui.c +++ /dev/null @@ -1,54 +0,0 @@ -/* mpz_cdiv_r_ui -- Division rounding the quotient towards +infinity. The - remainder gets the opposite sign as the denominator. In order to make it - always fit into the return type, the negative of the true remainder is - returned. - -Copyright (C) 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -unsigned long int -#if __STDC__ -mpz_cdiv_r_ui (mpz_ptr rem, mpz_srcptr dividend, unsigned long int divisor) -#else -mpz_cdiv_r_ui (rem, dividend, divisor) - mpz_ptr rem; - mpz_srcptr dividend; - unsigned long int divisor; -#endif -{ - mp_size_t dividend_size; - mp_size_t size; - mp_limb_t remainder_limb; - - dividend_size = dividend->_mp_size; - size = ABS (dividend_size); - - remainder_limb = mpn_mod_1 (dividend->_mp_d, size, (mp_limb_t) divisor); - - if (remainder_limb != 0 && dividend_size >= 0) - remainder_limb = divisor - remainder_limb; - - rem->_mp_d[0] = remainder_limb; - rem->_mp_size = -(remainder_limb != 0); - - return remainder_limb; -} diff --git a/gnu/lib/libgmp/mpz/cdiv_ui.c b/gnu/lib/libgmp/mpz/cdiv_ui.c deleted file mode 100644 index df841ed..0000000 --- a/gnu/lib/libgmp/mpz/cdiv_ui.c +++ /dev/null @@ -1,50 +0,0 @@ -/* mpz_cdiv_ui -- Division rounding the quotient towards +infinity. The - remainder gets the opposite sign as the denominator. In order to make it - always fit into the return type, the negative of the true remainder is - returned. - -Copyright (C) 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -unsigned long int -#if __STDC__ -mpz_cdiv_ui (mpz_srcptr dividend, unsigned long int divisor) -#else -mpz_cdiv_ui (dividend, divisor) - mpz_srcptr dividend; - unsigned long int divisor; -#endif -{ - mp_size_t dividend_size; - mp_size_t size; - mp_limb_t remainder_limb; - - dividend_size = dividend->_mp_size; - size = ABS (dividend_size); - - remainder_limb = mpn_mod_1 (dividend->_mp_d, size, (mp_limb_t) divisor); - - if (remainder_limb != 0 && dividend_size >= 0) - remainder_limb = divisor - remainder_limb; - - return remainder_limb; -} diff --git a/gnu/lib/libgmp/mpz/clear.c b/gnu/lib/libgmp/mpz/clear.c deleted file mode 100644 index 00f3cfd..0000000 --- a/gnu/lib/libgmp/mpz/clear.c +++ /dev/null @@ -1,35 +0,0 @@ -/* mpz_clear -- de-allocate the space occupied by the dynamic digit space of - an integer. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_clear (mpz_ptr m) -#else -mpz_clear (m) - mpz_ptr m; -#endif -{ - (*_mp_free_func) (m->_mp_d, m->_mp_alloc * BYTES_PER_MP_LIMB); -} diff --git a/gnu/lib/libgmp/mpz/clrbit.c b/gnu/lib/libgmp/mpz/clrbit.c deleted file mode 100644 index 59d9565..0000000 --- a/gnu/lib/libgmp/mpz/clrbit.c +++ /dev/null @@ -1,114 +0,0 @@ -/* mpz_clrbit -- clear a specified bit. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_clrbit (mpz_ptr d, unsigned long int bit_index) -#else -mpz_clrbit (d, bit_index) - mpz_ptr d; - unsigned long int bit_index; -#endif -{ - mp_size_t dsize = d->_mp_size; - mp_ptr dp = d->_mp_d; - mp_size_t limb_index; - - limb_index = bit_index / BITS_PER_MP_LIMB; - if (dsize >= 0) - { - if (limb_index < dsize) - { - dp[limb_index] &= ~((mp_limb_t) 1 << (bit_index % BITS_PER_MP_LIMB)); - MPN_NORMALIZE (dp, dsize); - d->_mp_size = dsize; - } - else - ; - } - else - { - mp_size_t zero_bound; - - /* Simulate two's complement arithmetic, i.e. simulate - 1. Set OP = ~(OP - 1) [with infinitely many leading ones]. - 2. clear the bit. - 3. Set OP = ~OP + 1. */ - - dsize = -dsize; - - /* No upper bound on this loop, we're sure there's a non-zero limb - sooner ot later. */ - for (zero_bound = 0; ; zero_bound++) - if (dp[zero_bound] != 0) - break; - - if (limb_index > zero_bound) - { - if (limb_index < dsize) - dp[limb_index] |= (mp_limb_t) 1 << (bit_index % BITS_PER_MP_LIMB); - else - { - /* Ugh. The bit should be cleared outside of the end of the - number. We have to increase the size of the number. */ - if (d->_mp_alloc < limb_index + 1) - { - _mpz_realloc (d, limb_index + 1); - dp = d->_mp_d; - } - MPN_ZERO (dp + dsize, limb_index - dsize); - dp[limb_index] = (mp_limb_t) 1 << (bit_index % BITS_PER_MP_LIMB); - d->_mp_size = -(limb_index + 1); - } - } - else if (limb_index == zero_bound) - { - dp[limb_index] = ((dp[limb_index] - 1) - | ((mp_limb_t) 1 << (bit_index % BITS_PER_MP_LIMB))) + 1; - if (dp[limb_index] == 0) - { - mp_size_t i; - for (i = limb_index + 1; i < dsize; i++) - { - dp[i] += 1; - if (dp[i] != 0) - goto fin; - } - /* We got carry all way out beyond the end of D. Increase - its size (and allocation if necessary). */ - dsize++; - if (d->_mp_alloc < dsize) - { - _mpz_realloc (d, dsize); - dp = d->_mp_d; - } - dp[i] = 1; - d->_mp_size = -dsize; - fin:; - } - } - else - ; - } -} diff --git a/gnu/lib/libgmp/mpz/cmp.c b/gnu/lib/libgmp/mpz/cmp.c deleted file mode 100644 index 37be334..0000000 --- a/gnu/lib/libgmp/mpz/cmp.c +++ /dev/null @@ -1,75 +0,0 @@ -/* mpz_cmp(u,v) -- Compare U, V. Return postive, zero, or negative - based on if U > V, U == V, or U < V. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#ifdef BERKELEY_MP -#include "mp.h" -#endif -#include "gmp.h" -#include "gmp-impl.h" - -#ifndef BERKELEY_MP -int -#if __STDC__ -mpz_cmp (mpz_srcptr u, mpz_srcptr v) -#else -mpz_cmp (u, v) - mpz_srcptr u; - mpz_srcptr v; -#endif -#else /* BERKELEY_MP */ -int -#if __STDC__ -mcmp (mpz_srcptr u, mpz_srcptr v) -#else -mcmp (u, v) - mpz_srcptr u; - mpz_srcptr v; -#endif -#endif /* BERKELEY_MP */ -{ - mp_size_t usize = u->_mp_size; - mp_size_t vsize = v->_mp_size; - mp_size_t size; - mp_srcptr up, vp; - int cmp; - - if (usize != vsize) - return usize - vsize; - - if (usize == 0) - return 0; - - size = ABS (usize); - - up = u->_mp_d; - vp = v->_mp_d; - - cmp = mpn_cmp (up, vp, size); - - if (cmp == 0) - return 0; - - if ((cmp < 0) == (usize < 0)) - return 1; - else - return -1; -} diff --git a/gnu/lib/libgmp/mpz/cmp_si.c b/gnu/lib/libgmp/mpz/cmp_si.c deleted file mode 100644 index 8063fd3..0000000 --- a/gnu/lib/libgmp/mpz/cmp_si.c +++ /dev/null @@ -1,66 +0,0 @@ -/* mpz_cmp_si(u,v) -- Compare an integer U with a single-word int V. - Return positive, zero, or negative based on if U > V, U == V, or U < V. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -/* gmp.h defines a macro for mpz_cmp_si. */ -#undef mpz_cmp_si - -int -#if __STDC__ -mpz_cmp_si (mpz_srcptr u, signed long int v_digit) -#else -mpz_cmp_si (u, v_digit) - mpz_srcptr u; - signed long int v_digit; -#endif -{ - mp_size_t usize = u->_mp_size; - mp_size_t vsize; - mp_limb_t u_digit; - - vsize = 0; - if (v_digit > 0) - vsize = 1; - else if (v_digit < 0) - { - vsize = -1; - v_digit = -v_digit; - } - - if (usize != vsize) - return usize - vsize; - - if (usize == 0) - return 0; - - u_digit = u->_mp_d[0]; - - if (u_digit == v_digit) - return 0; - - if (u_digit > v_digit) - return usize; - else - return -usize; -} diff --git a/gnu/lib/libgmp/mpz/cmp_ui.c b/gnu/lib/libgmp/mpz/cmp_ui.c deleted file mode 100644 index 1a50b96..0000000 --- a/gnu/lib/libgmp/mpz/cmp_ui.c +++ /dev/null @@ -1,56 +0,0 @@ -/* mpz_cmp_ui.c -- Compare a mpz_t a with an mp_limb_t b. Return positive, - zero, or negative based on if a > b, a == b, or a < b. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -/* gmp.h defines a macro for mpz_cmp_ui. */ -#undef mpz_cmp_ui - -int -#if __STDC__ -mpz_cmp_ui (mpz_srcptr u, unsigned long int v_digit) -#else -mpz_cmp_ui (u, v_digit) - mpz_srcptr u; - unsigned long int v_digit; -#endif -{ - mp_size_t usize = u->_mp_size; - - if (usize == 0) - return -(v_digit != 0); - - if (usize == 1) - { - mp_limb_t u_digit; - - u_digit = u->_mp_d[0]; - if (u_digit > v_digit) - return 1; - if (u_digit < v_digit) - return -1; - return 0; - } - - return (usize > 0) ? 1 : -1; -} diff --git a/gnu/lib/libgmp/mpz/com.c b/gnu/lib/libgmp/mpz/com.c deleted file mode 100644 index 559f2b6..0000000 --- a/gnu/lib/libgmp/mpz/com.c +++ /dev/null @@ -1,93 +0,0 @@ -/* mpz_com(mpz_ptr dst, mpz_ptr src) -- Assign the bit-complemented value of - SRC to DST. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_com (mpz_ptr dst, mpz_srcptr src) -#else -mpz_com (dst, src) - mpz_ptr dst; - mpz_srcptr src; -#endif -{ - mp_size_t size = src->_mp_size; - mp_srcptr src_ptr; - mp_ptr dst_ptr; - - if (size >= 0) - { - /* As with infinite precision: one's complement, two's complement. - But this can be simplified using the identity -x = ~x + 1. - So we're going to compute (~~x) + 1 = x + 1! */ - - if (dst->_mp_alloc < size + 1) - _mpz_realloc (dst, size + 1); - - src_ptr = src->_mp_d; - dst_ptr = dst->_mp_d; - - if (size == 0) - { - /* Special case, as mpn_add wants the first arg's size >= the - second arg's size. */ - dst_ptr[0] = 1; - dst->_mp_size = -1; - return; - } - - { - mp_limb_t cy; - - cy = mpn_add_1 (dst_ptr, src_ptr, size, (mp_limb_t) 1); - if (cy) - { - dst_ptr[size] = cy; - size++; - } - } - - /* Store a negative size, to indicate ones-extension. */ - dst->_mp_size = -size; - } - else - { - /* As with infinite precision: two's complement, then one's complement. - But that can be simplified using the identity -x = ~(x - 1). - So we're going to compute ~~(x - 1) = x - 1! */ - size = -size; - - if (dst->_mp_alloc < size) - _mpz_realloc (dst, size); - - src_ptr = src->_mp_d; - dst_ptr = dst->_mp_d; - - mpn_sub_1 (dst_ptr, src_ptr, size, (mp_limb_t) 1); - size -= dst_ptr[size - 1] == 0; - - /* Store a positive size, to indicate zero-extension. */ - dst->_mp_size = size; - } -} diff --git a/gnu/lib/libgmp/mpz/configure.in b/gnu/lib/libgmp/mpz/configure.in deleted file mode 100644 index ed84461..0000000 --- a/gnu/lib/libgmp/mpz/configure.in +++ /dev/null @@ -1,12 +0,0 @@ -# This file is a shell script fragment that supplies the information -# necessary for a configure script to process the program in -# this directory. For more information, look at ../configure. - -configdirs=tests -srctrigger=add_ui.c -srcname="GNU Multi-Precision library/mpz" - -# per-host: - -# per-target: - diff --git a/gnu/lib/libgmp/mpz/divexact.c b/gnu/lib/libgmp/mpz/divexact.c deleted file mode 100644 index b897448..0000000 --- a/gnu/lib/libgmp/mpz/divexact.c +++ /dev/null @@ -1,112 +0,0 @@ -/* mpz_divexact -- finds quotient when known that quot * den == num && den != 0. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* Ken Weber (kweber@mat.ufrgs.br, kweber@mcs.kent.edu) - - Funding for this work has been partially provided by Conselho Nacional - de Desenvolvimento Cienti'fico e Tecnolo'gico (CNPq) do Brazil, Grant - 301314194-2, and was done while I was a visiting reseacher in the Instituto - de Matema'tica at Universidade Federal do Rio Grande do Sul (UFRGS). - - References: - T. Jebelean, An algorithm for exact division, Journal of Symbolic - Computation, v. 15, 1993, pp. 169-180. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void -#if __STDC__ -mpz_divexact (mpz_ptr quot, mpz_srcptr num, mpz_srcptr den) -#else -mpz_divexact (quot, num, den) - mpz_ptr quot; - mpz_srcptr num; - mpz_srcptr den; -#endif -{ - mp_ptr qp, tp; - mp_size_t qsize, tsize; - - mp_srcptr np = num->_mp_d; - mp_srcptr dp = den->_mp_d; - mp_size_t nsize = ABS (num->_mp_size); - mp_size_t dsize = ABS (den->_mp_size); - TMP_DECL (marker); - - /* Generate divide-by-zero error if dsize == 0. */ - if (dsize == 0) - { - quot->_mp_size = 1 / dsize; - return; - } - - if (nsize == 0) - { - quot->_mp_size = 0; - return; - } - - qsize = nsize - dsize + 1; - if (quot->_mp_alloc < qsize) - _mpz_realloc (quot, qsize); - qp = quot->_mp_d; - - TMP_MARK (marker); - - /* QUOT <-- NUM/2^r, T <-- DEN/2^r where = r number of twos in DEN. */ - while (dp[0] == 0) - np += 1, nsize -= 1, dp += 1, dsize -= 1; - tsize = MIN (qsize, dsize); - if (dp[0] & 1) - { - if (qp != dp) - MPN_COPY (qp, np, qsize); - if (qp == dp) /* QUOT and DEN overlap. */ - { - tp = (mp_ptr) TMP_ALLOC (sizeof (mp_limb_t) * tsize); - MPN_COPY (tp, dp, tsize); - } - else - tp = (mp_ptr) dp; - } - else - { - unsigned long int r; - tp = (mp_ptr) TMP_ALLOC (sizeof (mp_limb_t) * tsize); - count_trailing_zeros (r, dp[0]); - mpn_rshift (tp, dp, tsize, r); - if (dsize > tsize) - tp[tsize-1] |= dp[tsize] << (BITS_PER_MP_LIMB - r); - mpn_rshift (qp, np, qsize, r); - if (nsize > qsize) - qp[qsize-1] |= np[qsize] << (BITS_PER_MP_LIMB - r); - } - - /* Now QUOT <-- QUOT/T. */ - mpn_bdivmod (qp, qp, qsize, tp, tsize, qsize * BITS_PER_MP_LIMB); - MPN_NORMALIZE (qp, qsize); - - quot->_mp_size = (num->_mp_size < 0) == (den->_mp_size < 0) ? qsize : -qsize; - - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/dmincl.c b/gnu/lib/libgmp/mpz/dmincl.c deleted file mode 100644 index 51bd084..0000000 --- a/gnu/lib/libgmp/mpz/dmincl.c +++ /dev/null @@ -1,201 +0,0 @@ -/* dmincl.c -- include file for tdiv_qr.c, tdiv_r.c. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -/* If den == quot, den needs temporary storage. - If den == rem, den needs temporary storage. - If num == quot, num needs temporary storage. - If den has temporary storage, it can be normalized while being copied, - i.e no extra storage should be allocated. */ - -/* This is the function body of mdiv, mpz_divmod, and mpz_mod. - - If COMPUTE_QUOTIENT is defined, the quotient is put in the MP_INT - object quot, otherwise that variable is not referenced at all. - - The remainder is always computed, and the result is put in the MP_INT - object rem. */ - -{ - mp_ptr np, dp; - mp_ptr qp, rp; - mp_size_t nsize = num->_mp_size; - mp_size_t dsize = den->_mp_size; - mp_size_t qsize, rsize; - mp_size_t sign_remainder = nsize; -#ifdef COMPUTE_QUOTIENT - mp_size_t sign_quotient = nsize ^ dsize; -#endif - unsigned normalization_steps; - mp_limb_t q_limb; - TMP_DECL (marker); - - nsize = ABS (nsize); - dsize = ABS (dsize); - - /* Ensure space is enough for quotient and remainder. */ - - /* We need space for an extra limb in the remainder, because it's - up-shifted (normalized) below. */ - rsize = nsize + 1; - if (rem->_mp_alloc < rsize) - _mpz_realloc (rem, rsize); - - qsize = rsize - dsize; /* qsize cannot be bigger than this. */ - if (qsize <= 0) - { - if (num != rem) - { - rem->_mp_size = num->_mp_size; - MPN_COPY (rem->_mp_d, num->_mp_d, nsize); - } -#ifdef COMPUTE_QUOTIENT - /* This needs to follow the assignment to rem, in case the - numerator and quotient are the same. */ - quot->_mp_size = 0; -#endif - return; - } - -#ifdef COMPUTE_QUOTIENT - if (quot->_mp_alloc < qsize) - _mpz_realloc (quot, qsize); -#endif - - /* Read pointers here, when reallocation is finished. */ - np = num->_mp_d; - dp = den->_mp_d; - rp = rem->_mp_d; - - /* Optimize division by a single-limb divisor. */ - if (dsize == 1) - { - mp_limb_t rlimb; -#ifdef COMPUTE_QUOTIENT - qp = quot->_mp_d; - rlimb = mpn_divmod_1 (qp, np, nsize, dp[0]); - qsize -= qp[qsize - 1] == 0; - quot->_mp_size = sign_quotient >= 0 ? qsize : -qsize; -#else - rlimb = mpn_mod_1 (np, nsize, dp[0]); -#endif - rp[0] = rlimb; - rsize = rlimb != 0; - rem->_mp_size = sign_remainder >= 0 ? rsize : -rsize; - return; - } - - TMP_MARK (marker); - -#ifdef COMPUTE_QUOTIENT - qp = quot->_mp_d; - - /* Make sure QP and NP point to different objects. Otherwise the - numerator would be gradually overwritten by the quotient limbs. */ - if (qp == np) - { - /* Copy NP object to temporary space. */ - np = (mp_ptr) TMP_ALLOC (nsize * BYTES_PER_MP_LIMB); - MPN_COPY (np, qp, nsize); - } - -#else - /* Put quotient at top of remainder. */ - qp = rp + dsize; -#endif - - count_leading_zeros (normalization_steps, dp[dsize - 1]); - - /* Normalize the denominator, i.e. make its most significant bit set by - shifting it NORMALIZATION_STEPS bits to the left. Also shift the - numerator the same number of steps (to keep the quotient the same!). */ - if (normalization_steps != 0) - { - mp_ptr tp; - mp_limb_t nlimb; - - /* Shift up the denominator setting the most significant bit of - the most significant word. Use temporary storage not to clobber - the original contents of the denominator. */ - tp = (mp_ptr) TMP_ALLOC (dsize * BYTES_PER_MP_LIMB); - mpn_lshift (tp, dp, dsize, normalization_steps); - dp = tp; - - /* Shift up the numerator, possibly introducing a new most - significant word. Move the shifted numerator in the remainder - meanwhile. */ - nlimb = mpn_lshift (rp, np, nsize, normalization_steps); - if (nlimb != 0) - { - rp[nsize] = nlimb; - rsize = nsize + 1; - } - else - rsize = nsize; - } - else - { - /* The denominator is already normalized, as required. Copy it to - temporary space if it overlaps with the quotient or remainder. */ -#ifdef COMPUTE_QUOTIENT - if (dp == rp || dp == qp) -#else - if (dp == rp) -#endif - { - mp_ptr tp; - - tp = (mp_ptr) TMP_ALLOC (dsize * BYTES_PER_MP_LIMB); - MPN_COPY (tp, dp, dsize); - dp = tp; - } - - /* Move the numerator to the remainder. */ - if (rp != np) - MPN_COPY (rp, np, nsize); - - rsize = nsize; - } - - q_limb = mpn_divmod (qp, rp, rsize, dp, dsize); - -#ifdef COMPUTE_QUOTIENT - qsize = rsize - dsize; - if (q_limb) - { - qp[qsize] = q_limb; - qsize += 1; - } - - quot->_mp_size = sign_quotient >= 0 ? qsize : -qsize; -#endif - - rsize = dsize; - MPN_NORMALIZE (rp, rsize); - - if (normalization_steps != 0 && rsize != 0) - { - mpn_rshift (rp, rp, rsize, normalization_steps); - rsize -= rp[rsize - 1] == 0; - } - - rem->_mp_size = sign_remainder >= 0 ? rsize : -rsize; - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/fac_ui.c b/gnu/lib/libgmp/mpz/fac_ui.c deleted file mode 100644 index a170060..0000000 --- a/gnu/lib/libgmp/mpz/fac_ui.c +++ /dev/null @@ -1,157 +0,0 @@ -/* mpz_fac_ui(result, n) -- Set RESULT to N!. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#ifdef DBG -#include -#endif - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void -#if __STDC__ -mpz_fac_ui (mpz_ptr result, unsigned long int n) -#else -mpz_fac_ui (result, n) - mpz_ptr result; - unsigned long int n; -#endif -{ -#if SIMPLE_FAC - - /* Be silly. Just multiply the numbers in ascending order. O(n**2). */ - - unsigned long int k; - - mpz_set_ui (result, 1L); - - for (k = 2; k <= n; k++) - mpz_mul_ui (result, result, k); -#else - - /* Be smarter. Multiply groups of numbers in ascending order until the - product doesn't fit in a limb. Multiply these partial product in a - balanced binary tree fashion, to make the operand have as equal sizes - as possible. When the operands have about the same size, mpn_mul - becomes faster. */ - - unsigned long int p, k; - mp_limb_t p1, p0; - - /* Stack of partial products, used to make the computation balanced - (i.e. make the sizes of the multiplication operands equal). The - topmost position of MP_STACK will contain a one-limb partial product, - the second topmost will contain a two-limb partial product, and so - on. MP_STACK[0] will contain a partial product with 2**t limbs. - To compute n! MP_STACK needs to be less than - log(n)**2/log(BITS_PER_MP_LIMB), so 30 is surely enough. */ -#define MP_STACK_SIZE 30 - mpz_t mp_stack[MP_STACK_SIZE]; - - /* TOP is an index into MP_STACK, giving the topmost element. - TOP_LIMIT_SO_FAR is the largets value it has taken so far. */ - int top, top_limit_so_far; - - /* Count of the total number of limbs put on MP_STACK so far. This - variable plays an essential role in making the compututation balanced. - See below. */ - unsigned int tree_cnt; - - top = top_limit_so_far = -1; - tree_cnt = 0; - p = 1; - for (k = 2; k <= n; k++) - { - /* Multiply the partial product in P with K. */ - umul_ppmm (p1, p0, (mp_limb_t) p, (mp_limb_t) k); - - /* Did we get overflow into the high limb, i.e. is the partial - product now more than one limb? */ - if (p1 != 0) - { - tree_cnt++; - - if (tree_cnt % 2 == 0) - { - mp_size_t i; - - /* TREE_CNT is even (i.e. we have generated an even number of - one-limb partial products), which means that we have a - single-limb product on the top of MP_STACK. */ - - mpz_mul_ui (mp_stack[top], mp_stack[top], p); - - /* If TREE_CNT is divisable by 4, 8,..., we have two - similar-sized partial products with 2, 4,... limbs at - the topmost two positions of MP_STACK. Multiply them - to form a new partial product with 4, 8,... limbs. */ - for (i = 4; (tree_cnt & (i - 1)) == 0; i <<= 1) - { - mpz_mul (mp_stack[top - 1], - mp_stack[top], mp_stack[top - 1]); - top--; - } - } - else - { - /* Put the single-limb partial product in P on the stack. - (The next time we get a single-limb product, we will - multiply the two together.) */ - top++; - if (top > top_limit_so_far) - { - if (top > MP_STACK_SIZE) - abort(); - /* The stack is now bigger than ever, initialize the top - element. */ - mpz_init_set_ui (mp_stack[top], p); - top_limit_so_far++; - } - else - mpz_set_ui (mp_stack[top], p); - } - - /* We ignored the last result from umul_ppmm. Put K in P as the - first component of the next single-limb partial product. */ - p = k; - } - else - /* We didn't get overflow in umul_ppmm. Put p0 in P and try - with one more value of K. */ - p = p0; /* bogus if long != mp_limb_t */ - } - - /* We have partial products in mp_stack[0..top], in descending order. - We also have a small partial product in p. - Their product is the final result. */ - if (top < 0) - mpz_set_ui (result, p); - else - mpz_mul_ui (result, mp_stack[top--], p); - while (top >= 0) - mpz_mul (result, result, mp_stack[top--]); - - /* Free the storage allocated for MP_STACK. */ - for (top = top_limit_so_far; top >= 0; top--) - mpz_clear (mp_stack[top]); -#endif -} diff --git a/gnu/lib/libgmp/mpz/fdiv_q.c b/gnu/lib/libgmp/mpz/fdiv_q.c deleted file mode 100644 index 3da943a..0000000 --- a/gnu/lib/libgmp/mpz/fdiv_q.c +++ /dev/null @@ -1,51 +0,0 @@ -/* mpz_fdiv_q -- Division rounding the quotient towards -infinity. - The remainder gets the same sign as the denominator. - -Copyright (C) 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_fdiv_q (mpz_ptr quot, mpz_srcptr dividend, mpz_srcptr divisor) -#else -mpz_fdiv_q (quot, dividend, divisor) - mpz_ptr quot; - mpz_srcptr dividend; - mpz_srcptr divisor; -#endif -{ - mp_size_t dividend_size = dividend->_mp_size; - mp_size_t divisor_size = divisor->_mp_size; - mpz_t rem; - TMP_DECL (marker); - - TMP_MARK (marker); - - MPZ_TMP_INIT (rem, 1 + ABS (dividend_size)); - - mpz_tdiv_qr (quot, rem, dividend, divisor); - - if ((divisor_size ^ dividend_size) < 0 && rem->_mp_size != 0) - mpz_sub_ui (quot, quot, 1L); - - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/fdiv_q_2exp.c b/gnu/lib/libgmp/mpz/fdiv_q_2exp.c deleted file mode 100644 index 3f56baf..0000000 --- a/gnu/lib/libgmp/mpz/fdiv_q_2exp.c +++ /dev/null @@ -1,94 +0,0 @@ -/* mpz_fdiv_q_2exp -- Divide an integer by 2**CNT. Round the quotient - towards -infinity. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_fdiv_q_2exp (mpz_ptr w, mpz_srcptr u, unsigned long int cnt) -#else -mpz_fdiv_q_2exp (w, u, cnt) - mpz_ptr w; - mpz_srcptr u; - unsigned long int cnt; -#endif -{ - mp_size_t usize = u->_mp_size; - mp_size_t wsize; - mp_size_t abs_usize = ABS (usize); - mp_size_t limb_cnt; - mp_ptr wp; - mp_limb_t round = 0; - - limb_cnt = cnt / BITS_PER_MP_LIMB; - wsize = abs_usize - limb_cnt; - if (wsize <= 0) - { - wp = w->_mp_d; - wsize = 0; - /* Set ROUND since we know we skip some non-zero words in this case. - Well, if U is zero, we don't, but then this will be taken care of - below, since rounding only really takes place for negative U. */ - round = 1; - wp[0] = 1; - w->_mp_size = -(usize < 0); - return; - } - else - { - mp_size_t i; - mp_ptr up; - - /* Make sure there is enough space. We make an extra limb - here to account for possible rounding at the end. */ - if (w->_mp_alloc < wsize + 1) - _mpz_realloc (w, wsize + 1); - - wp = w->_mp_d; - up = u->_mp_d; - - /* Set ROUND if we are about skip some non-zero limbs. */ - for (i = 0; i < limb_cnt && round == 0; i++) - round = up[i]; - - cnt %= BITS_PER_MP_LIMB; - if (cnt != 0) - { - round |= mpn_rshift (wp, up + limb_cnt, wsize, cnt); - wsize -= wp[wsize - 1] == 0; - } - else - { - MPN_COPY_INCR (wp, up + limb_cnt, wsize); - } - } - - if (usize < 0 && round != 0) - { - mp_limb_t cy; - cy = mpn_add_1 (wp, wp, wsize, 1); - wp[wsize] = cy; - wsize += cy; - } - w->_mp_size = usize >= 0 ? wsize : -wsize; -} diff --git a/gnu/lib/libgmp/mpz/fdiv_q_ui.c b/gnu/lib/libgmp/mpz/fdiv_q_ui.c deleted file mode 100644 index 3d6825d..0000000 --- a/gnu/lib/libgmp/mpz/fdiv_q_ui.c +++ /dev/null @@ -1,62 +0,0 @@ -/* mpz_fdiv_q_ui -- Division rounding the quotient towards -infinity. - The remainder gets the same sign as the denominator. - -Copyright (C) 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -unsigned long int -#if __STDC__ -mpz_fdiv_q_ui (mpz_ptr quot, mpz_srcptr dividend, unsigned long int divisor) -#else -mpz_fdiv_q_ui (quot, dividend, divisor) - mpz_ptr quot; - mpz_srcptr dividend; - unsigned long int divisor; -#endif -{ - mp_size_t dividend_size; - mp_size_t size; - mp_ptr quot_ptr; - mp_limb_t remainder_limb; - - dividend_size = dividend->_mp_size; - size = ABS (dividend_size); - - if (quot->_mp_alloc < size) - _mpz_realloc (quot, size); - - quot_ptr = quot->_mp_d; - - remainder_limb = mpn_divmod_1 (quot_ptr, dividend->_mp_d, size, - (mp_limb_t) divisor); - - if (remainder_limb != 0 && dividend_size < 0) - { - mpn_add_1 (quot_ptr, quot_ptr, size, (mp_limb_t) 1); - remainder_limb = divisor - remainder_limb; - } - - size -= size != 0 && quot_ptr[size - 1] == 0; - quot->_mp_size = dividend_size >= 0 ? size : -size; - - return remainder_limb; -} diff --git a/gnu/lib/libgmp/mpz/fdiv_qr.c b/gnu/lib/libgmp/mpz/fdiv_qr.c deleted file mode 100644 index 2abb16c..0000000 --- a/gnu/lib/libgmp/mpz/fdiv_qr.c +++ /dev/null @@ -1,62 +0,0 @@ -/* mpz_fdiv_qr -- Division rounding the quotient towards -infinity. - The remainder gets the same sign as the denominator. - -Copyright (C) 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_fdiv_qr (mpz_ptr quot, mpz_ptr rem, mpz_srcptr dividend, mpz_srcptr divisor) -#else -mpz_fdiv_qr (quot, rem, dividend, divisor) - mpz_ptr quot; - mpz_ptr rem; - mpz_srcptr dividend; - mpz_srcptr divisor; -#endif -{ - mp_size_t divisor_size = divisor->_mp_size; - mpz_t temp_divisor; /* N.B.: lives until function returns! */ - TMP_DECL (marker); - - TMP_MARK (marker); - - /* We need the original value of the divisor after the quotient and - remainder have been preliminary calculated. We have to copy it to - temporary space if it's the same variable as either QUOT or REM. */ - if (quot == divisor || rem == divisor) - { - MPZ_TMP_INIT (temp_divisor, ABS (divisor_size)); - mpz_set (temp_divisor, divisor); - divisor = temp_divisor; - } - - mpz_tdiv_qr (quot, rem, dividend, divisor); - - if ((divisor_size ^ dividend->_mp_size) < 0 && rem->_mp_size != 0) - { - mpz_sub_ui (quot, quot, 1L); - mpz_add (rem, rem, divisor); - } - - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/fdiv_qr_ui.c b/gnu/lib/libgmp/mpz/fdiv_qr_ui.c deleted file mode 100644 index a22b702..0000000 --- a/gnu/lib/libgmp/mpz/fdiv_qr_ui.c +++ /dev/null @@ -1,66 +0,0 @@ -/* mpz_fdiv_qr_ui -- Division rounding the quotient towards -infinity. - The remainder gets the same sign as the denominator. - -Copyright (C) 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -unsigned long int -#if __STDC__ -mpz_fdiv_qr_ui (mpz_ptr quot, mpz_ptr rem, mpz_srcptr dividend, unsigned long int divisor) -#else -mpz_fdiv_qr_ui (quot, rem, dividend, divisor) - mpz_ptr quot; - mpz_ptr rem; - mpz_srcptr dividend; - unsigned long int divisor; -#endif -{ - mp_size_t dividend_size; - mp_size_t size; - mp_ptr quot_ptr; - mp_limb_t remainder_limb; - - dividend_size = dividend->_mp_size; - size = ABS (dividend_size); - - if (quot->_mp_alloc < size) - _mpz_realloc (quot, size); - - quot_ptr = quot->_mp_d; - - remainder_limb = mpn_divmod_1 (quot_ptr, dividend->_mp_d, size, - (mp_limb_t) divisor); - - if (remainder_limb != 0 && dividend_size < 0) - { - mpn_add_1 (quot_ptr, quot_ptr, size, (mp_limb_t) 1); - remainder_limb = divisor - remainder_limb; - } - - size -= size != 0 && quot_ptr[size - 1] == 0; - quot->_mp_size = dividend_size >= 0 ? size : -size; - - rem->_mp_d[0] = remainder_limb; - rem->_mp_size = remainder_limb != 0; - - return remainder_limb; -} diff --git a/gnu/lib/libgmp/mpz/fdiv_r.c b/gnu/lib/libgmp/mpz/fdiv_r.c deleted file mode 100644 index 14e045b..0000000 --- a/gnu/lib/libgmp/mpz/fdiv_r.c +++ /dev/null @@ -1,58 +0,0 @@ -/* mpz_fdiv_r -- Division rounding the quotient towards -infinity. - The remainder gets the same sign as the denominator. - -Copyright (C) 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_fdiv_r (mpz_ptr rem, mpz_srcptr dividend, mpz_srcptr divisor) -#else -mpz_fdiv_r (rem, dividend, divisor) - mpz_ptr rem; - mpz_srcptr dividend; - mpz_srcptr divisor; -#endif -{ - mp_size_t divisor_size = divisor->_mp_size; - mpz_t temp_divisor; /* N.B.: lives until function returns! */ - TMP_DECL (marker); - - TMP_MARK (marker); - - /* We need the original value of the divisor after the remainder has been - preliminary calculated. We have to copy it to temporary space if it's - the same variable as REM. */ - if (rem == divisor) - { - MPZ_TMP_INIT (temp_divisor, ABS (divisor_size)); - mpz_set (temp_divisor, divisor); - divisor = temp_divisor; - } - - mpz_tdiv_r (rem, dividend, divisor); - - if ((divisor_size ^ dividend->_mp_size) < 0 && rem->_mp_size != 0) - mpz_add (rem, rem, divisor); - - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/fdiv_r_2exp.c b/gnu/lib/libgmp/mpz/fdiv_r_2exp.c deleted file mode 100644 index 04190b1..0000000 --- a/gnu/lib/libgmp/mpz/fdiv_r_2exp.c +++ /dev/null @@ -1,88 +0,0 @@ -/* mpz_fdiv_r_2exp -- Divide a integer by 2**CNT and produce a remainder. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_fdiv_r_2exp (mpz_ptr res, mpz_srcptr in, unsigned long int cnt) -#else -mpz_fdiv_r_2exp (res, in, cnt) - mpz_ptr res; - mpz_srcptr in; - unsigned long int cnt; -#endif -{ - mp_size_t in_size = ABS (in->_mp_size); - mp_size_t res_size; - mp_size_t limb_cnt = cnt / BITS_PER_MP_LIMB; - mp_srcptr in_ptr = in->_mp_d; - - if (in_size > limb_cnt) - { - /* The input operand is (probably) greater than 2**CNT. */ - mp_limb_t x; - - x = in_ptr[limb_cnt] & (((mp_limb_t) 1 << cnt % BITS_PER_MP_LIMB) - 1); - if (x != 0) - { - res_size = limb_cnt + 1; - if (res->_mp_alloc < res_size) - _mpz_realloc (res, res_size); - - res->_mp_d[limb_cnt] = x; - } - else - { - res_size = limb_cnt; - MPN_NORMALIZE (in_ptr, res_size); - - if (res->_mp_alloc < res_size) - _mpz_realloc (res, res_size); - - limb_cnt = res_size; - } - } - else - { - /* The input operand is smaller than 2**CNT. We perform a no-op, - apart from that we might need to copy IN to RES. */ - res_size = in_size; - if (res->_mp_alloc < res_size) - _mpz_realloc (res, res_size); - - limb_cnt = res_size; - } - - if (res != in) - MPN_COPY (res->_mp_d, in->_mp_d, limb_cnt); - res->_mp_size = res_size; - if (in->_mp_size < 0 && res_size != 0) - { - /* Result should be 2^CNT - RES */ - mpz_t tmp; - MPZ_TMP_INIT (tmp, limb_cnt + 1); - mpz_set_ui (tmp, 1L); - mpz_mul_2exp (tmp, tmp, cnt); - mpz_sub (res, tmp, res); - } -} diff --git a/gnu/lib/libgmp/mpz/fdiv_r_ui.c b/gnu/lib/libgmp/mpz/fdiv_r_ui.c deleted file mode 100644 index c4c3749..0000000 --- a/gnu/lib/libgmp/mpz/fdiv_r_ui.c +++ /dev/null @@ -1,52 +0,0 @@ -/* mpz_fdiv_r_ui -- Division rounding the quotient towards -infinity. - The remainder gets the same sign as the denominator. - -Copyright (C) 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -unsigned long int -#if __STDC__ -mpz_fdiv_r_ui (mpz_ptr rem, mpz_srcptr dividend, unsigned long int divisor) -#else -mpz_fdiv_r_ui (rem, dividend, divisor) - mpz_ptr rem; - mpz_srcptr dividend; - unsigned long int divisor; -#endif -{ - mp_size_t dividend_size; - mp_size_t size; - mp_limb_t remainder_limb; - - dividend_size = dividend->_mp_size; - size = ABS (dividend_size); - - remainder_limb = mpn_mod_1 (dividend->_mp_d, size, (mp_limb_t) divisor); - - if (remainder_limb != 0 && dividend_size < 0) - remainder_limb = divisor - remainder_limb; - - rem->_mp_d[0] = remainder_limb; - rem->_mp_size = remainder_limb != 0; - - return remainder_limb; -} diff --git a/gnu/lib/libgmp/mpz/fdiv_ui.c b/gnu/lib/libgmp/mpz/fdiv_ui.c deleted file mode 100644 index 4d018a2..0000000 --- a/gnu/lib/libgmp/mpz/fdiv_ui.c +++ /dev/null @@ -1,48 +0,0 @@ -/* mpz_fdiv_ui -- Division rounding the quotient towards -infinity. - The remainder gets the same sign as the denominator. - -Copyright (C) 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -unsigned long int -#if __STDC__ -mpz_fdiv_ui (mpz_srcptr dividend, unsigned long int divisor) -#else -mpz_fdiv_ui (dividend, divisor) - mpz_srcptr dividend; - unsigned long int divisor; -#endif -{ - mp_size_t dividend_size; - mp_size_t size; - mp_limb_t remainder_limb; - - dividend_size = dividend->_mp_size; - size = ABS (dividend_size); - - remainder_limb = mpn_mod_1 (dividend->_mp_d, size, (mp_limb_t) divisor); - - if (remainder_limb != 0 && dividend_size < 0) - remainder_limb = divisor - remainder_limb; - - return remainder_limb; -} diff --git a/gnu/lib/libgmp/mpz/gcd.c b/gnu/lib/libgmp/mpz/gcd.c deleted file mode 100644 index f93030c..0000000 --- a/gnu/lib/libgmp/mpz/gcd.c +++ /dev/null @@ -1,178 +0,0 @@ -/* mpz/gcd.c: Calculate the greatest common divisor of two integers. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void *_mpz_realloc (); - -#ifndef BERKELEY_MP -void -#if __STDC__ -mpz_gcd (mpz_ptr g, mpz_srcptr u, mpz_srcptr v) -#else -mpz_gcd (g, u, v) - mpz_ptr g; - mpz_srcptr u; - mpz_srcptr v; -#endif -#else /* BERKELEY_MP */ -void -#if __STDC__ -gcd (mpz_srcptr u, mpz_srcptr v, mpz_ptr g) -#else -gcd (u, v, g) - mpz_ptr g; - mpz_srcptr u; - mpz_srcptr v; -#endif -#endif /* BERKELEY_MP */ - -{ - unsigned long int g_zero_bits, u_zero_bits, v_zero_bits; - mp_size_t g_zero_limbs, u_zero_limbs, v_zero_limbs; - mp_ptr tp; - mp_ptr up = u->_mp_d; - mp_size_t usize = ABS (u->_mp_size); - mp_ptr vp = v->_mp_d; - mp_size_t vsize = ABS (v->_mp_size); - mp_size_t gsize; - TMP_DECL (marker); - - /* GCD(0, V) == V. */ - if (usize == 0) - { - g->_mp_size = vsize; - if (g == v) - return; - if (g->_mp_alloc < vsize) - _mpz_realloc (g, vsize); - MPN_COPY (g->_mp_d, vp, vsize); - return; - } - - /* GCD(U, 0) == U. */ - if (vsize == 0) - { - g->_mp_size = usize; - if (g == u) - return; - if (g->_mp_alloc < usize) - _mpz_realloc (g, usize); - MPN_COPY (g->_mp_d, up, usize); - return; - } - - if (usize == 1) - { - g->_mp_size = 1; - g->_mp_d[0] = mpn_gcd_1 (vp, vsize, up[0]); - return; - } - - if (vsize == 1) - { - g->_mp_size = 1; - g->_mp_d[0] = mpn_gcd_1 (up, usize, vp[0]); - return; - } - - TMP_MARK (marker); - - /* Eliminate low zero bits from U and V and move to temporary storage. */ - while (*up == 0) - up++; - u_zero_limbs = up - u->_mp_d; - usize -= u_zero_limbs; - count_trailing_zeros (u_zero_bits, *up); - tp = up; - up = (mp_ptr) TMP_ALLOC (usize * BYTES_PER_MP_LIMB); - if (u_zero_bits != 0) - { - mpn_rshift (up, tp, usize, u_zero_bits); - usize -= up[usize - 1] == 0; - } - else - MPN_COPY (up, tp, usize); - - while (*vp == 0) - vp++; - v_zero_limbs = vp - v->_mp_d; - vsize -= v_zero_limbs; - count_trailing_zeros (v_zero_bits, *vp); - tp = vp; - vp = (mp_ptr) TMP_ALLOC (vsize * BYTES_PER_MP_LIMB); - if (v_zero_bits != 0) - { - mpn_rshift (vp, tp, vsize, v_zero_bits); - vsize -= vp[vsize - 1] == 0; - } - else - MPN_COPY (vp, tp, vsize); - - if (u_zero_limbs > v_zero_limbs) - { - g_zero_limbs = v_zero_limbs; - g_zero_bits = v_zero_bits; - } - else if (u_zero_limbs < v_zero_limbs) - { - g_zero_limbs = u_zero_limbs; - g_zero_bits = u_zero_bits; - } - else /* Equal. */ - { - g_zero_limbs = u_zero_limbs; - g_zero_bits = MIN (u_zero_bits, v_zero_bits); - } - - /* Call mpn_gcd. The 1st argument must not have more bits than the 2nd. */ - vsize = (usize < vsize || (usize == vsize && up[usize-1] < vp[vsize-1])) - ? mpn_gcd (vp, up, usize, vp, vsize) - : mpn_gcd (vp, vp, vsize, up, usize); - - /* Here G <-- V << (g_zero_limbs*BITS_PER_MP_LIMB + g_zero_bits). */ - gsize = vsize + g_zero_limbs; - if (g_zero_bits != 0) - { - mp_limb_t cy_limb; - gsize += (vp[vsize - 1] >> (BITS_PER_MP_LIMB - g_zero_bits)) != 0; - if (g->_mp_alloc < gsize) - _mpz_realloc (g, gsize); - MPN_ZERO (g->_mp_d, g_zero_limbs); - - tp = g->_mp_d + g_zero_limbs; - cy_limb = mpn_lshift (tp, vp, vsize, g_zero_bits); - if (cy_limb != 0) - tp[vsize] = cy_limb; - } - else - { - if (g->_mp_alloc < gsize) - _mpz_realloc (g, gsize); - MPN_ZERO (g->_mp_d, g_zero_limbs); - MPN_COPY (g->_mp_d + g_zero_limbs, vp, vsize); - } - - g->_mp_size = gsize; - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/gcd_ui.c b/gnu/lib/libgmp/mpz/gcd_ui.c deleted file mode 100644 index 388ab05..0000000 --- a/gnu/lib/libgmp/mpz/gcd_ui.c +++ /dev/null @@ -1,64 +0,0 @@ -/* mpz_gcd_ui -- Calculate the greatest common divisior of two integers. - -Copyright (C) 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -unsigned long int -#if __STDC__ -mpz_gcd_ui (mpz_ptr w, mpz_srcptr u, unsigned long int v) -#else -mpz_gcd_ui (w, u, v) - mpz_ptr w; - mpz_srcptr u; - unsigned long int v; -#endif -{ - mp_size_t size; - mp_limb_t res; - - size = ABS (u->_mp_size); - - if (size == 0) - res = v; - else if (v == 0) - { - if (w != NULL && u != w) - { - if (w->_mp_alloc < size) - _mpz_realloc (w, size); - - MPN_COPY (w->_mp_d, u->_mp_d, size); - } - w->_mp_size = size; - /* We can't return any useful result for gcd(big,0). */ - return size > 1 ? 0 : w->_mp_d[0]; - } - else - res = mpn_gcd_1 (u->_mp_d, size, v); - - if (w != NULL) - { - w->_mp_d[0] = res; - w->_mp_size = 1; - } - return res; -} diff --git a/gnu/lib/libgmp/mpz/gcdext.c b/gnu/lib/libgmp/mpz/gcdext.c deleted file mode 100644 index adf66b0..0000000 --- a/gnu/lib/libgmp/mpz/gcdext.c +++ /dev/null @@ -1,88 +0,0 @@ -/* mpz_gcdext(g, s, t, a, b) -- Set G to gcd(a, b), and S and T such that - g = as + bt. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -/* Botch: SLOW! */ - -void -#if __STDC__ -mpz_gcdext (mpz_ptr g, mpz_ptr s, mpz_ptr t, mpz_srcptr a, mpz_srcptr b) -#else -mpz_gcdext (g, s, t, a, b) - mpz_ptr g; - mpz_ptr s; - mpz_ptr t; - mpz_srcptr a; - mpz_srcptr b; -#endif -{ - mpz_t s0, s1, q, r, x, d0, d1; - - mpz_init_set_ui (s0, 1L); - mpz_init_set_ui (s1, 0L); - mpz_init (q); - mpz_init (r); - mpz_init (x); - mpz_init_set (d0, a); - mpz_init_set (d1, b); - - while (d1->_mp_size != 0) - { - mpz_tdiv_qr (q, r, d0, d1); - mpz_set (d0, d1); - mpz_set (d1, r); - - mpz_mul (x, s1, q); - mpz_sub (x, s0, x); - mpz_set (s0, s1); - mpz_set (s1, x); - } - - if (t != NULL) - { - mpz_mul (x, s0, a); - mpz_sub (x, d0, x); - if (b->_mp_size == 0) - t->_mp_size = 0; - else - mpz_tdiv_q (t, x, b); - } - mpz_set (s, s0); - mpz_set (g, d0); - if (g->_mp_size < 0) - { - g->_mp_size = -g->_mp_size; - s->_mp_size = -s->_mp_size; - if (t != NULL) - t->_mp_size = -t->_mp_size; - } - - mpz_clear (s0); - mpz_clear (s1); - mpz_clear (q); - mpz_clear (r); - mpz_clear (x); - mpz_clear (d0); - mpz_clear (d1); -} diff --git a/gnu/lib/libgmp/mpz/get_d.c b/gnu/lib/libgmp/mpz/get_d.c deleted file mode 100644 index 0fd7916..0000000 --- a/gnu/lib/libgmp/mpz/get_d.c +++ /dev/null @@ -1,54 +0,0 @@ -/* double mpz_get_d (mpz_t src) -- Return the double approximation to SRC. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -double -#if __STDC__ -mpz_get_d (mpz_srcptr src) -#else -mpz_get_d (src) - mpz_srcptr src; -#endif -{ - double res; - mp_size_t size, i, n_limbs_to_use; - int negative; - mp_ptr qp; - - size = SIZ(src); - if (size == 0) - return 0.0; - - negative = size < 0; - size = ABS (size); - qp = PTR(src); - - res = qp[size - 1]; - n_limbs_to_use = MIN (LIMBS_PER_DOUBLE, size); - for (i = 2; i <= n_limbs_to_use; i++) - res = res * MP_BASE_AS_DOUBLE + qp[size - i]; - - res = __gmp_scale2 (res, (size - n_limbs_to_use) * BITS_PER_MP_LIMB); - - return negative ? -res : res; -} diff --git a/gnu/lib/libgmp/mpz/get_si.c b/gnu/lib/libgmp/mpz/get_si.c deleted file mode 100644 index 45e0e5a..0000000 --- a/gnu/lib/libgmp/mpz/get_si.c +++ /dev/null @@ -1,43 +0,0 @@ -/* mpz_get_si(integer) -- Return the least significant digit from INTEGER. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -signed long int -#if __STDC__ -mpz_get_si (mpz_srcptr op) -#else -mpz_get_si (op) - mpz_srcptr op; -#endif -{ - mp_size_t size = op->_mp_size; - mp_limb_t low_limb = op->_mp_d[0]; - - if (size > 0) - return low_limb % ((mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1)); - else if (size < 0) - /* This convoluted expression is necessary to properly handle 0x80000000 */ - return ~((low_limb - 1) % ((mp_limb_t) 1 << (BITS_PER_MP_LIMB - 1))); - else - return 0; -} diff --git a/gnu/lib/libgmp/mpz/get_str.c b/gnu/lib/libgmp/mpz/get_str.c deleted file mode 100644 index 8ccf3ef..0000000 --- a/gnu/lib/libgmp/mpz/get_str.c +++ /dev/null @@ -1,118 +0,0 @@ -/* mpz_get_str (string, base, mp_src) -- Convert the multiple precision - number MP_SRC to a string STRING of base BASE. If STRING is NULL - allocate space for the result. In any case, return a pointer to the - result. If STRING is not NULL, the caller must ensure enough space is - available to store the result. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -char * -#if __STDC__ -mpz_get_str (char *res_str, int base, mpz_srcptr x) -#else -mpz_get_str (res_str, base, x) - char *res_str; - int base; - mpz_srcptr x; -#endif -{ - mp_ptr xp; - mp_size_t x_size = x->_mp_size; - unsigned char *str; - char *return_str; - size_t str_size; - char *num_to_text; - int i; - TMP_DECL (marker); - - TMP_MARK (marker); - if (base >= 0) - { - if (base == 0) - base = 10; - num_to_text = "0123456789abcdefghijklmnopqrstuvwxyz"; - } - else - { - base = -base; - num_to_text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - } - - /* We allways allocate space for the string. If the caller passed a - NULL pointer for RES_STR, we allocate permanent space and return - a pointer to that to the caller. */ - str_size = ((size_t) (ABS (x_size) * BITS_PER_MP_LIMB - * __mp_bases[base].chars_per_bit_exactly)) + 3; - if (res_str == 0) - { - /* We didn't get a string from the user. Allocate one (and return - a pointer to it). */ - res_str = (char *) (*_mp_allocate_func) (str_size); - /* Make str, the variable used for raw result from mpn_get_str, - point to the same string, but just after a possible minus sign. */ - str = (unsigned char *) res_str + 1; - } - else - { - /* Use TMP_ALLOC to get temporary space, since we need a few extra bytes - that we can't expect to caller to supply us with. */ - str = (unsigned char *) TMP_ALLOC (str_size); - } - - return_str = res_str; - - if (x_size == 0) - { - res_str[0] = '0'; - res_str[1] = 0; - TMP_FREE (marker); - return res_str; - } - if (x_size < 0) - { - *res_str++ = '-'; - x_size = -x_size; - } - - /* Move the number to convert into temporary space, since mpn_get_str - clobbers its argument + needs one extra high limb.... */ - xp = (mp_ptr) TMP_ALLOC ((x_size + 1) * BYTES_PER_MP_LIMB); - MPN_COPY (xp, x->_mp_d, x_size); - - str_size = mpn_get_str (str, base, xp, x_size); - - /* mpn_get_str might make some leading zeros. Skip them. */ - while (*str == 0) - { - str_size--; - str++; - } - - /* Translate result to printable chars and move result to RES_STR. */ - for (i = 0; i < str_size; i++) - res_str[i] = num_to_text[str[i]]; - res_str[str_size] = 0; - - TMP_FREE (marker); - return return_str; -} diff --git a/gnu/lib/libgmp/mpz/get_ui.c b/gnu/lib/libgmp/mpz/get_ui.c deleted file mode 100644 index 4bfb5e1..0000000 --- a/gnu/lib/libgmp/mpz/get_ui.c +++ /dev/null @@ -1,37 +0,0 @@ -/* mpz_get_ui(integer) -- Return the least significant digit from INTEGER. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -unsigned long int -#if __STDC__ -mpz_get_ui (mpz_srcptr integer) -#else -mpz_get_ui (integer) - mpz_srcptr integer; -#endif -{ - if (integer->_mp_size == 0) - return 0; - else - return integer->_mp_d[0]; -} diff --git a/gnu/lib/libgmp/mpz/getlimbn.c b/gnu/lib/libgmp/mpz/getlimbn.c deleted file mode 100644 index c7a234b..0000000 --- a/gnu/lib/libgmp/mpz/getlimbn.c +++ /dev/null @@ -1,38 +0,0 @@ -/* mpz_getlimbn(integer,n) -- Return the N:th limb from INTEGER. - -Copyright (C) 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -mp_limb_t -#if __STDC__ -mpz_getlimbn (mpz_srcptr integer, mp_size_t n) -#else -mpz_getlimbn (integer, n) - mpz_srcptr integer; - mp_size_t n; -#endif -{ - if (integer->_mp_size <= n || n < 0) - return 0; - else - return integer->_mp_d[n]; -} diff --git a/gnu/lib/libgmp/mpz/hamdist.c b/gnu/lib/libgmp/mpz/hamdist.c deleted file mode 100644 index 58c9273..0000000 --- a/gnu/lib/libgmp/mpz/hamdist.c +++ /dev/null @@ -1,62 +0,0 @@ -/* mpz_hamdist(mpz_ptr op1, mpz_ptr op2) -- Compute the hamming distance - between OP1 and OP2. If one of the operands is negative, return ~0. (We - could make the function well-defined when both operands are negative, but - that would probably not be worth the trouble. - -Copyright (C) 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -unsigned long int -#if __STDC__ -mpz_hamdist (mpz_srcptr u, mpz_srcptr v) -#else -mpz_hamdist (u, v) - mpz_srcptr u; - mpz_srcptr v; -#endif -{ - mp_srcptr up, vp; - mp_size_t usize, vsize, size; - unsigned long int count; - - usize = u->_mp_size; - vsize = v->_mp_size; - - if ((usize | vsize) < 0) - return ~ (unsigned long int) 0; - - up = u->_mp_d; - vp = v->_mp_d; - - if (usize > vsize) - { - count = mpn_popcount (up + vsize, usize - vsize); - size = vsize; - } - else - { - count = mpn_popcount (vp + usize, vsize - usize); - size = usize; - } - - return count + mpn_hamdist (up, vp, size); -} diff --git a/gnu/lib/libgmp/mpz/init.c b/gnu/lib/libgmp/mpz/init.c deleted file mode 100644 index f8d8e20..0000000 --- a/gnu/lib/libgmp/mpz/init.c +++ /dev/null @@ -1,36 +0,0 @@ -/* mpz_init() -- Make a new multiple precision number with value 0. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_init (mpz_ptr x) -#else -mpz_init (x) - mpz_ptr x; -#endif -{ - x->_mp_alloc = 1; - x->_mp_d = (mp_ptr) (*_mp_allocate_func) (BYTES_PER_MP_LIMB); - x->_mp_size = 0; -} diff --git a/gnu/lib/libgmp/mpz/inp_raw.c b/gnu/lib/libgmp/mpz/inp_raw.c deleted file mode 100644 index e1cec1d..0000000 --- a/gnu/lib/libgmp/mpz/inp_raw.c +++ /dev/null @@ -1,101 +0,0 @@ -/* mpz_inp_raw -- Input a mpz_t in raw, but endianess, and wordsize - independent format (as output by mpz_out_raw). - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include - -#include "gmp.h" -#include "gmp-impl.h" - -size_t -#if __STDC__ -mpz_inp_raw (mpz_ptr x, FILE *stream) -#else -mpz_inp_raw (x, stream) - mpz_ptr x; - FILE *stream; -#endif -{ - int i; - mp_size_t s; - mp_size_t xsize; - mp_ptr xp; - unsigned int c; - mp_limb_t x_limb; - mp_size_t in_bytesize; - int neg_flag; - - if (stream == 0) - stream = stdin; - - /* Read 4-byte size */ - in_bytesize = 0; - for (i = 4 - 1; i >= 0; i--) - { - c = fgetc (stream); - in_bytesize = (in_bytesize << BITS_PER_CHAR) | c; - } - - /* Size is stored as a 32 bit word; sign extend in_bytesize for non-32 bit - machines. */ - if (sizeof (mp_size_t) > 4) - in_bytesize |= (-(in_bytesize < 0)) << 31; - - neg_flag = in_bytesize < 0; - in_bytesize = ABS (in_bytesize); - xsize = (in_bytesize + BYTES_PER_MP_LIMB - 1) / BYTES_PER_MP_LIMB; - - if (xsize == 0) - { - x->_mp_size = 0; - return 4; /* we've read 4 bytes */ - } - - if (x->_mp_alloc < xsize) - _mpz_realloc (x, xsize); - xp = x->_mp_d; - - x_limb = 0; - for (i = (in_bytesize - 1) % BYTES_PER_MP_LIMB; i >= 0; i--) - { - c = fgetc (stream); - x_limb = (x_limb << BITS_PER_CHAR) | c; - } - xp[xsize - 1] = x_limb; - - for (s = xsize - 2; s >= 0; s--) - { - x_limb = 0; - for (i = BYTES_PER_MP_LIMB - 1; i >= 0; i--) - { - c = fgetc (stream); - x_limb = (x_limb << BITS_PER_CHAR) | c; - } - xp[s] = x_limb; - } - - if (c == EOF) - return 0; /* error */ - - MPN_NORMALIZE (xp, xsize); - x->_mp_size = neg_flag ? -xsize : xsize; - return in_bytesize + 4; -} diff --git a/gnu/lib/libgmp/mpz/inp_str.c b/gnu/lib/libgmp/mpz/inp_str.c deleted file mode 100644 index 7159062..0000000 --- a/gnu/lib/libgmp/mpz/inp_str.c +++ /dev/null @@ -1,138 +0,0 @@ -/* mpz_inp_str(dest_integer, stream, base) -- Input a number in base - BASE from stdio stream STREAM and store the result in DEST_INTEGER. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include -#include "gmp.h" -#include "gmp-impl.h" - -static int -digit_value_in_base (c, base) - int c; - int base; -{ - int digit; - - if (isdigit (c)) - digit = c - '0'; - else if (islower (c)) - digit = c - 'a' + 10; - else if (isupper (c)) - digit = c - 'A' + 10; - else - return -1; - - if (digit < base) - return digit; - return -1; -} - -size_t -#if __STDC__ -mpz_inp_str (mpz_ptr dest, FILE *stream, int base) -#else -mpz_inp_str (dest, stream, base) - mpz_ptr dest; - FILE *stream; - int base; -#endif -{ - char *str; - size_t alloc_size, str_size; - int c; - int negative; - mp_size_t dest_size; - size_t nread; - - if (stream == 0) - stream = stdin; - - alloc_size = 100; - str = (char *) (*_mp_allocate_func) (alloc_size); - str_size = 0; - nread = 0; - - /* Skip whitespace. */ - do - { - c = getc (stream); - nread++; - } - while (isspace (c)); - - negative = 0; - if (c == '-') - { - negative = 1; - c = getc (stream); - } - - if (digit_value_in_base (c, base == 0 ? 10 : base) < 0) - return 0; /* error if no digits */ - - /* If BASE is 0, try to find out the base by looking at the initial - characters. */ - if (base == 0) - { - base = 10; - if (c == '0') - { - base = 8; - c = getc (stream); - nread++; - if (c == 'x' || c == 'X') - { - base = 16; - c = getc (stream); - nread++; - } - } - } - - for (;;) - { - int dig; - if (str_size >= alloc_size) - { - size_t old_alloc_size = alloc_size; - alloc_size = alloc_size * 3 / 2; - str = (char *) (*_mp_reallocate_func) (str, old_alloc_size, alloc_size); - } - dig = digit_value_in_base (c, base); - if (dig < 0) - break; - str[str_size++] = dig; - c = getc (stream); - } - - ungetc (c, stream); - - dest_size = str_size / __mp_bases[base].chars_per_limb + 1; - if (dest->_mp_alloc < dest_size) - _mpz_realloc (dest, dest_size); - - dest_size = mpn_set_str (dest->_mp_d, (unsigned char *) str, str_size, base); - dest->_mp_size = negative ? -dest_size : dest_size; - - (*_mp_free_func) (str, alloc_size); - return str_size + nread; -} diff --git a/gnu/lib/libgmp/mpz/invert.c b/gnu/lib/libgmp/mpz/invert.c deleted file mode 100644 index ff1d6d9..0000000 --- a/gnu/lib/libgmp/mpz/invert.c +++ /dev/null @@ -1,43 +0,0 @@ -/* mpz_invert (inv, x, n). Find multiplicative inverse of X in Z(N). - If X has an inverse, return non-zero and store inverse in INVERSE, - otherwise, return 0 and put garbage in X. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" - -int -#if __STDC__ -mpz_invert (mpz_ptr inverse, mpz_srcptr x, mpz_srcptr n) -#else -mpz_invert (inverse, x, n) - mpz_ptr inverse; - mpz_srcptr x, n; -#endif -{ - mpz_t gcd; - int rv; - - mpz_init (gcd); - mpz_gcdext (gcd, inverse, (mpz_ptr) 0, x, n); - rv = gcd->_mp_size == 1 && (gcd->_mp_d)[0] == 1; - mpz_clear (gcd); - return rv; -} diff --git a/gnu/lib/libgmp/mpz/ior.c b/gnu/lib/libgmp/mpz/ior.c deleted file mode 100644 index 77facfd..0000000 --- a/gnu/lib/libgmp/mpz/ior.c +++ /dev/null @@ -1,243 +0,0 @@ -/* mpz_ior -- Logical inclusive or. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_ior (mpz_ptr res, mpz_srcptr op1, mpz_srcptr op2) -#else -mpz_ior (res, op1, op2) - mpz_ptr res; - mpz_srcptr op1; - mpz_srcptr op2; -#endif -{ - mp_srcptr op1_ptr, op2_ptr; - mp_size_t op1_size, op2_size; - mp_ptr res_ptr; - mp_size_t res_size; - mp_size_t i; - TMP_DECL (marker); - - TMP_MARK (marker); - op1_size = op1->_mp_size; - op2_size = op2->_mp_size; - - op1_ptr = op1->_mp_d; - op2_ptr = op2->_mp_d; - res_ptr = res->_mp_d; - - if (op1_size >= 0) - { - if (op2_size >= 0) - { - if (op1_size >= op2_size) - { - if (res->_mp_alloc < op1_size) - { - _mpz_realloc (res, op1_size); - op1_ptr = op1->_mp_d; - op2_ptr = op2->_mp_d; - res_ptr = res->_mp_d; - } - - if (res_ptr != op1_ptr) - MPN_COPY (res_ptr + op2_size, op1_ptr + op2_size, - op1_size - op2_size); - for (i = op2_size - 1; i >= 0; i--) - res_ptr[i] = op1_ptr[i] | op2_ptr[i]; - res_size = op1_size; - } - else - { - if (res->_mp_alloc < op2_size) - { - _mpz_realloc (res, op2_size); - op1_ptr = op1->_mp_d; - op2_ptr = op2->_mp_d; - res_ptr = res->_mp_d; - } - - if (res_ptr != op2_ptr) - MPN_COPY (res_ptr + op1_size, op2_ptr + op1_size, - op2_size - op1_size); - for (i = op1_size - 1; i >= 0; i--) - res_ptr[i] = op1_ptr[i] | op2_ptr[i]; - res_size = op2_size; - } - - res->_mp_size = res_size; - return; - } - else /* op2_size < 0 */ - { - /* Fall through to the code at the end of the function. */ - } - } - else - { - if (op2_size < 0) - { - mp_ptr opx; - mp_limb_t cy; - - /* Both operands are negative, so will be the result. - -((-OP1) | (-OP2)) = -(~(OP1 - 1) | ~(OP2 - 1)) = - = ~(~(OP1 - 1) | ~(OP2 - 1)) + 1 = - = ((OP1 - 1) & (OP2 - 1)) + 1 */ - - op1_size = -op1_size; - op2_size = -op2_size; - - res_size = MIN (op1_size, op2_size); - - /* Possible optimization: Decrease mpn_sub precision, - as we won't use the entire res of both. */ - opx = (mp_ptr) TMP_ALLOC (res_size * BYTES_PER_MP_LIMB); - mpn_sub_1 (opx, op1_ptr, res_size, (mp_limb_t) 1); - op1_ptr = opx; - - opx = (mp_ptr) TMP_ALLOC (res_size * BYTES_PER_MP_LIMB); - mpn_sub_1 (opx, op2_ptr, res_size, (mp_limb_t) 1); - op2_ptr = opx; - - if (res->_mp_alloc < res_size) - { - _mpz_realloc (res, res_size); - res_ptr = res->_mp_d; - /* Don't re-read OP1_PTR and OP2_PTR. They point to - temporary space--never to the space RES->_mp_D used - to point to before reallocation. */ - } - - /* First loop finds the size of the result. */ - for (i = res_size - 1; i >= 0; i--) - if ((op1_ptr[i] & op2_ptr[i]) != 0) - break; - res_size = i + 1; - - if (res_size != 0) - { - /* Second loop computes the real result. */ - for (i = res_size - 1; i >= 0; i--) - res_ptr[i] = op1_ptr[i] & op2_ptr[i]; - - cy = mpn_add_1 (res_ptr, res_ptr, res_size, (mp_limb_t) 1); - if (cy) - { - res_ptr[res_size] = cy; - res_size++; - } - } - else - { - res_ptr[0] = 1; - res_size = 1; - } - - res->_mp_size = -res_size; - TMP_FREE (marker); - return; - } - else - { - /* We should compute -OP1 | OP2. Swap OP1 and OP2 and fall - through to the code that handles OP1 | -OP2. */ - {mpz_srcptr t = op1; op1 = op2; op2 = t;} - {mp_srcptr t = op1_ptr; op1_ptr = op2_ptr; op2_ptr = t;} - {mp_size_t t = op1_size; op1_size = op2_size; op2_size = t;} - } - } - - { - mp_ptr opx; - mp_limb_t cy; - mp_size_t res_alloc; - mp_size_t count; - - /* Operand 2 negative, so will be the result. - -(OP1 | (-OP2)) = -(OP1 | ~(OP2 - 1)) = - = ~(OP1 | ~(OP2 - 1)) + 1 = - = (~OP1 & (OP2 - 1)) + 1 */ - - op2_size = -op2_size; - - res_alloc = op2_size; - - opx = (mp_ptr) TMP_ALLOC (op2_size * BYTES_PER_MP_LIMB); - mpn_sub_1 (opx, op2_ptr, op2_size, (mp_limb_t) 1); - op2_ptr = opx; - - if (res->_mp_alloc < res_alloc) - { - _mpz_realloc (res, res_alloc); - op1_ptr = op1->_mp_d; - res_ptr = res->_mp_d; - /* Don't re-read OP2_PTR. It points to temporary space--never - to the space RES->_mp_D used to point to before reallocation. */ - } - - if (op1_size >= op2_size) - { - /* We can just ignore the part of OP1 that stretches above OP2, - because the result limbs are zero there. */ - - /* First loop finds the size of the result. */ - for (i = op2_size - 1; i >= 0; i--) - if ((~op1_ptr[i] & op2_ptr[i]) != 0) - break; - res_size = i + 1; - count = res_size; - } - else - { - res_size = op2_size; - - /* Copy the part of OP2 that stretches above OP1, to RES. */ - MPN_COPY (res_ptr + op1_size, op2_ptr + op1_size, op2_size - op1_size); - count = op1_size; - } - - if (res_size != 0) - { - /* Second loop computes the real result. */ - for (i = count - 1; i >= 0; i--) - res_ptr[i] = ~op1_ptr[i] & op2_ptr[i]; - - cy = mpn_add_1 (res_ptr, res_ptr, res_size, (mp_limb_t) 1); - if (cy) - { - res_ptr[res_size] = cy; - res_size++; - } - } - else - { - res_ptr[0] = 1; - res_size = 1; - } - - res->_mp_size = -res_size; - } - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/iset.c b/gnu/lib/libgmp/mpz/iset.c deleted file mode 100644 index c8a17dc..0000000 --- a/gnu/lib/libgmp/mpz/iset.c +++ /dev/null @@ -1,49 +0,0 @@ -/* mpz_init_set (src_integer) -- Make a new multiple precision number with - a value copied from SRC_INTEGER. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_init_set (mpz_ptr w, mpz_srcptr u) -#else -mpz_init_set (w, u) - mpz_ptr w; - mpz_srcptr u; -#endif -{ - mp_ptr wp, up; - mp_size_t usize, size; - - usize = u->_mp_size; - size = ABS (usize); - - w->_mp_alloc = MAX (size, 1); - w->_mp_d = (mp_ptr) (*_mp_allocate_func) (w->_mp_alloc * BYTES_PER_MP_LIMB); - - wp = w->_mp_d; - up = u->_mp_d; - - MPN_COPY (wp, up, size); - w->_mp_size = usize; -} diff --git a/gnu/lib/libgmp/mpz/iset_d.c b/gnu/lib/libgmp/mpz/iset_d.c deleted file mode 100644 index 41e5c4f..0000000 --- a/gnu/lib/libgmp/mpz/iset_d.c +++ /dev/null @@ -1,39 +0,0 @@ -/* mpz_init_set_d(integer, val) -- Initialize and assign INTEGER with a double - value VAL. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_init_set_d (mpz_ptr dest, double val) -#else -mpz_init_set_d (dest, val) - mpz_ptr dest; - double val; -#endif -{ - dest->_mp_alloc = 1; - dest->_mp_d = (mp_ptr) (*_mp_allocate_func) (BYTES_PER_MP_LIMB); - dest->_mp_size = 0; - mpz_set_d (dest, val); -} diff --git a/gnu/lib/libgmp/mpz/iset_si.c b/gnu/lib/libgmp/mpz/iset_si.c deleted file mode 100644 index af51f05..0000000 --- a/gnu/lib/libgmp/mpz/iset_si.c +++ /dev/null @@ -1,49 +0,0 @@ -/* mpz_init_set_si(val) -- Make a new multiple precision number with - value val. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_init_set_si (mpz_ptr x, signed long int val) -#else -mpz_init_set_si (x, val) - mpz_ptr x; - signed long int val; -#endif -{ - x->_mp_alloc = 1; - x->_mp_d = (mp_ptr) (*_mp_allocate_func) (BYTES_PER_MP_LIMB); - if (val > 0) - { - x->_mp_d[0] = val; - x->_mp_size = 1; - } - else if (val < 0) - { - x->_mp_d[0] = -val; - x->_mp_size = -1; - } - else - x->_mp_size = 0; -} diff --git a/gnu/lib/libgmp/mpz/iset_str.c b/gnu/lib/libgmp/mpz/iset_str.c deleted file mode 100644 index e04ad5d..0000000 --- a/gnu/lib/libgmp/mpz/iset_str.c +++ /dev/null @@ -1,44 +0,0 @@ -/* mpz_init_set_str(string, base) -- Convert the \0-terminated string - STRING in base BASE to a multiple precision integer. Return a MP_INT - structure representing the integer. Allow white space in the - string. If BASE == 0 determine the base in the C standard way, - i.e. 0xhh...h means base 16, 0oo...o means base 8, otherwise - assume base 10. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -int -#if __STDC__ -mpz_init_set_str (mpz_ptr x, const char *str, int base) -#else -mpz_init_set_str (x, str, base) - mpz_ptr x; - const char *str; - int base; -#endif -{ - x->_mp_alloc = 1; - x->_mp_d = (mp_ptr) (*_mp_allocate_func) (BYTES_PER_MP_LIMB); - - return mpz_set_str (x, str, base); -} diff --git a/gnu/lib/libgmp/mpz/iset_ui.c b/gnu/lib/libgmp/mpz/iset_ui.c deleted file mode 100644 index dc39f59..0000000 --- a/gnu/lib/libgmp/mpz/iset_ui.c +++ /dev/null @@ -1,39 +0,0 @@ -/* mpz_init_set_ui(val) -- Make a new multiple precision number with - value val. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_init_set_ui (mpz_ptr x, unsigned long int val) -#else -mpz_init_set_ui (x, val) - mpz_ptr x; - unsigned long int val; -#endif -{ - x->_mp_alloc = 1; - x->_mp_d = (mp_ptr) (*_mp_allocate_func) (BYTES_PER_MP_LIMB); - x->_mp_d[0] = val; - x->_mp_size = val != 0; -} diff --git a/gnu/lib/libgmp/mpz/jacobi.c b/gnu/lib/libgmp/mpz/jacobi.c deleted file mode 100644 index 409f622..0000000 --- a/gnu/lib/libgmp/mpz/jacobi.c +++ /dev/null @@ -1,53 +0,0 @@ -/* mpz_jacobi (op1, op2). - Contributed by Bennet Yee (bsy) at Carnegie-Mellon University - -Copyright (C) 1991, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" - -/* Precondition: both p and q are positive */ - -int -#if __STDC__ -mpz_jacobi (mpz_srcptr pi, mpz_srcptr qi) -#else -mpz_jacobi (pi, qi) - mpz_srcptr pi, qi; -#endif -{ -#if GCDCHECK - int retval; - mpz_t gcdval; - - mpz_init (gcdval); - mpz_gcd (gcdval, pi, qi); - if (!mpz_cmp_ui (gcdval, 1L)) - { - /* J(ab,cb) = J(ab,c)J(ab,b) = J(ab,c)J(0,b) = J(ab,c)*0 */ - retval = 0; - } - else - retval = mpz_legendre (pi, qi); - mpz_clear (gcdval); - return retval; -#else - return mpz_legendre (pi, qi); -#endif -} diff --git a/gnu/lib/libgmp/mpz/legendre.c b/gnu/lib/libgmp/mpz/legendre.c deleted file mode 100644 index 4de16a6..0000000 --- a/gnu/lib/libgmp/mpz/legendre.c +++ /dev/null @@ -1,184 +0,0 @@ -/* mpz_legendre (op1, op2). - Contributed by Bennet Yee (bsy) at Carnegie-Mellon University - -Copyright (C) 1992, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" - -#if defined (DEBUG) -#include -#endif - -/* Precondition: both p and q are positive */ - -int -#if __STDC__ -mpz_legendre (mpz_srcptr pi, mpz_srcptr qi) -#else -mpz_legendre (pi, qi) -mpz_srcptr pi, qi; -#endif -{ - mpz_t p, q, qdiv2; -#ifdef Q_MINUS_1 - mpz_t q_minus_1; -#endif - mpz_ptr mtmp; - register mpz_ptr pptr, qptr; - register int retval = 1; - register unsigned long int s; - - pptr = p; - mpz_init_set (pptr, pi); - qptr = q; - mpz_init_set (qptr, qi); - -#ifdef Q_MINUS_1 - mpz_init (q_minus_1); -#endif - mpz_init (qdiv2); - -tail_recurse2: -#ifdef DEBUG - printf ("tail_recurse2: p="); - mpz_out_str (stdout, 10, pptr); - printf ("\nq="); - mpz_out_str (stdout, 10, qptr); - putchar ('\n'); -#endif - s = mpz_scan1 (qptr, 0); - if (s) mpz_tdiv_q_2exp (qptr, qptr, s); /* J(a,2) = 1 */ -#ifdef DEBUG - printf ("2 factor decomposition: p="); - mpz_out_str (stdout, 10, pptr); - printf ("\nq="); - mpz_out_str (stdout, 10, qptr); - putchar ('\n'); -#endif - /* postcondition q odd */ - if (!mpz_cmp_ui (qptr, 1L)) /* J(a,1) = 1 */ - goto done; - mpz_mod (pptr, pptr, qptr); /* J(a,q) = J(b,q) when a == b mod q */ -#ifdef DEBUG - printf ("mod out by q: p="); - mpz_out_str (stdout, 10, pptr); - printf ("\nq="); - mpz_out_str (stdout, 10, qptr); - putchar ('\n'); -#endif - /* quick calculation to get approximate size first */ - /* precondition: p < q */ - if ((mpz_sizeinbase (pptr, 2) + 1 >= mpz_sizeinbase (qptr,2)) - && (mpz_tdiv_q_2exp (qdiv2, qptr, 1L), mpz_cmp (pptr, qdiv2) > 0)) - { - /* p > q/2 */ - mpz_sub (pptr, qptr, pptr); - /* J(-1,q) = (-1)^((q-1)/2), q odd */ - if (mpz_get_ui (qptr) & 2) - retval = -retval; - } - /* p < q/2 */ -#ifdef Q_MINUS_1 - mpz_sub_ui (q_minus_q, qptr, 1L); -#endif -tail_recurse: /* we use tail_recurse only if q has not changed */ -#ifdef DEBUG - printf ("tail_recurse1: p="); - mpz_out_str (stdout, 10, pptr); - printf ("\nq="); - mpz_out_str (stdout, 10, qptr); - putchar ('\n'); -#endif - /* - * J(0,q) = 0 - * this occurs only if gcd(p,q) != 1 which is never true for - * Legendre function. - */ - if (!mpz_cmp_ui (pptr, 0L)) - { - retval = 0; - goto done; - } - - if (!mpz_cmp_ui (pptr, 1L)) - { - /* J(1,q) = 1 */ - /* retval *= 1; */ - goto done; - } -#ifdef Q_MINUS_1 - if (!mpz_cmp (pptr, q_minus_1)) - { - /* J(-1,q) = (-1)^((q-1)/2) */ - if (mpz_get_ui (qptr) & 2) - retval = -retval; - /* else retval *= 1; */ - goto done; - } -#endif - /* - * we do not handle J(xy,q) except for x==2 - * since we do not want to factor - */ - if ((s = mpz_scan1 (pptr, 0)) != 0) - { - /* - * J(2,q) = (-1)^((q^2-1)/8) - * - * Note that q odd guarantees that q^2-1 is divisible by 8: - * Let a: q=2a+1. q^2 = 4a^2+4a+1, (q^2-1)/8 = a(a+1)/2, qed - * - * Now, note that this means that the low two bits of _a_ - * (or the low bits of q shifted over by 1 determines - * the factor). - */ - mpz_tdiv_q_2exp (pptr, pptr, s); - - /* even powers of 2 gives J(2,q)^{2n} = 1 */ - if (s & 1) - { - s = mpz_get_ui (qptr) >> 1; - s = s * (s + 1); - if (s & 2) - retval = -retval; - } - goto tail_recurse; - } - /* - * we know p is odd since we have cast out 2s - * precondition that q is odd guarantees both odd. - * - * quadratic reciprocity - * J(p,q) = (-1)^((p-1)(q-1)/4) * J(q,p) - */ - if ((s = mpz_scan1 (pptr, 1)) <= 2 && (s + mpz_scan1 (qptr, 1)) <= 2) - retval = -retval; - - mtmp = pptr; pptr = qptr; qptr = mtmp; - goto tail_recurse2; -done: - mpz_clear (p); - mpz_clear (q); - mpz_clear (qdiv2); -#ifdef Q_MINUS_1 - mpz_clear (q_minus_1); -#endif - return retval; -} diff --git a/gnu/lib/libgmp/mpz/mod.c b/gnu/lib/libgmp/mpz/mod.c deleted file mode 100644 index b2b8b39..0000000 --- a/gnu/lib/libgmp/mpz/mod.c +++ /dev/null @@ -1,63 +0,0 @@ -/* mpz_mod -- The mathematical mod function. - -Copyright (C) 1991, 1993, 1994, 1995, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_mod (mpz_ptr rem, mpz_srcptr dividend, mpz_srcptr divisor) -#else -mpz_mod (rem, dividend, divisor) - mpz_ptr rem; - mpz_srcptr dividend; - mpz_srcptr divisor; -#endif -{ - mp_size_t divisor_size = divisor->_mp_size; - mpz_t temp_divisor; /* N.B.: lives until function returns! */ - TMP_DECL (marker); - - TMP_MARK (marker); - - /* We need the original value of the divisor after the remainder has been - preliminary calculated. We have to copy it to temporary space if it's - the same variable as REM. */ - if (rem == divisor) - { - MPZ_TMP_INIT (temp_divisor, ABS (divisor_size)); - mpz_set (temp_divisor, divisor); - divisor = temp_divisor; - } - - mpz_tdiv_r (rem, dividend, divisor); - - if (rem->_mp_size != 0) - { - if (dividend->_mp_size < 0) - if (divisor->_mp_size < 0) - mpz_sub (rem, rem, divisor); - else - mpz_add (rem, rem, divisor); - } - - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/mul.c b/gnu/lib/libgmp/mpz/mul.c deleted file mode 100644 index 47ce8e3..0000000 --- a/gnu/lib/libgmp/mpz/mul.c +++ /dev/null @@ -1,127 +0,0 @@ -/* mpz_mul -- Multiply two integers. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -#ifndef BERKELEY_MP -void -#if __STDC__ -mpz_mul (mpz_ptr w, mpz_srcptr u, mpz_srcptr v) -#else -mpz_mul (w, u, v) - mpz_ptr w; - mpz_srcptr u; - mpz_srcptr v; -#endif -#else /* BERKELEY_MP */ -void -#if __STDC__ -mult (mpz_srcptr u, mpz_srcptr v, mpz_ptr w) -#else -mult (u, v, w) - mpz_srcptr u; - mpz_srcptr v; - mpz_ptr w; -#endif -#endif /* BERKELEY_MP */ -{ - mp_size_t usize = u->_mp_size; - mp_size_t vsize = v->_mp_size; - mp_size_t wsize; - mp_size_t sign_product; - mp_ptr up, vp; - mp_ptr wp; - mp_ptr free_me = NULL; - size_t free_me_size; - mp_limb_t cy_limb; - TMP_DECL (marker); - - TMP_MARK (marker); - sign_product = usize ^ vsize; - usize = ABS (usize); - vsize = ABS (vsize); - - if (usize < vsize) - { - /* Swap U and V. */ - {const __mpz_struct *t = u; u = v; v = t;} - {mp_size_t t = usize; usize = vsize; vsize = t;} - } - - up = u->_mp_d; - vp = v->_mp_d; - wp = w->_mp_d; - - /* Ensure W has space enough to store the result. */ - wsize = usize + vsize; - if (w->_mp_alloc < wsize) - { - if (wp == up || wp == vp) - { - free_me = wp; - free_me_size = w->_mp_alloc; - } - else - (*_mp_free_func) (wp, w->_mp_alloc * BYTES_PER_MP_LIMB); - - w->_mp_alloc = wsize; - wp = (mp_ptr) (*_mp_allocate_func) (wsize * BYTES_PER_MP_LIMB); - w->_mp_d = wp; - } - else - { - /* Make U and V not overlap with W. */ - if (wp == up) - { - /* W and U are identical. Allocate temporary space for U. */ - up = (mp_ptr) TMP_ALLOC (usize * BYTES_PER_MP_LIMB); - /* Is V identical too? Keep it identical with U. */ - if (wp == vp) - vp = up; - /* Copy to the temporary space. */ - MPN_COPY (up, wp, usize); - } - else if (wp == vp) - { - /* W and V are identical. Allocate temporary space for V. */ - vp = (mp_ptr) TMP_ALLOC (vsize * BYTES_PER_MP_LIMB); - /* Copy to the temporary space. */ - MPN_COPY (vp, wp, vsize); - } - } - - if (vsize == 0) - { - wsize = 0; - } - else - { - cy_limb = mpn_mul (wp, up, usize, vp, vsize); - wsize = usize + vsize; - wsize -= cy_limb == 0; - } - - w->_mp_size = sign_product < 0 ? -wsize : wsize; - if (free_me != NULL) - (*_mp_free_func) (free_me, free_me_size * BYTES_PER_MP_LIMB); - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/mul_2exp.c b/gnu/lib/libgmp/mpz/mul_2exp.c deleted file mode 100644 index 4d66a98..0000000 --- a/gnu/lib/libgmp/mpz/mul_2exp.c +++ /dev/null @@ -1,76 +0,0 @@ -/* mpz_mul_2exp -- Multiply a bignum by 2**CNT - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_mul_2exp (mpz_ptr w, mpz_srcptr u, unsigned long int cnt) -#else -mpz_mul_2exp (w, u, cnt) - mpz_ptr w; - mpz_srcptr u; - unsigned long int cnt; -#endif -{ - mp_size_t usize = u->_mp_size; - mp_size_t abs_usize = ABS (usize); - mp_size_t wsize; - mp_size_t limb_cnt; - mp_ptr wp; - mp_limb_t wlimb; - - if (usize == 0) - { - w->_mp_size = 0; - return; - } - - limb_cnt = cnt / BITS_PER_MP_LIMB; - wsize = abs_usize + limb_cnt + 1; - if (w->_mp_alloc < wsize) - _mpz_realloc (w, wsize); - - wp = w->_mp_d; - wsize = abs_usize + limb_cnt; - - cnt %= BITS_PER_MP_LIMB; - if (cnt != 0) - { - wlimb = mpn_lshift (wp + limb_cnt, u->_mp_d, abs_usize, cnt); - if (wlimb != 0) - { - wp[wsize] = wlimb; - wsize++; - } - } - else - { - MPN_COPY_DECR (wp + limb_cnt, u->_mp_d, abs_usize); - } - - /* Zero all whole limbs at low end. Do it here and not before calling - mpn_lshift, not to lose for U == W. */ - MPN_ZERO (wp, limb_cnt); - - w->_mp_size = usize >= 0 ? wsize : -wsize; -} diff --git a/gnu/lib/libgmp/mpz/mul_ui.c b/gnu/lib/libgmp/mpz/mul_ui.c deleted file mode 100644 index f1f7269..0000000 --- a/gnu/lib/libgmp/mpz/mul_ui.c +++ /dev/null @@ -1,64 +0,0 @@ -/* mpz_mul_ui(product, multiplier, small_multiplicand) -- Set - PRODUCT to MULTIPLICATOR times SMALL_MULTIPLICAND. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_mul_ui (mpz_ptr prod, mpz_srcptr mult, unsigned long int small_mult) -#else -mpz_mul_ui (prod, mult, small_mult) - mpz_ptr prod; - mpz_srcptr mult; - unsigned long int small_mult; -#endif -{ - mp_size_t size = mult->_mp_size; - mp_size_t sign_product = size; - mp_limb_t cy; - mp_size_t prod_size; - mp_ptr prod_ptr; - - size = ABS (size); - - if (size == 0 || small_mult == 0) - { - prod->_mp_size = 0; - return; - } - - prod_size = size + 1; - if (prod->_mp_alloc < prod_size) - _mpz_realloc (prod, prod_size); - - prod_ptr = prod->_mp_d; - - cy = mpn_mul_1 (prod_ptr, mult->_mp_d, size, (mp_limb_t) small_mult); - if (cy != 0) - { - prod_ptr[size] = cy; - size++; - } - - prod->_mp_size = sign_product >= 0 ? size : -size; -} diff --git a/gnu/lib/libgmp/mpz/neg.c b/gnu/lib/libgmp/mpz/neg.c deleted file mode 100644 index 0b48e5c..0000000 --- a/gnu/lib/libgmp/mpz/neg.c +++ /dev/null @@ -1,53 +0,0 @@ -/* mpz_neg(mpz_ptr dst, mpz_ptr src) -- Assign the negated value of SRC to DST. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_neg (mpz_ptr w, mpz_srcptr u) -#else -mpz_neg (w, u) - mpz_ptr w; - mpz_srcptr u; -#endif -{ - mp_ptr wp, up; - mp_size_t usize, size; - - usize = u->_mp_size; - - if (u != w) - { - size = ABS (usize); - - if (w->_mp_alloc < size) - _mpz_realloc (w, size); - - wp = w->_mp_d; - up = u->_mp_d; - - MPN_COPY (wp, up, size); - } - - w->_mp_size = -usize; -} diff --git a/gnu/lib/libgmp/mpz/out_raw.c b/gnu/lib/libgmp/mpz/out_raw.c deleted file mode 100644 index 35d311b..0000000 --- a/gnu/lib/libgmp/mpz/out_raw.c +++ /dev/null @@ -1,89 +0,0 @@ -/* mpz_out_raw -- Output a mpz_t in binary. Use an endianess and word size - independent format. - -Copyright (C) 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include - -#include "gmp.h" -#include "gmp-impl.h" - -size_t -#if __STDC__ -mpz_out_raw (FILE *stream, mpz_srcptr x) -#else -mpz_out_raw (stream, x) - FILE *stream; - mpz_srcptr x; -#endif -{ - int i; - mp_size_t s; - mp_size_t xsize = ABS (x->_mp_size); - mp_srcptr xp = x->_mp_d; - mp_size_t out_bytesize; - mp_limb_t hi_limb; - int n_bytes_in_hi_limb; - - if (stream == 0) - stream = stdout; - - if (xsize == 0) - { - for (i = 4 - 1; i >= 0; i--) - fputc (0, stream); - return ferror (stream) ? 0 : 4; - } - - hi_limb = xp[xsize - 1]; - for (i = BYTES_PER_MP_LIMB - 1; i > 0; i--) - { - if ((hi_limb >> i * BITS_PER_CHAR) != 0) - break; - } - n_bytes_in_hi_limb = i + 1; - out_bytesize = BYTES_PER_MP_LIMB * (xsize - 1) + n_bytes_in_hi_limb; - if (x->_mp_size < 0) - out_bytesize = -out_bytesize; - - /* Make the size 4 bytes on all machines, to make the format portable. */ - for (i = 4 - 1; i >= 0; i--) - fputc ((out_bytesize >> (i * BITS_PER_CHAR)) % (1 << BITS_PER_CHAR), - stream); - - /* Output from the most significant limb to the least significant limb, - with each limb also output in decreasing significance order. */ - - /* Output the most significant limb separately, since we will only - output some of its bytes. */ - for (i = n_bytes_in_hi_limb - 1; i >= 0; i--) - fputc ((hi_limb >> (i * BITS_PER_CHAR)) % (1 << BITS_PER_CHAR), stream); - - /* Output the remaining limbs. */ - for (s = xsize - 2; s >= 0; s--) - { - mp_limb_t x_limb; - - x_limb = xp[s]; - for (i = BYTES_PER_MP_LIMB - 1; i >= 0; i--) - fputc ((x_limb >> (i * BITS_PER_CHAR)) % (1 << BITS_PER_CHAR), stream); - } - return ferror (stream) ? 0 : ABS (out_bytesize) + 4; -} diff --git a/gnu/lib/libgmp/mpz/out_str.c b/gnu/lib/libgmp/mpz/out_str.c deleted file mode 100644 index 909f533..0000000 --- a/gnu/lib/libgmp/mpz/out_str.c +++ /dev/null @@ -1,108 +0,0 @@ -/* mpz_out_str(stream, base, integer) -- Output to STREAM the multi prec. - integer INTEGER in base BASE. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" - -size_t -#if __STDC__ -mpz_out_str (FILE *stream, int base, mpz_srcptr x) -#else -mpz_out_str (stream, base, x) - FILE *stream; - int base; - mpz_srcptr x; -#endif -{ - mp_ptr xp; - mp_size_t x_size = x->_mp_size; - unsigned char *str; - size_t str_size; - size_t i; - size_t written; - char *num_to_text; - TMP_DECL (marker); - - if (stream == 0) - stream = stdout; - - if (base >= 0) - { - if (base == 0) - base = 10; - num_to_text = "0123456789abcdefghijklmnopqrstuvwxyz"; - } - else - { - base = -base; - num_to_text = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - } - - if (x_size == 0) - { - fputc ('0', stream); - return ferror (stream) ? 0 : 1; - } - - written = 0; - - if (x_size < 0) - { - fputc ('-', stream); - x_size = -x_size; - written = 1; - } - - TMP_MARK (marker); - str_size = ((size_t) (x_size * BITS_PER_MP_LIMB - * __mp_bases[base].chars_per_bit_exactly)) + 3; - str = (unsigned char *) TMP_ALLOC (str_size); - - /* Move the number to convert into temporary space, since mpn_get_str - clobbers its argument + needs one extra high limb.... */ - xp = (mp_ptr) TMP_ALLOC ((x_size + 1) * BYTES_PER_MP_LIMB); - MPN_COPY (xp, x->_mp_d, x_size); - - str_size = mpn_get_str (str, base, xp, x_size); - - /* mpn_get_str might make some leading zeros. Skip them. */ - while (*str == 0) - { - str_size--; - str++; - } - - /* Translate to printable chars. */ - for (i = 0; i < str_size; i++) - str[i] = num_to_text[str[i]]; - str[str_size] = 0; - - { - size_t fwret; - fwret = fwrite ((char *) str, 1, str_size, stream); - written += fwret; - } - - TMP_FREE (marker); - return ferror (stream) ? 0 : written; -} diff --git a/gnu/lib/libgmp/mpz/perfsqr.c b/gnu/lib/libgmp/mpz/perfsqr.c deleted file mode 100644 index cdf1b5a..0000000 --- a/gnu/lib/libgmp/mpz/perfsqr.c +++ /dev/null @@ -1,41 +0,0 @@ -/* mpz_perfect_square_p(arg) -- Return non-zero if ARG is a perfect square, - zero otherwise. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -int -#if __STDC__ -mpz_perfect_square_p (mpz_srcptr a) -#else -mpz_perfect_square_p (a) - mpz_srcptr a; -#endif -{ - mp_size_t asize = a->_mp_size; - - /* No negative numbers are perfect squares. */ - if (asize < 0) - return 0; - - return mpn_perfect_square_p (a->_mp_d, asize); -} diff --git a/gnu/lib/libgmp/mpz/popcount.c b/gnu/lib/libgmp/mpz/popcount.c deleted file mode 100644 index a979380..0000000 --- a/gnu/lib/libgmp/mpz/popcount.c +++ /dev/null @@ -1,42 +0,0 @@ -/* mpz_popcount(mpz_ptr op) -- Population count of OP. If the operand is - negative, return ~0 (a novel representation of infinity). - -Copyright (C) 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -unsigned long int -#if __STDC__ -mpz_popcount (mpz_srcptr u) -#else -mpz_popcount (u) - mpz_srcptr u; -#endif -{ - mp_size_t usize; - - usize = u->_mp_size; - - if ((usize) < 0) - return ~ (unsigned long int) 0; - - return mpn_popcount (u->_mp_d, usize); -} diff --git a/gnu/lib/libgmp/mpz/pow_ui.c b/gnu/lib/libgmp/mpz/pow_ui.c deleted file mode 100644 index d8cf7a6..0000000 --- a/gnu/lib/libgmp/mpz/pow_ui.c +++ /dev/null @@ -1,129 +0,0 @@ -/* mpz_pow_ui(res, base, exp) -- Set RES to BASE**EXP. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#ifdef BERKELEY_MP -#include "mp.h" -#endif -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -#ifndef BERKELEY_MP -void -#if __STDC__ -mpz_pow_ui (mpz_ptr r, mpz_srcptr b, unsigned long int e) -#else -mpz_pow_ui (r, b, e) - mpz_ptr r; - mpz_srcptr b; - unsigned long int e; -#endif -#else /* BERKELEY_MP */ -void -#if __STDC__ -rpow (const MINT *b, signed short int e, MINT *r) -#else -rpow (b, e, r) - const MINT *b; - signed short int e; - MINT *r; -#endif -#endif /* BERKELEY_MP */ -{ - mp_ptr rp, bp, tp, xp; - mp_size_t rsize, bsize; - int cnt, i; - mp_limb_t blimb; - TMP_DECL (marker); - - bsize = ABS (b->_mp_size); - - /* Single out cases that give result == 0 or 1. These tests are here - to simplify the general code below, not to optimize. */ - if (e == 0) - { - r->_mp_d[0] = 1; - r->_mp_size = 1; - return; - } - if (bsize == 0 -#ifdef BERKELEY_MP - || e < 0 -#endif - ) - { - r->_mp_size = 0; - return; - } - - bp = b->_mp_d; - - blimb = bp[bsize - 1]; - if (bsize == 1 && blimb < 0x100) - { - /* Estimate space requirements accurately. Using the code from the - `else' path would over-estimate space requirements wildly. */ - float lb = __mp_bases[blimb].chars_per_bit_exactly; - rsize = 2 + ((mp_size_t) (e / lb) / BITS_PER_MP_LIMB); - } - else - { - /* Over-estimate space requirements somewhat. */ - count_leading_zeros (cnt, blimb); - rsize = bsize * e - cnt * e / BITS_PER_MP_LIMB + 1; - } - - TMP_MARK (marker); - - /* The two areas are used to alternatingly hold the input and recieve the - product for mpn_mul. (This scheme is used to fulfill the requirements - of mpn_mul; that the product space may not be the same as any of the - input operands.) */ - rp = (mp_ptr) TMP_ALLOC (rsize * BYTES_PER_MP_LIMB); - tp = (mp_ptr) TMP_ALLOC (rsize * BYTES_PER_MP_LIMB); - - MPN_COPY (rp, bp, bsize); - rsize = bsize; - count_leading_zeros (cnt, e); - - for (i = BITS_PER_MP_LIMB - cnt - 2; i >= 0; i--) - { - mpn_mul_n (tp, rp, rp, rsize); - rsize = 2 * rsize; - rsize -= tp[rsize - 1] == 0; - xp = tp; tp = rp; rp = xp; - - if ((e & ((mp_limb_t) 1 << i)) != 0) - { - rsize = rsize + bsize - (mpn_mul (tp, rp, rsize, bp, bsize) == 0); - xp = tp; tp = rp; rp = xp; - } - } - - /* Now then we know the exact space requirements, reallocate if - necessary. */ - if (r->_mp_alloc < rsize) - _mpz_realloc (r, rsize); - - MPN_COPY (r->_mp_d, rp, rsize); - r->_mp_size = (e & 1) == 0 || b->_mp_size >= 0 ? rsize : -rsize; - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/powm.c b/gnu/lib/libgmp/mpz/powm.c deleted file mode 100644 index 5dcd1b1..0000000 --- a/gnu/lib/libgmp/mpz/powm.c +++ /dev/null @@ -1,276 +0,0 @@ -/* mpz_powm(res,base,exp,mod) -- Set RES to (base**exp) mod MOD. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -#ifndef BERKELEY_MP -void -#if __STDC__ -mpz_powm (mpz_ptr res, mpz_srcptr base, mpz_srcptr exp, mpz_srcptr mod) -#else -mpz_powm (res, base, exp, mod) - mpz_ptr res; - mpz_srcptr base; - mpz_srcptr exp; - mpz_srcptr mod; -#endif -#else /* BERKELEY_MP */ -void -#if __STDC__ -pow (mpz_srcptr base, mpz_srcptr exp, mpz_srcptr mod, mpz_ptr res) -#else -pow (base, exp, mod, res) - mpz_srcptr base; - mpz_srcptr exp; - mpz_srcptr mod; - mpz_ptr res; -#endif -#endif /* BERKELEY_MP */ -{ - mp_ptr rp, ep, mp, bp; - mp_size_t esize, msize, bsize, rsize; - mp_size_t size; - int mod_shift_cnt; - int negative_result; - mp_limb_t *free_me = NULL; - size_t free_me_size; - TMP_DECL (marker); - - esize = ABS (exp->_mp_size); - msize = ABS (mod->_mp_size); - size = 2 * msize; - - rp = res->_mp_d; - ep = exp->_mp_d; - - if (msize == 0) - msize = 1 / msize; /* provoke a signal */ - - if (esize == 0) - { - /* Exponent is zero, result is 1 mod MOD, i.e., 1 or 0 - depending on if MOD equals 1. */ - rp[0] = 1; - res->_mp_size = (msize == 1 && (mod->_mp_d)[0] == 1) ? 0 : 1; - return; - } - - TMP_MARK (marker); - - /* Normalize MOD (i.e. make its most significant bit set) as required by - mpn_divmod. This will make the intermediate values in the calculation - slightly larger, but the correct result is obtained after a final - reduction using the original MOD value. */ - - mp = (mp_ptr) TMP_ALLOC (msize * BYTES_PER_MP_LIMB); - count_leading_zeros (mod_shift_cnt, mod->_mp_d[msize - 1]); - if (mod_shift_cnt != 0) - mpn_lshift (mp, mod->_mp_d, msize, mod_shift_cnt); - else - MPN_COPY (mp, mod->_mp_d, msize); - - bsize = ABS (base->_mp_size); - if (bsize > msize) - { - /* The base is larger than the module. Reduce it. */ - - /* Allocate (BSIZE + 1) with space for remainder and quotient. - (The quotient is (bsize - msize + 1) limbs.) */ - bp = (mp_ptr) TMP_ALLOC ((bsize + 1) * BYTES_PER_MP_LIMB); - MPN_COPY (bp, base->_mp_d, bsize); - /* We don't care about the quotient, store it above the remainder, - at BP + MSIZE. */ - mpn_divmod (bp + msize, bp, bsize, mp, msize); - bsize = msize; - /* Canonicalize the base, since we are going to multiply with it - quite a few times. */ - MPN_NORMALIZE (bp, bsize); - } - else - bp = base->_mp_d; - - if (bsize == 0) - { - res->_mp_size = 0; - TMP_FREE (marker); - return; - } - - if (res->_mp_alloc < size) - { - /* We have to allocate more space for RES. If any of the input - parameters are identical to RES, defer deallocation of the old - space. */ - - if (rp == ep || rp == mp || rp == bp) - { - free_me = rp; - free_me_size = res->_mp_alloc; - } - else - (*_mp_free_func) (rp, res->_mp_alloc * BYTES_PER_MP_LIMB); - - rp = (mp_ptr) (*_mp_allocate_func) (size * BYTES_PER_MP_LIMB); - res->_mp_alloc = size; - res->_mp_d = rp; - } - else - { - /* Make BASE, EXP and MOD not overlap with RES. */ - if (rp == bp) - { - /* RES and BASE are identical. Allocate temp. space for BASE. */ - bp = (mp_ptr) TMP_ALLOC (bsize * BYTES_PER_MP_LIMB); - MPN_COPY (bp, rp, bsize); - } - if (rp == ep) - { - /* RES and EXP are identical. Allocate temp. space for EXP. */ - ep = (mp_ptr) TMP_ALLOC (esize * BYTES_PER_MP_LIMB); - MPN_COPY (ep, rp, esize); - } - if (rp == mp) - { - /* RES and MOD are identical. Allocate temporary space for MOD. */ - mp = (mp_ptr) TMP_ALLOC (msize * BYTES_PER_MP_LIMB); - MPN_COPY (mp, rp, msize); - } - } - - MPN_COPY (rp, bp, bsize); - rsize = bsize; - - { - mp_size_t i; - mp_ptr xp = (mp_ptr) TMP_ALLOC (2 * (msize + 1) * BYTES_PER_MP_LIMB); - int c; - mp_limb_t e; - mp_limb_t carry_limb; - - negative_result = (ep[0] & 1) && base->_mp_size < 0; - - i = esize - 1; - e = ep[i]; - count_leading_zeros (c, e); - e = (e << c) << 1; /* shift the exp bits to the left, lose msb */ - c = BITS_PER_MP_LIMB - 1 - c; - - /* Main loop. - - Make the result be pointed to alternately by XP and RP. This - helps us avoid block copying, which would otherwise be necessary - with the overlap restrictions of mpn_divmod. With 50% probability - the result after this loop will be in the area originally pointed - by RP (==RES->_mp_d), and with 50% probability in the area originally - pointed to by XP. */ - - for (;;) - { - while (c != 0) - { - mp_ptr tp; - mp_size_t xsize; - - mpn_mul_n (xp, rp, rp, rsize); - xsize = 2 * rsize; - if (xsize > msize) - { - mpn_divmod (xp + msize, xp, xsize, mp, msize); - xsize = msize; - } - - tp = rp; rp = xp; xp = tp; - rsize = xsize; - - if ((mp_limb_signed_t) e < 0) - { - mpn_mul (xp, rp, rsize, bp, bsize); - xsize = rsize + bsize; - if (xsize > msize) - { - mpn_divmod (xp + msize, xp, xsize, mp, msize); - xsize = msize; - } - - tp = rp; rp = xp; xp = tp; - rsize = xsize; - } - e <<= 1; - c--; - } - - i--; - if (i < 0) - break; - e = ep[i]; - c = BITS_PER_MP_LIMB; - } - - /* We shifted MOD, the modulo reduction argument, left MOD_SHIFT_CNT - steps. Adjust the result by reducing it with the original MOD. - - Also make sure the result is put in RES->_mp_d (where it already - might be, see above). */ - - if (mod_shift_cnt != 0) - { - carry_limb = mpn_lshift (res->_mp_d, rp, rsize, mod_shift_cnt); - rp = res->_mp_d; - if (carry_limb != 0) - { - rp[rsize] = carry_limb; - rsize++; - } - } - else - { - MPN_COPY (res->_mp_d, rp, rsize); - rp = res->_mp_d; - } - - if (rsize >= msize) - { - mpn_divmod (rp + msize, rp, rsize, mp, msize); - rsize = msize; - } - - /* Remove any leading zero words from the result. */ - if (mod_shift_cnt != 0) - mpn_rshift (rp, rp, rsize, mod_shift_cnt); - MPN_NORMALIZE (rp, rsize); - } - - if (negative_result && rsize != 0) - { - if (mod_shift_cnt != 0) - mpn_rshift (mp, mp, msize, mod_shift_cnt); - mpn_sub (rp, mp, msize, rp, rsize); - rsize = msize; - MPN_NORMALIZE (rp, rsize); - } - res->_mp_size = rsize; - - if (free_me != NULL) - (*_mp_free_func) (free_me, free_me_size * BYTES_PER_MP_LIMB); - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/powm_ui.c b/gnu/lib/libgmp/mpz/powm_ui.c deleted file mode 100644 index 596815a..0000000 --- a/gnu/lib/libgmp/mpz/powm_ui.c +++ /dev/null @@ -1,234 +0,0 @@ -/* mpz_powm_ui(res,base,exp,mod) -- Set RES to (base**exp) mod MOD. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void -#if __STDC__ -mpz_powm_ui (mpz_ptr res, mpz_srcptr base, unsigned long int exp, mpz_srcptr mod) -#else -mpz_powm_ui (res, base, exp, mod) - mpz_ptr res; - mpz_srcptr base; - unsigned long int exp; - mpz_srcptr mod; -#endif -{ - mp_ptr rp, mp, bp; - mp_size_t msize, bsize, rsize; - mp_size_t size; - int mod_shift_cnt; - int negative_result; - mp_limb_t *free_me = NULL; - size_t free_me_size; - TMP_DECL (marker); - - msize = ABS (mod->_mp_size); - size = 2 * msize; - - rp = res->_mp_d; - - if (msize == 0) - msize = 1 / msize; /* provoke a signal */ - - if (exp == 0) - { - rp[0] = 1; - res->_mp_size = (msize == 1 && (mod->_mp_d)[0] == 1) ? 0 : 1; - return; - } - - TMP_MARK (marker); - - /* Normalize MOD (i.e. make its most significant bit set) as required by - mpn_divmod. This will make the intermediate values in the calculation - slightly larger, but the correct result is obtained after a final - reduction using the original MOD value. */ - - mp = (mp_ptr) TMP_ALLOC (msize * BYTES_PER_MP_LIMB); - count_leading_zeros (mod_shift_cnt, mod->_mp_d[msize - 1]); - if (mod_shift_cnt != 0) - mpn_lshift (mp, mod->_mp_d, msize, mod_shift_cnt); - else - MPN_COPY (mp, mod->_mp_d, msize); - - bsize = ABS (base->_mp_size); - if (bsize > msize) - { - /* The base is larger than the module. Reduce it. */ - - /* Allocate (BSIZE + 1) with space for remainder and quotient. - (The quotient is (bsize - msize + 1) limbs.) */ - bp = (mp_ptr) TMP_ALLOC ((bsize + 1) * BYTES_PER_MP_LIMB); - MPN_COPY (bp, base->_mp_d, bsize); - /* We don't care about the quotient, store it above the remainder, - at BP + MSIZE. */ - mpn_divmod (bp + msize, bp, bsize, mp, msize); - bsize = msize; - /* Canonicalize the base, since we are going to multiply with it - quite a few times. */ - MPN_NORMALIZE (bp, bsize); - } - else - bp = base->_mp_d; - - if (bsize == 0) - { - res->_mp_size = 0; - TMP_FREE (marker); - return; - } - - if (res->_mp_alloc < size) - { - /* We have to allocate more space for RES. If any of the input - parameters are identical to RES, defer deallocation of the old - space. */ - - if (rp == mp || rp == bp) - { - free_me = rp; - free_me_size = res->_mp_alloc; - } - else - (*_mp_free_func) (rp, res->_mp_alloc * BYTES_PER_MP_LIMB); - - rp = (mp_ptr) (*_mp_allocate_func) (size * BYTES_PER_MP_LIMB); - res->_mp_alloc = size; - res->_mp_d = rp; - } - else - { - /* Make BASE, EXP and MOD not overlap with RES. */ - if (rp == bp) - { - /* RES and BASE are identical. Allocate temp. space for BASE. */ - bp = (mp_ptr) TMP_ALLOC (bsize * BYTES_PER_MP_LIMB); - MPN_COPY (bp, rp, bsize); - } - if (rp == mp) - { - /* RES and MOD are identical. Allocate temporary space for MOD. */ - mp = (mp_ptr) TMP_ALLOC (msize * BYTES_PER_MP_LIMB); - MPN_COPY (mp, rp, msize); - } - } - - MPN_COPY (rp, bp, bsize); - rsize = bsize; - - { - mp_ptr xp = (mp_ptr) TMP_ALLOC (2 * (msize + 1) * BYTES_PER_MP_LIMB); - int c; - mp_limb_t e; - mp_limb_t carry_limb; - - negative_result = (exp & 1) && base->_mp_size < 0; - - e = exp; - count_leading_zeros (c, e); - e = (e << c) << 1; /* shift the exp bits to the left, lose msb */ - c = BITS_PER_MP_LIMB - 1 - c; - - /* Main loop. - - Make the result be pointed to alternately by XP and RP. This - helps us avoid block copying, which would otherwise be necessary - with the overlap restrictions of mpn_divmod. With 50% probability - the result after this loop will be in the area originally pointed - by RP (==RES->_mp_d), and with 50% probability in the area originally - pointed to by XP. */ - - while (c != 0) - { - mp_ptr tp; - mp_size_t xsize; - - mpn_mul_n (xp, rp, rp, rsize); - xsize = 2 * rsize; - if (xsize > msize) - { - mpn_divmod (xp + msize, xp, xsize, mp, msize); - xsize = msize; - } - - tp = rp; rp = xp; xp = tp; - rsize = xsize; - - if ((mp_limb_signed_t) e < 0) - { - mpn_mul (xp, rp, rsize, bp, bsize); - xsize = rsize + bsize; - if (xsize > msize) - { - mpn_divmod (xp + msize, xp, xsize, mp, msize); - xsize = msize; - } - - tp = rp; rp = xp; xp = tp; - rsize = xsize; - } - e <<= 1; - c--; - } - - /* We shifted MOD, the modulo reduction argument, left MOD_SHIFT_CNT - steps. Adjust the result by reducing it with the original MOD. - - Also make sure the result is put in RES->_mp_d (where it already - might be, see above). */ - - if (mod_shift_cnt != 0) - { - carry_limb = mpn_lshift (res->_mp_d, rp, rsize, mod_shift_cnt); - rp = res->_mp_d; - if (carry_limb != 0) - { - rp[rsize] = carry_limb; - rsize++; - } - } - else - { - MPN_COPY (res->_mp_d, rp, rsize); - rp = res->_mp_d; - } - - if (rsize >= msize) - { - mpn_divmod (rp + msize, rp, rsize, mp, msize); - rsize = msize; - } - - /* Remove any leading zero words from the result. */ - if (mod_shift_cnt != 0) - mpn_rshift (rp, rp, rsize, mod_shift_cnt); - MPN_NORMALIZE (rp, rsize); - } - - res->_mp_size = negative_result == 0 ? rsize : -rsize; - - if (free_me != NULL) - (*_mp_free_func) (free_me, free_me_size * BYTES_PER_MP_LIMB); - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/pprime_p.c b/gnu/lib/libgmp/mpz/pprime_p.c deleted file mode 100644 index 494de14..0000000 --- a/gnu/lib/libgmp/mpz/pprime_p.c +++ /dev/null @@ -1,115 +0,0 @@ -/* mpz_probab_prime_p -- - An implementation of the probabilistic primality test found in Knuth's - Seminumerical Algorithms book. If the function mpz_probab_prime_p() - returns 0 then n is not prime. If it returns 1, then n is 'probably' - prime. The probability of a false positive is (1/4)**reps, where - reps is the number of internal passes of the probabilistic algorithm. - Knuth indicates that 25 passes are reasonable. - -Copyright (C) 1991, 1993, 1994 Free Software Foundation, Inc. -Contributed by John Amanatides. - -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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" - -static int -possibly_prime (n, n_minus_1, x, y, q, k) - mpz_srcptr n; - mpz_srcptr n_minus_1; - mpz_ptr x; - mpz_ptr y; - mpz_srcptr q; - unsigned long int k; -{ - unsigned long int i; - - /* find random x s.t. 1 < x < n */ - do - { - mpz_random (x, mpz_size (n)); - mpz_mmod (x, x, n); - } - while (mpz_cmp_ui (x, 1L) <= 0); - - mpz_powm (y, x, q, n); - - if (mpz_cmp_ui (y, 1L) == 0 || mpz_cmp (y, n_minus_1) == 0) - return 1; - - for (i = 1; i < k; i++) - { - mpz_powm_ui (y, y, 2L, n); - if (mpz_cmp (y, n_minus_1) == 0) - return 1; - if (mpz_cmp_ui (y, 1L) == 0) - return 0; - } - return 0; -} - -int -#if __STDC__ -mpz_probab_prime_p (mpz_srcptr m, int reps) -#else -mpz_probab_prime_p (m, reps) - mpz_srcptr m; - int reps; -#endif -{ - mpz_t n, n_minus_1, x, y, q; - int i, is_prime; - unsigned long int k; - - mpz_init (n); - /* Take the absolute value of M, to handle positive and negative primes. */ - mpz_abs (n, m); - - if (mpz_cmp_ui (n, 3L) <= 0) - { - mpz_clear (n); - return mpz_cmp_ui (n, 1L) > 0; - } - - if ((mpz_get_ui (n) & 1) == 0) - { - mpz_clear (n); - return 0; /* even */ - } - - mpz_init (n_minus_1); - mpz_sub_ui (n_minus_1, n, 1L); - mpz_init (x); - mpz_init (y); - - /* find q and k, s.t. n = 1 + 2**k * q */ - mpz_init_set (q, n_minus_1); - k = mpz_scan1 (q, 0); - mpz_tdiv_q_2exp (q, q, k); - - is_prime = 1; - for (i = 0; i < reps && is_prime; i++) - is_prime &= possibly_prime (n, n_minus_1, x, y, q, k); - - mpz_clear (n_minus_1); - mpz_clear (n); - mpz_clear (x); - mpz_clear (y); - mpz_clear (q); - return is_prime; -} diff --git a/gnu/lib/libgmp/mpz/random.c b/gnu/lib/libgmp/mpz/random.c deleted file mode 100644 index ab41eef..0000000 --- a/gnu/lib/libgmp/mpz/random.c +++ /dev/null @@ -1,56 +0,0 @@ -/* mpz_random -- Generate a random mpz_t of specified size. - This function is non-portable and generates poor random numbers. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void -#if __STDC__ -mpz_random (mpz_ptr x, mp_size_t size) -#else -mpz_random (x, size) - mpz_ptr x; - mp_size_t size; -#endif -{ - mp_size_t i; - mp_limb_t ran; - mp_ptr xp; - mp_size_t abs_size; - - abs_size = ABS (size); - - if (x->_mp_alloc < abs_size) - _mpz_realloc (x, abs_size); - - xp = x->_mp_d; - - for (i = 0; i < abs_size; i++) - { - ran = urandom (); - xp[i] = ran; - } - - MPN_NORMALIZE (xp, abs_size); - x->_mp_size = size < 0 ? -abs_size : abs_size; -} diff --git a/gnu/lib/libgmp/mpz/random2.c b/gnu/lib/libgmp/mpz/random2.c deleted file mode 100644 index 725a8b4..0000000 --- a/gnu/lib/libgmp/mpz/random2.c +++ /dev/null @@ -1,48 +0,0 @@ -/* mpz_random2 -- Generate a positive random mpz_t of specified size, with - long runs of consecutive ones and zeros in the binary representation. - Meant for testing of other MP routines. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_random2 (mpz_ptr x, mp_size_t size) -#else -mpz_random2 (x, size) - mpz_ptr x; - mp_size_t size; -#endif -{ - mp_size_t abs_size; - - abs_size = ABS (size); - if (abs_size != 0) - { - if (x->_mp_alloc < abs_size) - _mpz_realloc (x, abs_size); - - mpn_random2 (x->_mp_d, abs_size); - } - - x->_mp_size = size; -} diff --git a/gnu/lib/libgmp/mpz/realloc.c b/gnu/lib/libgmp/mpz/realloc.c deleted file mode 100644 index 2c2a5da..0000000 --- a/gnu/lib/libgmp/mpz/realloc.c +++ /dev/null @@ -1,52 +0,0 @@ -/* _mpz_realloc -- make the mpz_t have NEW_SIZE digits allocated. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void * -#if __STDC__ -_mpz_realloc (mpz_ptr m, mp_size_t new_size) -#else -_mpz_realloc (m, new_size) - mpz_ptr m; - mp_size_t new_size; -#endif -{ - /* Never allocate zero space. */ - if (new_size == 0) - new_size = 1; - - m->_mp_d = (mp_ptr) (*_mp_reallocate_func) (m->_mp_d, - m->_mp_alloc * BYTES_PER_MP_LIMB, - new_size * BYTES_PER_MP_LIMB); - m->_mp_alloc = new_size; - -#if 0 - /* This might break some code that reads the size field after - reallocation, in the case the reallocated destination and a - source argument are identical. */ - if (ABS (m->_mp_size) > new_size) - m->_mp_size = 0; -#endif - - return (void *) m->_mp_d; -} diff --git a/gnu/lib/libgmp/mpz/scan0.c b/gnu/lib/libgmp/mpz/scan0.c deleted file mode 100644 index 8e45aa3..0000000 --- a/gnu/lib/libgmp/mpz/scan0.c +++ /dev/null @@ -1,35 +0,0 @@ -/* mpz_scan0(op, startbit) -- Scan for the next set bit, starting at startbit. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -unsigned long int -#if __STDC__ -mpz_scan0 (mpz_srcptr u, unsigned long int starting_bit) -#else -mpz_scan0 (u, starting_bit) - mpz_srcptr u; - unsigned long int starting_bit; -#endif -{ - return mpn_scan0 (u->_mp_d, starting_bit); -} diff --git a/gnu/lib/libgmp/mpz/scan1.c b/gnu/lib/libgmp/mpz/scan1.c deleted file mode 100644 index 6ecb0aa..0000000 --- a/gnu/lib/libgmp/mpz/scan1.c +++ /dev/null @@ -1,35 +0,0 @@ -/* mpz_scan1(op, startbit) -- Scan for the next set bit, starting at startbit. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -unsigned long int -#if __STDC__ -mpz_scan1 (mpz_srcptr u, unsigned long int starting_bit) -#else -mpz_scan1 (u, starting_bit) - mpz_srcptr u; - unsigned long int starting_bit; -#endif -{ - return mpn_scan1 (u->_mp_d, starting_bit); -} diff --git a/gnu/lib/libgmp/mpz/set.c b/gnu/lib/libgmp/mpz/set.c deleted file mode 100644 index d94ab74..0000000 --- a/gnu/lib/libgmp/mpz/set.c +++ /dev/null @@ -1,48 +0,0 @@ -/* mpz_set (dest_integer, src_integer) -- Assign DEST_INTEGER from SRC_INTEGER. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_set (mpz_ptr w, mpz_srcptr u) -#else -mpz_set (w, u) - mpz_ptr w; - mpz_srcptr u; -#endif -{ - mp_ptr wp, up; - mp_size_t usize, size; - - usize = u->_mp_size; - size = ABS (usize); - - if (w->_mp_alloc < size) - _mpz_realloc (w, size); - - wp = w->_mp_d; - up = u->_mp_d; - - MPN_COPY (wp, up, size); - w->_mp_size = usize; -} diff --git a/gnu/lib/libgmp/mpz/set_d.c b/gnu/lib/libgmp/mpz/set_d.c deleted file mode 100644 index c09b1d9..0000000 --- a/gnu/lib/libgmp/mpz/set_d.c +++ /dev/null @@ -1,93 +0,0 @@ -/* mpz_set_d(integer, val) -- Assign INTEGER with a double value VAL. - -Copyright (C) 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_set_d (mpz_ptr r, double d) -#else -mpz_set_d (r, d) - mpz_ptr r; - double d; -#endif -{ - int negative; - mp_size_t size; - mp_limb_t tp[3]; - mp_ptr rp; - - negative = d < 0; - d = ABS (d); - - /* Handle small arguments quickly. */ - if (d < MP_BASE_AS_DOUBLE) - { - mp_limb_t tmp; - tmp = d; - PTR(r)[0] = tmp; - SIZ(r) = negative ? -(tmp != 0) : (tmp != 0); - return; - } - - size = __gmp_extract_double (tp, d); - - if (ALLOC(r) < size) - _mpz_realloc (r, size); - - rp = PTR (r); - -#if BITS_PER_MP_LIMB == 32 - switch (size) - { - default: - MPN_ZERO (rp, size - 3); - rp += size - 3; - case 3: - rp[2] = tp[2]; - rp[1] = tp[1]; - rp[0] = tp[0]; - break; - case 2: - rp[1] = tp[2]; - rp[0] = tp[1]; - break; - case 1: - abort (); - } -#else - switch (size) - { - default: - MPN_ZERO (rp, size - 2); - rp += size - 2; - case 2: - rp[1] = tp[1]; - rp[0] = tp[0]; - break; - case 1: - abort (); - } -#endif - - SIZ(r) = negative ? -size : size; -} diff --git a/gnu/lib/libgmp/mpz/set_f.c b/gnu/lib/libgmp/mpz/set_f.c deleted file mode 100644 index 9547907..0000000 --- a/gnu/lib/libgmp/mpz/set_f.c +++ /dev/null @@ -1,64 +0,0 @@ -/* mpz_set_f (dest_integer, src_float) -- Assign DEST_INTEGER from SRC_FLOAT. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_set_f (mpz_ptr w, mpf_srcptr u) -#else -mpz_set_f (w, u) - mpz_ptr w; - mpf_srcptr u; -#endif -{ - mp_ptr wp, up; - mp_size_t usize, size; - mp_exp_t exp; - - usize = SIZ (u); - size = ABS (usize); - exp = EXP (u); - - if (w->_mp_alloc < exp) - _mpz_realloc (w, exp); - - wp = w->_mp_d; - up = u->_mp_d; - - if (exp <= 0) - { - SIZ (w) = 0; - return; - } - if (exp < size) - { - MPN_COPY (wp, up + size - exp, exp); - } - else - { - MPN_ZERO (wp, exp - size); - MPN_COPY (wp + exp - size, up, size); - } - - w->_mp_size = usize >= 0 ? exp : -exp; -} diff --git a/gnu/lib/libgmp/mpz/set_q.c b/gnu/lib/libgmp/mpz/set_q.c deleted file mode 100644 index 61bd5c7..0000000 --- a/gnu/lib/libgmp/mpz/set_q.c +++ /dev/null @@ -1,36 +0,0 @@ -/* mpz_set_q (dest_integer, src_rational) -- Assign DEST_INTEGER from - SRC_rational. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_set_q (mpz_ptr w, mpq_srcptr u) -#else -mpz_set_q (w, u) - mpz_ptr w; - mpq_srcptr u; -#endif -{ - mpz_tdiv_q (w, mpq_numref (u), mpq_denref (u)); -} diff --git a/gnu/lib/libgmp/mpz/set_si.c b/gnu/lib/libgmp/mpz/set_si.c deleted file mode 100644 index 82a90a3..0000000 --- a/gnu/lib/libgmp/mpz/set_si.c +++ /dev/null @@ -1,48 +0,0 @@ -/* mpz_set_si(integer, val) -- Assign INTEGER with a small value VAL. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_set_si (mpz_ptr dest, signed long int val) -#else -mpz_set_si (dest, val) - mpz_ptr dest; - signed long int val; -#endif -{ - /* We don't check if the allocation is enough, since the rest of the - package ensures it's at least 1, which is what we need here. */ - if (val > 0) - { - dest->_mp_d[0] = val; - dest->_mp_size = 1; - } - else if (val < 0) - { - dest->_mp_d[0] = -val; - dest->_mp_size = -1; - } - else - dest->_mp_size = 0; -} diff --git a/gnu/lib/libgmp/mpz/set_str.c b/gnu/lib/libgmp/mpz/set_str.c deleted file mode 100644 index d1334b1..0000000 --- a/gnu/lib/libgmp/mpz/set_str.c +++ /dev/null @@ -1,132 +0,0 @@ -/* mpz_set_str(mp_dest, string, base) -- Convert the \0-terminated - string STRING in base BASE to multiple precision integer in - MP_DEST. Allow white space in the string. If BASE == 0 determine - the base in the C standard way, i.e. 0xhh...h means base 16, - 0oo...o means base 8, otherwise assume base 10. - -Copyright (C) 1991, 1993, 1994, 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -static int -digit_value_in_base (c, base) - int c; - int base; -{ - int digit; - - if (isdigit (c)) - digit = c - '0'; - else if (islower (c)) - digit = c - 'a' + 10; - else if (isupper (c)) - digit = c - 'A' + 10; - else - return -1; - - if (digit < base) - return digit; - return -1; -} - -int -#if __STDC__ -mpz_set_str (mpz_ptr x, const char *str, int base) -#else -mpz_set_str (x, str, base) - mpz_ptr x; - const char *str; - int base; -#endif -{ - size_t str_size; - char *s, *begs; - size_t i; - mp_size_t xsize; - int c; - int negative; - TMP_DECL (marker); - - /* Skip whitespace. */ - do - c = *str++; - while (isspace (c)); - - negative = 0; - if (c == '-') - { - negative = 1; - c = *str++; - } - - if (digit_value_in_base (c, base == 0 ? 10 : base) < 0) - return -1; /* error if no digits */ - - /* If BASE is 0, try to find out the base by looking at the initial - characters. */ - if (base == 0) - { - base = 10; - if (c == '0') - { - base = 8; - c = *str++; - if (c == 'x' || c == 'X') - { - base = 16; - c = *str++; - } - } - } - - TMP_MARK (marker); - str_size = strlen (str - 1); - s = begs = (char *) TMP_ALLOC (str_size + 1); - - for (i = 0; i < str_size; i++) - { - if (!isspace (c)) - { - int dig = digit_value_in_base (c, base); - if (dig < 0) - { - TMP_FREE (marker); - return -1; - } - *s++ = dig; - } - c = *str++; - } - - str_size = s - begs; - - xsize = str_size / __mp_bases[base].chars_per_limb + 1; - if (x->_mp_alloc < xsize) - _mpz_realloc (x, xsize); - - xsize = mpn_set_str (x->_mp_d, (unsigned char *) begs, str_size, base); - x->_mp_size = negative ? -xsize : xsize; - - TMP_FREE (marker); - return 0; -} diff --git a/gnu/lib/libgmp/mpz/set_ui.c b/gnu/lib/libgmp/mpz/set_ui.c deleted file mode 100644 index 73f6cf5..0000000 --- a/gnu/lib/libgmp/mpz/set_ui.c +++ /dev/null @@ -1,43 +0,0 @@ -/* mpz_set_ui(integer, val) -- Assign INTEGER with a small value VAL. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_set_ui (mpz_ptr dest, unsigned long int val) -#else -mpz_set_ui (dest, val) - mpz_ptr dest; - unsigned long int val; -#endif -{ - /* We don't check if the allocation is enough, since the rest of the - package ensures it's at least 1, which is what we need here. */ - if (val > 0) - { - dest->_mp_d[0] = val; - dest->_mp_size = 1; - } - else - dest->_mp_size = 0; -} diff --git a/gnu/lib/libgmp/mpz/setbit.c b/gnu/lib/libgmp/mpz/setbit.c deleted file mode 100644 index af59e2c..0000000 --- a/gnu/lib/libgmp/mpz/setbit.c +++ /dev/null @@ -1,113 +0,0 @@ -/* mpz_setbit -- set a specified bit. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_setbit (mpz_ptr d, unsigned long int bit_index) -#else -mpz_setbit (d, bit_index) - mpz_ptr d; - unsigned long int bit_index; -#endif -{ - mp_size_t dsize = d->_mp_size; - mp_ptr dp = d->_mp_d; - mp_size_t limb_index; - - limb_index = bit_index / BITS_PER_MP_LIMB; - if (dsize >= 0) - { - if (limb_index < dsize) - { - dp[limb_index] |= (mp_limb_t) 1 << (bit_index % BITS_PER_MP_LIMB); - d->_mp_size = dsize; - } - else - { - /* Ugh. The bit should be set outside of the end of the - number. We have to increase the size of the number. */ - if (d->_mp_alloc < limb_index + 1) - { - _mpz_realloc (d, limb_index + 1); - dp = d->_mp_d; - } - MPN_ZERO (dp + dsize, limb_index - dsize); - dp[limb_index] = (mp_limb_t) 1 << (bit_index % BITS_PER_MP_LIMB); - d->_mp_size = limb_index + 1; - } - } - else - { - mp_size_t zero_bound; - - /* Simulate two's complement arithmetic, i.e. simulate - 1. Set OP = ~(OP - 1) [with infinitely many leading ones]. - 2. set the bit. - 3. Set OP = ~OP + 1. */ - - dsize = -dsize; - - /* No upper bound on this loop, we're sure there's a non-zero limb - sooner ot later. */ - for (zero_bound = 0; ; zero_bound++) - if (dp[zero_bound] != 0) - break; - - if (limb_index > zero_bound) - { - if (limb_index < dsize) - dp[limb_index] &= ~((mp_limb_t) 1 << (bit_index % BITS_PER_MP_LIMB)); - else - ; - } - else if (limb_index == zero_bound) - { - dp[limb_index] = ((dp[limb_index] - 1) - & ~((mp_limb_t) 1 << (bit_index % BITS_PER_MP_LIMB))) + 1; - if (dp[limb_index] == 0) - { - mp_size_t i; - for (i = limb_index + 1; i < dsize; i++) - { - dp[i] += 1; - if (dp[i] != 0) - goto fin; - } - /* We got carry all way out beyond the end of D. Increase - its size (and allocation if necessary). */ - dsize++; - if (d->_mp_alloc < dsize) - { - _mpz_realloc (d, dsize); - dp = d->_mp_d; - } - dp[i] = 1; - d->_mp_size = -dsize; - fin:; - } - } - else - ; - } -} diff --git a/gnu/lib/libgmp/mpz/size.c b/gnu/lib/libgmp/mpz/size.c deleted file mode 100644 index 0b09fbe..0000000 --- a/gnu/lib/libgmp/mpz/size.c +++ /dev/null @@ -1,35 +0,0 @@ -/* mpz_size(x) -- return the number of lims currently used by the - value of integer X. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -size_t -#if __STDC__ -mpz_size (mpz_srcptr x) -#else -mpz_size (x) - mpz_srcptr x; -#endif -{ - return ABS (x->_mp_size); -} diff --git a/gnu/lib/libgmp/mpz/sizeinbase.c b/gnu/lib/libgmp/mpz/sizeinbase.c deleted file mode 100644 index 51bd555..0000000 --- a/gnu/lib/libgmp/mpz/sizeinbase.c +++ /dev/null @@ -1,60 +0,0 @@ -/* mpz_sizeinbase(x, base) -- return an approximation to the number of - character the integer X would have printed in base BASE. The - approximation is never too small. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -size_t -#if __STDC__ -mpz_sizeinbase (mpz_srcptr x, int base) -#else -mpz_sizeinbase (x, base) - mpz_srcptr x; - int base; -#endif -{ - mp_size_t size = ABS (x->_mp_size); - int lb_base, cnt; - size_t totbits; - - /* Special case for X == 0. */ - if (size == 0) - return 1; - - /* Calculate the total number of significant bits of X. */ - count_leading_zeros (cnt, x->_mp_d[size - 1]); - totbits = size * BITS_PER_MP_LIMB - cnt; - - if ((base & (base - 1)) == 0) - { - /* Special case for powers of 2, giving exact result. */ - - count_leading_zeros (lb_base, base); - lb_base = BITS_PER_MP_LIMB - lb_base - 1; - - return (totbits + lb_base - 1) / lb_base; - } - else - return (size_t) (totbits * __mp_bases[base].chars_per_bit_exactly) + 1; -} diff --git a/gnu/lib/libgmp/mpz/sqrt.c b/gnu/lib/libgmp/mpz/sqrt.c deleted file mode 100644 index 44c554e..0000000 --- a/gnu/lib/libgmp/mpz/sqrt.c +++ /dev/null @@ -1,85 +0,0 @@ -/* mpz_sqrt(root, u) -- Set ROOT to floor(sqrt(U)). - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_sqrt (mpz_ptr root, mpz_srcptr op) -#else -mpz_sqrt (root, op) - mpz_ptr root; - mpz_srcptr op; -#endif -{ - mp_size_t op_size, root_size; - mp_ptr root_ptr, op_ptr; - mp_ptr free_me = NULL; - mp_size_t free_me_size; - TMP_DECL (marker); - - TMP_MARK (marker); - op_size = op->_mp_size; - if (op_size < 0) - op_size = 1 / (op_size > 0); /* Divide by zero for negative OP. */ - - /* The size of the root is accurate after this simple calculation. */ - root_size = (op_size + 1) / 2; - - root_ptr = root->_mp_d; - op_ptr = op->_mp_d; - - if (root->_mp_alloc < root_size) - { - if (root_ptr == op_ptr) - { - free_me = root_ptr; - free_me_size = root->_mp_alloc; - } - else - (*_mp_free_func) (root_ptr, root->_mp_alloc * BYTES_PER_MP_LIMB); - - root->_mp_alloc = root_size; - root_ptr = (mp_ptr) (*_mp_allocate_func) (root_size * BYTES_PER_MP_LIMB); - root->_mp_d = root_ptr; - } - else - { - /* Make OP not overlap with ROOT. */ - if (root_ptr == op_ptr) - { - /* ROOT and OP are identical. Allocate temporary space for OP. */ - op_ptr = (mp_ptr) TMP_ALLOC (op_size * BYTES_PER_MP_LIMB); - /* Copy to the temporary space. Hack: Avoid temporary variable - by using ROOT_PTR. */ - MPN_COPY (op_ptr, root_ptr, op_size); - } - } - - mpn_sqrtrem (root_ptr, NULL, op_ptr, op_size); - - root->_mp_size = root_size; - - if (free_me != NULL) - (*_mp_free_func) (free_me, free_me_size * BYTES_PER_MP_LIMB); - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/sqrtrem.c b/gnu/lib/libgmp/mpz/sqrtrem.c deleted file mode 100644 index 757cc5d..0000000 --- a/gnu/lib/libgmp/mpz/sqrtrem.c +++ /dev/null @@ -1,107 +0,0 @@ -/* mpz_sqrtrem(root,rem,x) -- Set ROOT to floor(sqrt(X)) and REM - to the remainder, i.e. X - ROOT**2. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -#ifndef BERKELEY_MP -void -#if __STDC__ -mpz_sqrtrem (mpz_ptr root, mpz_ptr rem, mpz_srcptr op) -#else -mpz_sqrtrem (root, rem, op) - mpz_ptr root; - mpz_ptr rem; - mpz_srcptr op; -#endif -#else /* BERKELEY_MP */ -void -#if __STDC__ -msqrt (mpz_srcptr op, mpz_ptr root, mpz_ptr rem) -#else -msqrt (op, root, rem) - mpz_srcptr op; - mpz_ptr root; - mpz_ptr rem; -#endif -#endif /* BERKELEY_MP */ -{ - mp_size_t op_size, root_size, rem_size; - mp_ptr root_ptr, op_ptr; - mp_ptr free_me = NULL; - mp_size_t free_me_size; - TMP_DECL (marker); - - TMP_MARK (marker); - op_size = op->_mp_size; - if (op_size < 0) - op_size = 1 / (op_size > 0); /* Divide by zero for negative OP. */ - - if (rem->_mp_alloc < op_size) - _mpz_realloc (rem, op_size); - - /* The size of the root is accurate after this simple calculation. */ - root_size = (op_size + 1) / 2; - - root_ptr = root->_mp_d; - op_ptr = op->_mp_d; - - if (root->_mp_alloc < root_size) - { - if (root_ptr == op_ptr) - { - free_me = root_ptr; - free_me_size = root->_mp_alloc; - } - else - (*_mp_free_func) (root_ptr, root->_mp_alloc * BYTES_PER_MP_LIMB); - - root->_mp_alloc = root_size; - root_ptr = (mp_ptr) (*_mp_allocate_func) (root_size * BYTES_PER_MP_LIMB); - root->_mp_d = root_ptr; - } - else - { - /* Make OP not overlap with ROOT. */ - if (root_ptr == op_ptr) - { - /* ROOT and OP are identical. Allocate temporary space for OP. */ - op_ptr = (mp_ptr) TMP_ALLOC (op_size * BYTES_PER_MP_LIMB); - /* Copy to the temporary space. Hack: Avoid temporary variable - by using ROOT_PTR. */ - MPN_COPY (op_ptr, root_ptr, op_size); - } - } - - rem_size = mpn_sqrtrem (root_ptr, rem->_mp_d, op_ptr, op_size); - - root->_mp_size = root_size; - - /* Write remainder size last, to enable us to define this function to - give only the square root remainder, if the user calls if with - ROOT == REM. */ - rem->_mp_size = rem_size; - - if (free_me != NULL) - (*_mp_free_func) (free_me, free_me_size * BYTES_PER_MP_LIMB); - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/sub.c b/gnu/lib/libgmp/mpz/sub.c deleted file mode 100644 index 56ef1a1..0000000 --- a/gnu/lib/libgmp/mpz/sub.c +++ /dev/null @@ -1,120 +0,0 @@ -/* mpz_sub -- Subtract two integers. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -#ifndef BERKELEY_MP -void -#if __STDC__ -mpz_sub (mpz_ptr w, mpz_srcptr u, mpz_srcptr v) -#else -mpz_sub (w, u, v) - mpz_ptr w; - mpz_srcptr u; - mpz_srcptr v; -#endif -#else /* BERKELEY_MP */ -void -#if __STDC__ -msub (mpz_srcptr u, mpz_srcptr v, mpz_ptr w) -#else -msub (u, v, w) - mpz_srcptr u; - mpz_srcptr v; - mpz_ptr w; -#endif -#endif /* BERKELEY_MP */ -{ - mp_srcptr up, vp; - mp_ptr wp; - mp_size_t usize, vsize, wsize; - mp_size_t abs_usize; - mp_size_t abs_vsize; - - usize = u->_mp_size; - vsize = -v->_mp_size; /* The "-" makes the difference from mpz_add */ - abs_usize = ABS (usize); - abs_vsize = ABS (vsize); - - if (abs_usize < abs_vsize) - { - /* Swap U and V. */ - {const __mpz_struct *t = u; u = v; v = t;} - {mp_size_t t = usize; usize = vsize; vsize = t;} - {mp_size_t t = abs_usize; abs_usize = abs_vsize; abs_vsize = t;} - } - - /* True: ABS_USIZE >= ABS_VSIZE. */ - - /* If not space for w (and possible carry), increase space. */ - wsize = abs_usize + 1; - if (w->_mp_alloc < wsize) - _mpz_realloc (w, wsize); - - /* These must be after realloc (u or v may be the same as w). */ - up = u->_mp_d; - vp = v->_mp_d; - wp = w->_mp_d; - - if ((usize ^ vsize) < 0) - { - /* U and V have different sign. Need to compare them to determine - which operand to subtract from which. */ - - /* This test is right since ABS_USIZE >= ABS_VSIZE. */ - if (abs_usize != abs_vsize) - { - mpn_sub (wp, up, abs_usize, vp, abs_vsize); - wsize = abs_usize; - MPN_NORMALIZE (wp, wsize); - if (usize < 0) - wsize = -wsize; - } - else if (mpn_cmp (up, vp, abs_usize) < 0) - { - mpn_sub_n (wp, vp, up, abs_usize); - wsize = abs_usize; - MPN_NORMALIZE (wp, wsize); - if (usize >= 0) - wsize = -wsize; - } - else - { - mpn_sub_n (wp, up, vp, abs_usize); - wsize = abs_usize; - MPN_NORMALIZE (wp, wsize); - if (usize < 0) - wsize = -wsize; - } - } - else - { - /* U and V have same sign. Add them. */ - mp_limb_t cy_limb = mpn_add (wp, up, abs_usize, vp, abs_vsize); - wp[abs_usize] = cy_limb; - wsize = abs_usize + cy_limb; - if (usize < 0) - wsize = -wsize; - } - - w->_mp_size = wsize; -} diff --git a/gnu/lib/libgmp/mpz/sub_ui.c b/gnu/lib/libgmp/mpz/sub_ui.c deleted file mode 100644 index 7dea4b6..0000000 --- a/gnu/lib/libgmp/mpz/sub_ui.c +++ /dev/null @@ -1,84 +0,0 @@ -/* mpz_sub_ui -- Subtract an unsigned one-word integer from an MP_INT. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_sub_ui (mpz_ptr w, mpz_srcptr u, unsigned long int v) -#else -mpz_sub_ui (w, u, v) - mpz_ptr w; - mpz_srcptr u; - unsigned long int v; -#endif -{ - mp_srcptr up; - mp_ptr wp; - mp_size_t usize, wsize; - mp_size_t abs_usize; - - usize = u->_mp_size; - abs_usize = ABS (usize); - - /* If not space for W (and possible carry), increase space. */ - wsize = abs_usize + 1; - if (w->_mp_alloc < wsize) - _mpz_realloc (w, wsize); - - /* These must be after realloc (U may be the same as W). */ - up = u->_mp_d; - wp = w->_mp_d; - - if (abs_usize == 0) - { - wp[0] = v; - w->_mp_size = -(v != 0); - return; - } - - if (usize < 0) - { - mp_limb_t cy; - cy = mpn_add_1 (wp, up, abs_usize, v); - wp[abs_usize] = cy; - wsize = -(abs_usize + cy); - } - else - { - /* The signs are different. Need exact comparison to determine - which operand to subtract from which. */ - if (abs_usize == 1 && up[0] < v) - { - wp[0] = v - up[0]; - wsize = -1; - } - else - { - mpn_sub_1 (wp, up, abs_usize, v); - /* Size can decrease with at most one limb. */ - wsize = abs_usize - (wp[abs_usize - 1] == 0); - } - } - - w->_mp_size = wsize; -} diff --git a/gnu/lib/libgmp/mpz/tdiv_q.c b/gnu/lib/libgmp/mpz/tdiv_q.c deleted file mode 100644 index b4d3636..0000000 --- a/gnu/lib/libgmp/mpz/tdiv_q.c +++ /dev/null @@ -1,133 +0,0 @@ -/* mpz_tdiv_q -- divide two integers and produce a quotient. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void -#if __STDC__ -mpz_tdiv_q (mpz_ptr quot, mpz_srcptr num, mpz_srcptr den) -#else -mpz_tdiv_q (quot, num, den) - mpz_ptr quot; - mpz_srcptr num; - mpz_srcptr den; -#endif -{ - mp_srcptr np, dp; - mp_ptr qp, rp; - mp_size_t nsize = num->_mp_size; - mp_size_t dsize = den->_mp_size; - mp_size_t qsize, rsize; - mp_size_t sign_quotient = nsize ^ dsize; - unsigned normalization_steps; - mp_limb_t q_limb; - TMP_DECL (marker); - - nsize = ABS (nsize); - dsize = ABS (dsize); - - /* Ensure space is enough for quotient. */ - - qsize = nsize - dsize + 1; /* qsize cannot be bigger than this. */ - if (qsize <= 0) - { - quot->_mp_size = 0; - return; - } - - if (quot->_mp_alloc < qsize) - _mpz_realloc (quot, qsize); - - qp = quot->_mp_d; - np = num->_mp_d; - dp = den->_mp_d; - - /* Optimize division by a single-limb divisor. */ - if (dsize == 1) - { - mpn_divmod_1 (qp, np, nsize, dp[0]); - qsize -= qp[qsize - 1] == 0; - quot->_mp_size = sign_quotient >= 0 ? qsize : -qsize; - return; - } - - TMP_MARK (marker); - - rp = (mp_ptr) TMP_ALLOC ((nsize + 1) * BYTES_PER_MP_LIMB); - - count_leading_zeros (normalization_steps, dp[dsize - 1]); - - /* Normalize the denominator, i.e. make its most significant bit set by - shifting it NORMALIZATION_STEPS bits to the left. Also shift the - numerator the same number of steps (to keep the quotient the same!). */ - if (normalization_steps != 0) - { - mp_ptr tp; - mp_limb_t nlimb; - - /* Shift up the denominator setting the most significant bit of - the most significant word. Use temporary storage not to clobber - the original contents of the denominator. */ - tp = (mp_ptr) TMP_ALLOC (dsize * BYTES_PER_MP_LIMB); - mpn_lshift (tp, dp, dsize, normalization_steps); - dp = tp; - - /* Shift up the numerator, possibly introducing a new most - significant word. Move the shifted numerator in the remainder - meanwhile. */ - nlimb = mpn_lshift (rp, np, nsize, normalization_steps); - if (nlimb != 0) - { - rp[nsize] = nlimb; - rsize = nsize + 1; - } - else - rsize = nsize; - } - else - { - /* The denominator is already normalized, as required. Copy it to - temporary space if it overlaps with the quotient. */ - if (dp == qp) - { - dp = (mp_ptr) TMP_ALLOC (dsize * BYTES_PER_MP_LIMB); - MPN_COPY ((mp_ptr) dp, qp, dsize); - } - - /* Move the numerator to the remainder. */ - MPN_COPY (rp, np, nsize); - rsize = nsize; - } - - q_limb = mpn_divmod (qp, rp, rsize, dp, dsize); - - qsize = rsize - dsize; - if (q_limb) - { - qp[qsize] = q_limb; - qsize += 1; - } - - quot->_mp_size = sign_quotient >= 0 ? qsize : -qsize; - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/mpz/tdiv_q_2exp.c b/gnu/lib/libgmp/mpz/tdiv_q_2exp.c deleted file mode 100644 index e70d810..0000000 --- a/gnu/lib/libgmp/mpz/tdiv_q_2exp.c +++ /dev/null @@ -1,68 +0,0 @@ -/* mpz_tdiv_q_2exp -- Divide an integer by 2**CNT. Round the quotient - towards -infinity. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_tdiv_q_2exp (mpz_ptr w, mpz_srcptr u, unsigned long int cnt) -#else -mpz_tdiv_q_2exp (w, u, cnt) - mpz_ptr w; - mpz_srcptr u; - unsigned long int cnt; -#endif -{ - mp_size_t usize, wsize; - mp_size_t limb_cnt; - - usize = u->_mp_size; - limb_cnt = cnt / BITS_PER_MP_LIMB; - wsize = ABS (usize) - limb_cnt; - if (wsize <= 0) - w->_mp_size = 0; - else - { - mp_ptr wp; - mp_srcptr up; - - if (w->_mp_alloc < wsize) - _mpz_realloc (w, wsize); - - wp = w->_mp_d; - up = u->_mp_d; - - cnt %= BITS_PER_MP_LIMB; - if (cnt != 0) - { - mpn_rshift (wp, up + limb_cnt, wsize, cnt); - wsize -= wp[wsize - 1] == 0; - } - else - { - MPN_COPY_INCR (wp, up + limb_cnt, wsize); - } - - w->_mp_size = usize >= 0 ? wsize : -wsize; - } -} diff --git a/gnu/lib/libgmp/mpz/tdiv_q_ui.c b/gnu/lib/libgmp/mpz/tdiv_q_ui.c deleted file mode 100644 index 9048e0a..0000000 --- a/gnu/lib/libgmp/mpz/tdiv_q_ui.c +++ /dev/null @@ -1,63 +0,0 @@ -/* mpz_tdiv_q_ui(quot, dividend, divisor_limb) - -- Divide DIVIDEND by DIVISOR_LIMB and store the result in QUOT. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_tdiv_q_ui (mpz_ptr quot, mpz_srcptr dividend, unsigned long int divisor) -#else -mpz_tdiv_q_ui (quot, dividend, divisor) - mpz_ptr quot; - mpz_srcptr dividend; - unsigned long int divisor; -#endif -{ - mp_size_t dividend_size; - mp_size_t size; - mp_ptr quot_ptr; - - dividend_size = dividend->_mp_size; - size = ABS (dividend_size); - - if (size == 0) - { - quot->_mp_size = 0; - return; - } - - /* No need for temporary allocation and copying if QUOT == DIVIDEND as - the divisor is just one limb, and thus no intermediate remainders - need to be stored. */ - - if (quot->_mp_alloc < size) - _mpz_realloc (quot, size); - - quot_ptr = quot->_mp_d; - - mpn_divmod_1 (quot_ptr, dividend->_mp_d, size, (mp_limb_t) divisor); - - /* The quotient is SIZE limbs, but the most significant might be zero. */ - size -= quot_ptr[size - 1] == 0; - quot->_mp_size = dividend_size >= 0 ? size : -size; -} diff --git a/gnu/lib/libgmp/mpz/tdiv_qr.c b/gnu/lib/libgmp/mpz/tdiv_qr.c deleted file mode 100644 index 500e199..0000000 --- a/gnu/lib/libgmp/mpz/tdiv_qr.c +++ /dev/null @@ -1,39 +0,0 @@ -/* mpz_tdiv_qr(quot,rem,dividend,divisor) -- Set QUOT to DIVIDEND/DIVISOR, - and REM to DIVIDEND mod DIVISOR. - -Copyright (C) 1991, 1993, 1994 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void -#if __STDC__ -mpz_tdiv_qr (mpz_ptr quot, mpz_ptr rem, mpz_srcptr num, mpz_srcptr den) -#else -mpz_tdiv_qr (quot, rem, num, den) - mpz_ptr quot; - mpz_ptr rem; - mpz_srcptr num; - mpz_srcptr den; -#endif - -#define COMPUTE_QUOTIENT -#include "dmincl.c" diff --git a/gnu/lib/libgmp/mpz/tdiv_qr_ui.c b/gnu/lib/libgmp/mpz/tdiv_qr_ui.c deleted file mode 100644 index cb5041c..0000000 --- a/gnu/lib/libgmp/mpz/tdiv_qr_ui.c +++ /dev/null @@ -1,78 +0,0 @@ -/* mpz_tdiv_qr_ui(quot,rem,dividend,short_divisor) -- - Set QUOT to DIVIDEND / SHORT_DIVISOR - and REM to DIVIDEND mod SHORT_DIVISOR. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_tdiv_qr_ui (mpz_ptr quot, mpz_ptr rem, mpz_srcptr dividend, unsigned long int divisor) -#else -mpz_tdiv_qr_ui (quot, rem, dividend, divisor) - mpz_ptr quot; - mpz_ptr rem; - mpz_srcptr dividend; - unsigned long int divisor; -#endif -{ - mp_size_t dividend_size; - mp_size_t size; - mp_ptr quot_ptr; - mp_limb_t remainder_limb; - - dividend_size = dividend->_mp_size; - size = ABS (dividend_size); - - if (size == 0) - { - quot->_mp_size = 0; - rem->_mp_size = 0; - return; - } - - /* No need for temporary allocation and copying if QUOT == DIVIDEND as - the divisor is just one limb, and thus no intermediate remainders - need to be stored. */ - - if (quot->_mp_alloc < size) - _mpz_realloc (quot, size); - - quot_ptr = quot->_mp_d; - - remainder_limb = mpn_divmod_1 (quot_ptr, dividend->_mp_d, size, - (mp_limb_t) divisor); - - if (remainder_limb == 0) - rem->_mp_size = 0; - else - { - /* Store the single-limb remainder. We don't check if there's space - for just one limb, since no function ever makes zero space. */ - rem->_mp_size = dividend_size >= 0 ? 1 : -1; - rem->_mp_d[0] = remainder_limb; - } - - /* The quotient is SIZE limbs, but the most significant might be zero. */ - size -= quot_ptr[size - 1] == 0; - quot->_mp_size = dividend_size >= 0 ? size : -size; -} diff --git a/gnu/lib/libgmp/mpz/tdiv_r.c b/gnu/lib/libgmp/mpz/tdiv_r.c deleted file mode 100644 index 813a0d4..0000000 --- a/gnu/lib/libgmp/mpz/tdiv_r.c +++ /dev/null @@ -1,37 +0,0 @@ -/* mpz_tdiv_r(rem, dividend, divisor) -- Set REM to DIVIDEND mod DIVISOR. - -Copyright (C) 1991, 1993, 1994 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void -#if __STDC__ -mpz_tdiv_r (mpz_ptr rem, mpz_srcptr num, mpz_srcptr den) -#else -mpz_tdiv_r (rem, num, den) - mpz_ptr rem; - mpz_srcptr num; - mpz_srcptr den; -#endif - -#undef COMPUTE_QUOTIENT -#include "dmincl.c" diff --git a/gnu/lib/libgmp/mpz/tdiv_r_2exp.c b/gnu/lib/libgmp/mpz/tdiv_r_2exp.c deleted file mode 100644 index 99d617e..0000000 --- a/gnu/lib/libgmp/mpz/tdiv_r_2exp.c +++ /dev/null @@ -1,79 +0,0 @@ -/* mpz_tdiv_r_2exp -- Divide a integer by 2**CNT and produce a remainder. - -Copyright (C) 1991, 1993, 1994, 1995 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_tdiv_r_2exp (mpz_ptr res, mpz_srcptr in, unsigned long int cnt) -#else -mpz_tdiv_r_2exp (res, in, cnt) - mpz_ptr res; - mpz_srcptr in; - unsigned long int cnt; -#endif -{ - mp_size_t in_size = ABS (in->_mp_size); - mp_size_t res_size; - mp_size_t limb_cnt = cnt / BITS_PER_MP_LIMB; - mp_srcptr in_ptr = in->_mp_d; - - if (in_size > limb_cnt) - { - /* The input operand is (probably) greater than 2**CNT. */ - mp_limb_t x; - - x = in_ptr[limb_cnt] & (((mp_limb_t) 1 << cnt % BITS_PER_MP_LIMB) - 1); - if (x != 0) - { - res_size = limb_cnt + 1; - if (res->_mp_alloc < res_size) - _mpz_realloc (res, res_size); - - res->_mp_d[limb_cnt] = x; - } - else - { - res_size = limb_cnt; - MPN_NORMALIZE (in_ptr, res_size); - - if (res->_mp_alloc < res_size) - _mpz_realloc (res, res_size); - - limb_cnt = res_size; - } - } - else - { - /* The input operand is smaller than 2**CNT. We perform a no-op, - apart from that we might need to copy IN to RES. */ - res_size = in_size; - if (res->_mp_alloc < res_size) - _mpz_realloc (res, res_size); - - limb_cnt = res_size; - } - - if (res != in) - MPN_COPY (res->_mp_d, in->_mp_d, limb_cnt); - res->_mp_size = in->_mp_size >= 0 ? res_size : -res_size; -} diff --git a/gnu/lib/libgmp/mpz/tdiv_r_ui.c b/gnu/lib/libgmp/mpz/tdiv_r_ui.c deleted file mode 100644 index 0428b52..0000000 --- a/gnu/lib/libgmp/mpz/tdiv_r_ui.c +++ /dev/null @@ -1,64 +0,0 @@ -/* mpz_tdiv_r_ui(rem, dividend, divisor_limb) - -- Set REM to DIVDEND mod DIVISOR_LIMB. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" - -void -#if __STDC__ -mpz_tdiv_r_ui (mpz_ptr rem, mpz_srcptr dividend, unsigned long int divisor) -#else -mpz_tdiv_r_ui (rem, dividend, divisor) - mpz_ptr rem; - mpz_srcptr dividend; - unsigned long int divisor; -#endif -{ - mp_size_t dividend_size; - mp_size_t size; - mp_limb_t remainder_limb; - - dividend_size = dividend->_mp_size; - size = ABS (dividend_size); - - if (size == 0) - { - rem->_mp_size = 0; - return; - } - - /* No need for temporary allocation and copying if QUOT == DIVIDEND as - the divisor is just one limb, and thus no intermediate remainders - need to be stored. */ - - remainder_limb = mpn_mod_1 (dividend->_mp_d, size, (mp_limb_t) divisor); - - if (remainder_limb == 0) - rem->_mp_size = 0; - else - { - /* Store the single-limb remainder. We don't check if there's space - for just one limb, since no function ever makes zero space. */ - rem->_mp_size = dividend_size >= 0 ? 1 : -1; - rem->_mp_d[0] = remainder_limb; - } -} diff --git a/gnu/lib/libgmp/mpz/tests/Makefile.in b/gnu/lib/libgmp/mpz/tests/Makefile.in deleted file mode 100644 index 5a0cf59..0000000 --- a/gnu/lib/libgmp/mpz/tests/Makefile.in +++ /dev/null @@ -1,126 +0,0 @@ -# Makefile for mpz/tests for GNU MP - -srcdir = . - -CC = gcc - -TEST_LIBS = ../../libgmp.a -INCLUDES = -I../../mpn -I$(srcdir)/../.. -CFLAGS = -g -O - -.c.o: - $(CC) -c $(INCLUDES) $(CFLAGS) $(XCFLAGS) $< - -TEST_SRCS = t-mul.c t-tdiv.c t-tdiv_ui.c t-fdiv.c t-fdiv_ui.c t-gcd.c \ - t-gcd2.c dive.c t-sqrtrem.c convert.c io.c logic.c t-powm.c t-powm_ui.c \ - reuse.c -TEST_OBJS = t-mul.o t-tdiv.o t-tdiv_ui.o t-fdiv.o t-fdiv_ui.o t-gcd.o \ - t-gcd2.o dive.o t-sqrtrem.o convert.o io.o logic.o t-powm.o t-powm_ui.o \ - reuse.o -TESTS = t-mul t-tdiv t-tdiv_ui t-fdiv t-fdiv_ui t-gcd t-gcd2 \ - dive t-sqrtrem convert io logic t-powm t-powm_ui reuse - -check: Makefile st-mul st-tdiv st-tdiv_ui st-fdiv st-fdiv_ui st-gcd st-gcd2 st-dive \ - st-sqrtrem st-convert st-io st-logic st-powm st-powm_ui st-reuse - @echo "The tests passed." - -st-mul: t-mul - ./t-mul - touch $@ -st-tdiv: t-tdiv - ./t-tdiv - touch $@ -st-tdiv_ui: t-tdiv_ui - ./t-tdiv_ui - touch $@ -st-fdiv: t-fdiv - ./t-fdiv - touch $@ -st-fdiv_ui: t-fdiv_ui - ./t-fdiv_ui - touch $@ -st-gcd: t-gcd - ./t-gcd - touch $@ -st-gcd2: t-gcd2 - ./t-gcd2 - touch $@ -st-dive: dive - ./dive - touch $@ -st-sqrtrem: t-sqrtrem - ./t-sqrtrem - touch $@ -st-convert: convert - ./convert - touch $@ -st-io: io - ./io - touch $@ -st-logic: logic - ./logic - touch $@ -st-powm: t-powm - ./t-powm - touch $@ -st-powm_ui: t-powm_ui - ./t-powm_ui - touch $@ -st-reuse: reuse - ./reuse - touch $@ - -t-mul: t-mul.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -t-tdiv: t-tdiv.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -t-tdiv_ui: t-tdiv_ui.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -t-fdiv: t-fdiv.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -t-fdiv_ui: t-fdiv_ui.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -t-gcd: t-gcd.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -t-gcd2: t-gcd2.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -dive: dive.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -t-sqrtrem: t-sqrtrem.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -convert: convert.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -io: io.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -logic: logic.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -t-powm: t-powm.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -t-powm_ui: t-powm_ui.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) -reuse: reuse.o $(TEST_LIBS) - $(CC) -o $@ $@.o $(TEST_LIBS) $(CFLAGS) - -t-mul.o: $(srcdir)/t-mul.c -t-tdiv.o: $(srcdir)/t-tdiv.c -t-tdiv_ui.o: $(srcdir)/t-tdiv_ui.c -t-fdiv.o: $(srcdir)/t-fdiv.c -t-fdiv_ui.o: $(srcdir)/t-fdiv_ui.c -t-gcd.o: $(srcdir)/t-gcd.c -t-gcd2.o: $(srcdir)/t-gcd2.c -dive.o: $(srcdir)/dive.c -t-sqrtrem.o: $(srcdir)/t-sqrtrem.c -convert.o: $(srcdir)/convert.c -io.o: $(srcdir)/io.c -logic.o: $(srcdir)/logic.c -t-powm.o: $(srcdir)/t-powm.c -t-powm_ui.o: $(srcdir)/t-powm_ui.c -reuse.o: $(srcdir)/reuse.c - -clean mostlyclean: - rm -f *.o st-* $(TESTS) -distclean maintainer-clean: clean - rm -f Makefile config.status - -Makefile: $(srcdir)/Makefile.in - $(SHELL) ./config.status diff --git a/gnu/lib/libgmp/mpz/tests/configure.in b/gnu/lib/libgmp/mpz/tests/configure.in deleted file mode 100644 index dacc177..0000000 --- a/gnu/lib/libgmp/mpz/tests/configure.in +++ /dev/null @@ -1,11 +0,0 @@ -# This file is a shell script that supplies the information necessary -# to tailor a template configure script into the configure script -# appropriate for this directory. For more information, check any -# existing configure script. - -srctrigger=t-mul.c -srcname="gmp/mpz/tests" - -# per-host: - -# per-target: diff --git a/gnu/lib/libgmp/mpz/tests/convert.c b/gnu/lib/libgmp/mpz/tests/convert.c deleted file mode 100644 index 1d82370..0000000 --- a/gnu/lib/libgmp/mpz/tests/convert.c +++ /dev/null @@ -1,80 +0,0 @@ -/* Test conversion using mpz_get_str and mpz_set_str. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 32 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - MP_INT op1, op2; - mp_size_t size; - int i; - int reps = 100000; - char *str; - int base; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (&op1); - mpz_init (&op2); - - for (i = 0; i < reps; i++) - { - size = urandom () % SIZE - SIZE/2; - - mpz_random2 (&op1, size); - base = urandom () % 36 + 1; - if (base == 1) - base = 0; - - str = mpz_get_str ((char *) 0, base, &op1); - mpz_set_str (&op2, str, base); - free (str); - - if (mpz_cmp (&op1, &op2)) - { - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "op1 = "); debug_mp (&op1, -16); - fprintf (stderr, "base = %d\n", base); - abort (); - } - } - - exit (0); -} - -void -debug_mp (x, base) - MP_INT *x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/mpz/tests/dive.c b/gnu/lib/libgmp/mpz/tests/dive.c deleted file mode 100644 index 8d3516d..0000000 --- a/gnu/lib/libgmp/mpz/tests/dive.c +++ /dev/null @@ -1,87 +0,0 @@ -/* Test mpz_mul, mpz_divexact. - -Copyright (C) 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 32 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpz_t op1, op2; - mpz_t prod, quot; - mp_size_t size; - int i; - int reps = 100000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (op1); - mpz_init (op2); - mpz_init (prod); - mpz_init (quot); - - for (i = 0; i < reps; i++) - { - size = urandom () % SIZE - SIZE/2; - mpz_random2 (op1, size); - - do - { - size = urandom () % SIZE - SIZE/2; - mpz_random2 (op2, size); - } - while (mpz_cmp_ui (op2, 0) == 0); - - mpz_mul (prod, op1, op2); - - mpz_divexact (quot, prod, op2); - if (mpz_cmp (quot, op1) != 0) - dump_abort (quot, op1); - } - - exit (0); -} - -dump_abort (op1, op2) - mpz_t op1, op2; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "ref = "); debug_mp (op1, -16); - fprintf (stderr, "wrong = "); debug_mp (op2, -16); - abort(); -} - -void -debug_mp (x, base) - mpz_t x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/mpz/tests/io-binary.c b/gnu/lib/libgmp/mpz/tests/io-binary.c deleted file mode 100644 index c28f2a5..0000000 --- a/gnu/lib/libgmp/mpz/tests/io-binary.c +++ /dev/null @@ -1,76 +0,0 @@ -/* Test mpz_inp_binary and mpz_out_binary. - - We write and read back some test strings, and both compare - the numerical result, and make sure the pattern on file is - what we expect. The latter is important for compatibility - between machines with different word sizes. */ - -#include -#include "gmp.h" - -FILE *file; - -test (str, binary_len, binary_str) - char *str; - int binary_len; - char *binary_str; -{ - mpz_t x, y; - int n_written; - char buf[100]; - - mpz_init_set_str (x, str, 0); - mpz_init (y); - - fseek (file, 0, SEEK_SET); - mpz_out_binary (file, x); - n_written = ftell (file); - if (n_written != binary_len) - abort (); - - fseek (file, 0, SEEK_SET); - mpz_inp_binary (y, file); - if (n_written != ftell (file)) - abort (); - if (mpz_cmp (x, y) != 0) - abort (); - - fseek (file, 0, SEEK_SET); - fread (buf, n_written, 1, file); - if (memcmp (buf, binary_str, binary_len) != 0) - abort (); - - mpz_clear (x); -} - -main () -{ - file = fopen ("xtmpfile", "w+"); - - test ("0", 4, - "\000\000\000\000"); - - test ("1", 5, - "\000\000\000\001\001"); - test ("0x123", 6, - "\000\000\000\002\001\043"); - test ("0xdeadbeef", 8, - "\000\000\000\004\336\255\276\357"); - test ("0xbabefaced", 9, - "\000\000\000\005\013\253\357\254\355"); - test ("0x123456789facade0", 12, - "\000\000\000\010\022\064\126\170\237\254\255\340"); - - test ("-1", 5, - "\377\377\377\377\001"); - test ("-0x123", 6, - "\377\377\377\376\001\043"); - test ("-0xdeadbeef", 8, - "\377\377\377\374\336\255\276\357"); - test ("-0xbabefaced", 9, - "\377\377\377\373\013\253\357\254\355"); - test ("-0x123456789facade0", 12, - "\377\377\377\370\022\064\126\170\237\254\255\340"); - - exit (0); -} diff --git a/gnu/lib/libgmp/mpz/tests/io.c b/gnu/lib/libgmp/mpz/tests/io.c deleted file mode 100644 index 3dfa9a5..0000000 --- a/gnu/lib/libgmp/mpz/tests/io.c +++ /dev/null @@ -1,86 +0,0 @@ -/* Test conversion and I/O using mpz_out_str and mpz_inp_str. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 16 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - MP_INT op1, op2; - mp_size_t size; - int i; - int reps = 10000; - FILE *fsin, *fsout; - int fd[2]; - int base; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (&op1); - mpz_init (&op2); - - pipe (fd); - fsin = fdopen (fd[0], "r"); - fsout = fdopen (fd[1], "w"); - - for (i = 0; i < reps; i++) - { - size = urandom () % SIZE - SIZE/2; - - mpz_random2 (&op1, size); - base = urandom () % 36 + 1; - if (base == 1) - base = 0; - - mpz_out_str (fsout, base, &op1); - putc (' ', fsout); - fflush (fsout); - mpz_inp_str (&op2, fsin, base); - - if (mpz_cmp (&op1, &op2)) - { - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "op1 = "); debug_mp (&op1, -16); - fprintf (stderr, "base = %d\n", base); - abort (); - } - } - - exit (0); -} - -void -debug_mp (x, base) - MP_INT *x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/mpz/tests/logic.c b/gnu/lib/libgmp/mpz/tests/logic.c deleted file mode 100644 index 41a8cac..0000000 --- a/gnu/lib/libgmp/mpz/tests/logic.c +++ /dev/null @@ -1,103 +0,0 @@ -/* Test mpz_com, mpz_and, and mpz_ior. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 16 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpz_t x, y, r1, r2; - mpz_t t1, t2, t3, t4; - mp_size_t xsize, ysize; - int i; - int reps = 100000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (x); - mpz_init (y); - mpz_init (r1); - mpz_init (r2); - mpz_init (t1); - mpz_init (t2); - mpz_init (t3); - mpz_init (t4); - - for (i = 0; i < reps; i++) - { - xsize = urandom () % SIZE - SIZE/2; - mpz_random2 (x, xsize); - - ysize = urandom () % SIZE - SIZE/2; - mpz_random2 (y, ysize); - - mpz_com (r1, x); - mpz_com (r1, r1); - if (mpz_cmp (r1, x) != 0) - dump_abort (); - - mpz_com (r1, y); - mpz_com (r2, r1); - if (mpz_cmp (r2, y) != 0) - dump_abort (); - - mpz_com (t1, x); - mpz_com (t2, y); - mpz_and (t3, t1, t2); - mpz_com (r1, t3); - mpz_ior (r2, x, y); - if (mpz_cmp (r1, r2) != 0) - dump_abort (); - - mpz_com (t1, x); - mpz_com (t2, y); - mpz_ior (t3, t1, t2); - mpz_com (r1, t3); - mpz_and (r2, x, y); - if (mpz_cmp (r1, r2) != 0) - dump_abort (); - } - - exit (0); -} - -dump_abort () -{ - abort(); -} - -void -debug_mp (x, base) - MP_INT *x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/mpz/tests/reuse.c b/gnu/lib/libgmp/mpz/tests/reuse.c deleted file mode 100644 index 52fc5a5..0000000 --- a/gnu/lib/libgmp/mpz/tests/reuse.c +++ /dev/null @@ -1,135 +0,0 @@ -/* Test that routines allow reusing a source variable as destination. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -#ifndef SIZE -#define SIZE 16 -#endif - -#if __STDC__ -typedef void (*dss_func) (mpz_ptr, mpz_srcptr, mpz_srcptr); -#else -typedef void (*dss_func) (); -#endif - -dss_func dss_funcs[] = -{ - mpz_add, mpz_and, mpz_cdiv_q, mpz_cdiv_r, mpz_fdiv_q, mpz_fdiv_r, - mpz_gcd, mpz_ior, mpz_mul, mpz_sub, mpz_tdiv_q, mpz_tdiv_r -}; - -char *dss_func_names[] = -{ - "mpz_add", "mpz_and", "mpz_cdiv_q", "mpz_cdiv_r", "mpz_fdiv_q", "mpz_fdiv_r", - "mpz_gcd", "mpz_ior", "mpz_mul", "mpz_sub", "mpz_tdiv_q", "mpz_tdiv_r" -}; - -char dss_func_division[] = {0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1}; - -#if 0 -mpz_divexact /* requires special operands */ -#endif - -main (argc, argv) - int argc; - char **argv; -{ - int i; - int pass, reps = 10000; - mpz_t in1, in2, out1; - mpz_t res1, res2, res3; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (in1); - mpz_init (in2); - mpz_init (out1); - mpz_init (res1); - mpz_init (res2); - mpz_init (res3); - - for (pass = 1; pass <= reps; pass++) - { - mpz_random (in1, urandom () % SIZE - SIZE/2); - mpz_random (in2, urandom () % SIZE - SIZE/2); - - for (i = 0; i < sizeof (dss_funcs) / sizeof (dss_func); i++) - { - if (dss_func_division[i] && mpz_cmp_ui (in2, 0) == 0) - continue; - - (dss_funcs[i]) (res1, in1, in2); - - mpz_set (out1, in1); - (dss_funcs[i]) (out1, out1, in2); - mpz_set (res2, out1); - - mpz_set (out1, in2); - (dss_funcs[i]) (out1, in1, out1); - mpz_set (res3, out1); - - if (mpz_cmp (res1, res2) != 0) - dump_abort (dss_func_names[i], in1, in2); - if (mpz_cmp (res1, res3) != 0) - dump_abort (dss_func_names[i], in1, in2); - } - } - - exit (0); -} - -dump_abort (name, in1, in2) - char *name; - mpz_t in1, in2; -{ - printf ("failure in %s (", name); - mpz_out_str (stdout, -16, in1); - printf (" "); - mpz_out_str (stdout, -16, in2); - printf (")\n"); - abort (); -} - -#if 0 -void mpz_add_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -void mpz_div_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -void mpz_mod_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -void mpz_mul_2exp _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -void mpz_mul_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -void mpz_pow_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -void mpz_sub_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -void mpz_tdiv_q_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -void mpz_tdiv_r_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); - -void mpz_abs _PROTO ((mpz_ptr, mpz_srcptr)); -void mpz_com _PROTO ((mpz_ptr, mpz_srcptr)); -void mpz_sqrt _PROTO ((mpz_ptr, mpz_srcptr)); -void mpz_neg _PROTO ((mpz_ptr, mpz_srcptr)); - -void mpz_tdiv_qr_ui _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int)); - -void mpz_powm_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr)); - -void mpz_gcdext _PROTO ((mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); - -void mpz_cdiv_qr _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); -void mpz_fdiv_qr _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); -void mpz_tdiv_qr _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr)); - -void mpz_powm _PROTO ((mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr)); - -void mpz_sqrtrem _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr)); - -unsigned long int mpz_cdiv_qr_ui _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int)); -unsigned long int mpz_fdiv_qr_ui _PROTO ((mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int)); - -unsigned long int mpz_cdiv_q_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -unsigned long int mpz_cdiv_r_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -unsigned long int mpz_fdiv_q_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -unsigned long int mpz_fdiv_r_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -unsigned long int mpz_gcd_ui _PROTO ((mpz_ptr, mpz_srcptr, unsigned long int)); -#endif diff --git a/gnu/lib/libgmp/mpz/tests/t-fdiv.c b/gnu/lib/libgmp/mpz/tests/t-fdiv.c deleted file mode 100644 index 9de22d7..0000000 --- a/gnu/lib/libgmp/mpz/tests/t-fdiv.c +++ /dev/null @@ -1,118 +0,0 @@ -/* Test mpz_abs, mpz_add, mpz_cmp, mpz_cmp_ui, mpz_fdiv_qr, mpz_fdiv_q, - mpz_fdiv_r, mpz_mul. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 16 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpz_t dividend, divisor; - mpz_t quotient, remainder; - mpz_t quotient2, remainder2; - mpz_t temp; - mp_size_t dividend_size, divisor_size; - int i; - int reps = 100000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (dividend); - mpz_init (divisor); - mpz_init (quotient); - mpz_init (remainder); - mpz_init (quotient2); - mpz_init (remainder2); - mpz_init (temp); - - for (i = 0; i < reps; i++) - { - dividend_size = urandom () % SIZE - SIZE/2; - mpz_random2 (dividend, dividend_size); - - divisor_size = urandom () % SIZE - SIZE/2; - mpz_random2 (divisor, divisor_size); - if (mpz_cmp_ui (divisor, 0) == 0) - continue; - - mpz_fdiv_qr (quotient, remainder, dividend, divisor); - mpz_fdiv_q (quotient2, dividend, divisor); - mpz_fdiv_r (remainder2, dividend, divisor); - - /* First determine that the quotients and remainders computed - with different functions are equal. */ - if (mpz_cmp (quotient, quotient2) != 0) - dump_abort (dividend, divisor); - if (mpz_cmp (remainder, remainder2) != 0) - dump_abort (dividend, divisor); - - /* Check if the sign of the quotient is correct. */ - if (mpz_cmp_ui (quotient, 0) != 0) - if ((mpz_cmp_ui (quotient, 0) < 0) - != ((mpz_cmp_ui (dividend, 0) ^ mpz_cmp_ui (divisor, 0)) < 0)) - dump_abort (dividend, divisor); - - /* Check if the remainder has the same sign as the divisor - (quotient rounded towards minus infinity). */ - if (mpz_cmp_ui (remainder, 0) != 0) - if ((mpz_cmp_ui (remainder, 0) < 0) != (mpz_cmp_ui (divisor, 0) < 0)) - dump_abort (dividend, divisor); - - mpz_mul (temp, quotient, divisor); - mpz_add (temp, temp, remainder); - if (mpz_cmp (temp, dividend) != 0) - dump_abort (dividend, divisor); - - mpz_abs (temp, divisor); - mpz_abs (remainder, remainder); - if (mpz_cmp (remainder, temp) >= 0) - dump_abort (dividend, divisor); - } - - exit (0); -} - -dump_abort (dividend, divisor) - mpz_t dividend, divisor; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = "); debug_mp (divisor, -16); - abort(); -} - -void -debug_mp (x, base) - mpz_t x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/mpz/tests/t-fdiv_ui.c b/gnu/lib/libgmp/mpz/tests/t-fdiv_ui.c deleted file mode 100644 index 74ba9fc..0000000 --- a/gnu/lib/libgmp/mpz/tests/t-fdiv_ui.c +++ /dev/null @@ -1,117 +0,0 @@ -/* Test mpz_abs, mpz_add, mpz_cmp, mpz_cmp_ui, mpz_fdiv_qr_ui, mpz_fdiv_q_ui, - mpz_fdiv_r_ui, mpz_mul, mpz_mul_ui. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 16 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpz_t dividend; - mpz_t quotient, remainder; - mpz_t quotient2, remainder2; - mpz_t temp; - mp_size_t dividend_size; - mp_limb_t divisor; - int i; - int reps = 100000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (dividend); - mpz_init (quotient); - mpz_init (remainder); - mpz_init (quotient2); - mpz_init (remainder2); - mpz_init (temp); - - for (i = 0; i < reps; i++) - { - dividend_size = urandom () % SIZE - SIZE/2; - mpz_random2 (dividend, dividend_size); - - divisor = urandom (); - if (divisor == 0) - continue; - - mpz_fdiv_qr_ui (quotient, remainder, dividend, divisor); - mpz_fdiv_q_ui (quotient2, dividend, divisor); - mpz_fdiv_r_ui (remainder2, dividend, divisor); - - /* First determine that the quotients and remainders computed - with different functions are equal. */ - if (mpz_cmp (quotient, quotient2) != 0) - dump_abort (dividend, divisor); - if (mpz_cmp (remainder, remainder2) != 0) - dump_abort (dividend, divisor); - - /* Check if the sign of the quotient is correct. */ - if (mpz_cmp_ui (quotient, 0) != 0) - if ((mpz_cmp_ui (quotient, 0) < 0) - != (mpz_cmp_ui (dividend, 0) < 0)) - dump_abort (dividend, divisor); - - /* Check if the remainder has the same sign as the divisor - (quotient rounded towards minus infinity). */ - if (mpz_cmp_ui (remainder, 0) != 0) - if (mpz_cmp_ui (remainder, 0) < 0) - dump_abort (dividend, divisor); - - mpz_mul_ui (temp, quotient, divisor); - mpz_add (temp, temp, remainder); - if (mpz_cmp (temp, dividend) != 0) - dump_abort (dividend, divisor); - - mpz_abs (remainder, remainder); - if (mpz_cmp_ui (remainder, divisor) >= 0) - dump_abort (dividend, divisor); - } - - exit (0); -} - -dump_abort (dividend, divisor) - mpz_t dividend; - mp_limb_t divisor; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = %lX\n", divisor); - abort(); -} - -void -debug_mp (x, base) - mpz_t x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/mpz/tests/t-gcd.c b/gnu/lib/libgmp/mpz/tests/t-gcd.c deleted file mode 100644 index d9a7884..0000000 --- a/gnu/lib/libgmp/mpz/tests/t-gcd.c +++ /dev/null @@ -1,132 +0,0 @@ -/* Test mpz_gcd, mpz_gcdext, mpz_mul, mpz_tdiv_r, mpz_add, mpz_cmp, - mpz_cmp_ui, mpz_init_set, mpz_set, mpz_clear. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void mpz_refgcd (), debug_mp (); - -#ifndef SIZE -#define SIZE 256 /* really needs to be this large to exercise corner cases! */ -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpz_t op1, op2; - mpz_t refgcd, gcd, s, t; - mpz_t temp1, temp2; - mp_size_t op1_size, op2_size; - int i; - int reps = 1000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (op1); - mpz_init (op2); - mpz_init (refgcd); - mpz_init (gcd); - mpz_init (temp1); - mpz_init (temp2); - mpz_init (s); - mpz_init (t); - - for (i = 0; i < reps; i++) - { - op1_size = urandom () % SIZE - SIZE/2; - op2_size = urandom () % SIZE - SIZE/2; - - mpz_random2 (op1, op1_size); - mpz_random2 (op2, op2_size); - - mpz_refgcd (refgcd, op1, op2); - - mpz_gcd (gcd, op1, op2); - if (mpz_cmp (refgcd, gcd)) - dump_abort (op1, op2); - - mpz_gcdext (gcd, s, t, op1, op2); - if (mpz_cmp (refgcd, gcd)) - dump_abort (op1, op2); - - mpz_mul (temp1, s, op1); - mpz_mul (temp2, t, op2); - mpz_add (gcd, temp1, temp2); - if (mpz_cmp (refgcd, gcd)) - dump_abort (op1, op2); - } - - exit (0); -} - -void -mpz_refgcd (g, x, y) - mpz_t g; - mpz_t x, y; -{ - mpz_t xx, yy; - - mpz_init (xx); - mpz_init (yy); - - mpz_abs (xx, x); - mpz_abs (yy, y); - - for (;;) - { - if (mpz_cmp_ui (yy, 0) == 0) - { - mpz_set (g, xx); - break; - } - mpz_tdiv_r (xx, xx, yy); - if (mpz_cmp_ui (xx, 0) == 0) - { - mpz_set (g, yy); - break; - } - mpz_tdiv_r (yy, yy, xx); - } - - mpz_clear (xx); - mpz_clear (yy); -} - -dump_abort (op1, op2) - mpz_t op1, op2; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "op1 = "); debug_mp (op1, -16); - fprintf (stderr, "op2 = "); debug_mp (op2, -16); - abort(); -} - -void -debug_mp (x, base) - mpz_t x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/mpz/tests/t-gcd2.c b/gnu/lib/libgmp/mpz/tests/t-gcd2.c deleted file mode 100644 index b7ad67c..0000000 --- a/gnu/lib/libgmp/mpz/tests/t-gcd2.c +++ /dev/null @@ -1,137 +0,0 @@ -/* Test mpz_gcd, mpz_gcdext, mpz_mul, mpz_tdiv_r, mpz_add, mpz_cmp, - mpz_cmp_ui, mpz_init_set, mpz_set, mpz_clear. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void mpz_refgcd (), debug_mp (); - -#ifndef SIZE -#define SIZE 128 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpz_t op1, op2, x; - mpz_t refgcd, gcd, s, t; - mpz_t temp1, temp2; - mp_size_t op1_size, op2_size, x_size; - int i; - int reps = 1000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (op1); - mpz_init (op2); - mpz_init (x); - mpz_init (refgcd); - mpz_init (gcd); - mpz_init (temp1); - mpz_init (temp2); - mpz_init (s); - mpz_init (t); - - for (i = 0; i < reps; i++) - { - op1_size = urandom () % SIZE - SIZE/2; - op2_size = urandom () % SIZE - SIZE/2; - x_size = urandom () % SIZE/2; - - mpz_random2 (op1, op1_size); - mpz_random2 (op2, op2_size); - mpz_random2 (x, x_size); - mpz_mul (op1, op1, x); - mpz_mul (op2, op2, x); - - mpz_refgcd (refgcd, op1, op2); - - mpz_gcd (gcd, op1, op2); - if (mpz_cmp (refgcd, gcd)) - dump_abort (op1, op2); - - mpz_gcdext (gcd, s, t, op1, op2); - if (mpz_cmp (refgcd, gcd)) - dump_abort (op1, op2); - - mpz_mul (temp1, s, op1); - mpz_mul (temp2, t, op2); - mpz_add (gcd, temp1, temp2); - if (mpz_cmp (refgcd, gcd)) - dump_abort (op1, op2); - } - - exit (0); -} - -void -mpz_refgcd (g, x, y) - mpz_t g; - mpz_t x, y; -{ - mpz_t xx, yy; - - mpz_init (xx); - mpz_init (yy); - - mpz_abs (xx, x); - mpz_abs (yy, y); - - for (;;) - { - if (mpz_cmp_ui (yy, 0) == 0) - { - mpz_set (g, xx); - break; - } - mpz_tdiv_r (xx, xx, yy); - if (mpz_cmp_ui (xx, 0) == 0) - { - mpz_set (g, yy); - break; - } - mpz_tdiv_r (yy, yy, xx); - } - - mpz_clear (xx); - mpz_clear (yy); -} - -dump_abort (op1, op2) - mpz_t op1, op2; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "op1 = "); debug_mp (op1, -16); - fprintf (stderr, "op2 = "); debug_mp (op2, -16); - abort(); -} - -void -debug_mp (x, base) - mpz_t x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/mpz/tests/t-mul.c b/gnu/lib/libgmp/mpz/tests/t-mul.c deleted file mode 100644 index b200cd7..0000000 --- a/gnu/lib/libgmp/mpz/tests/t-mul.c +++ /dev/null @@ -1,261 +0,0 @@ -/* Test mpz_add, mpz_cmp, mpz_cmp_ui, mpz_divmod, mpz_mul. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" -#include "urandom.h" - -void debug_mp (); -mp_size_t _mpn_mul_classic (); -void mpz_refmul (); - -#ifndef SIZE -#define SIZE 128 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpz_t multiplier, multiplicand; - mpz_t product, ref_product; - mpz_t quotient, remainder; - mp_size_t multiplier_size, multiplicand_size; - int i; - int reps = 10000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (multiplier); - mpz_init (multiplicand); - mpz_init (product); - mpz_init (ref_product); - mpz_init (quotient); - mpz_init (remainder); - - for (i = 0; i < reps; i++) - { - multiplier_size = urandom () % SIZE - SIZE/2; - multiplicand_size = urandom () % SIZE - SIZE/2; - - mpz_random2 (multiplier, multiplier_size); - mpz_random2 (multiplicand, multiplicand_size); - - mpz_mul (product, multiplier, multiplicand); - mpz_refmul (ref_product, multiplier, multiplicand); - if (mpz_cmp_ui (multiplicand, 0) != 0) - mpz_divmod (quotient, remainder, product, multiplicand); - - if (mpz_cmp (product, ref_product)) - dump_abort (multiplier, multiplicand); - - if (mpz_cmp_ui (multiplicand, 0) != 0) - if (mpz_cmp_ui (remainder, 0) || mpz_cmp (quotient, multiplier)) - dump_abort (multiplier, multiplicand); - } - - exit (0); -} - -void -mpz_refmul (w, u, v) - mpz_t w; - const mpz_t u; - const mpz_t v; -{ - mp_size_t usize = u->_mp_size; - mp_size_t vsize = v->_mp_size; - mp_size_t wsize; - mp_size_t sign_product; - mp_ptr up, vp; - mp_ptr wp; - mp_ptr free_me = NULL; - size_t free_me_size; - TMP_DECL (marker); - - TMP_MARK (marker); - sign_product = usize ^ vsize; - usize = ABS (usize); - vsize = ABS (vsize); - - if (usize < vsize) - { - /* Swap U and V. */ - {const __mpz_struct *t = u; u = v; v = t;} - {mp_size_t t = usize; usize = vsize; vsize = t;} - } - - up = u->_mp_d; - vp = v->_mp_d; - wp = w->_mp_d; - - /* Ensure W has space enough to store the result. */ - wsize = usize + vsize; - if (w->_mp_alloc < wsize) - { - if (wp == up || wp == vp) - { - free_me = wp; - free_me_size = w->_mp_alloc; - } - else - (*_mp_free_func) (wp, w->_mp_alloc * BYTES_PER_MP_LIMB); - - w->_mp_alloc = wsize; - wp = (mp_ptr) (*_mp_allocate_func) (wsize * BYTES_PER_MP_LIMB); - w->_mp_d = wp; - } - else - { - /* Make U and V not overlap with W. */ - if (wp == up) - { - /* W and U are identical. Allocate temporary space for U. */ - up = (mp_ptr) TMP_ALLOC (usize * BYTES_PER_MP_LIMB); - /* Is V identical too? Keep it identical with U. */ - if (wp == vp) - vp = up; - /* Copy to the temporary space. */ - MPN_COPY (up, wp, usize); - } - else if (wp == vp) - { - /* W and V are identical. Allocate temporary space for V. */ - vp = (mp_ptr) TMP_ALLOC (vsize * BYTES_PER_MP_LIMB); - /* Copy to the temporary space. */ - MPN_COPY (vp, wp, vsize); - } - } - - wsize = _mpn_mul_classic (wp, up, usize, vp, vsize); - w->_mp_size = sign_product < 0 ? -wsize : wsize; - if (free_me != NULL) - (*_mp_free_func) (free_me, free_me_size * BYTES_PER_MP_LIMB); - - TMP_FREE (marker); -} - -mp_size_t -_mpn_mul_classic (prodp, up, usize, vp, vsize) - mp_ptr prodp; - mp_srcptr up; - mp_size_t usize; - mp_srcptr vp; - mp_size_t vsize; -{ - mp_size_t i, j; - mp_limb_t prod_low, prod_high; - mp_limb_t cy_dig; - mp_limb_t v_limb, c; - - if (vsize == 0) - return 0; - - /* Offset UP and PRODP so that the inner loop can be faster. */ - up += usize; - prodp += usize; - - /* Multiply by the first limb in V separately, as the result can - be stored (not added) to PROD. We also avoid a loop for zeroing. */ - v_limb = vp[0]; - cy_dig = 0; - j = -usize; - do - { - umul_ppmm (prod_high, prod_low, up[j], v_limb); - add_ssaaaa (cy_dig, prodp[j], prod_high, prod_low, 0, cy_dig); - j++; - } - while (j < 0); - - prodp[j] = cy_dig; - prodp++; - - /* For each iteration in the outer loop, multiply one limb from - U with one limb from V, and add it to PROD. */ - for (i = 1; i < vsize; i++) - { - v_limb = vp[i]; - cy_dig = 0; - j = -usize; - - /* Inner loops. Simulate the carry flag by jumping between - these loops. The first is used when there was no carry - in the previois iteration; the second when there was carry. */ - - do - { - umul_ppmm (prod_high, prod_low, up[j], v_limb); - add_ssaaaa (cy_dig, prod_low, prod_high, prod_low, 0, cy_dig); - c = prodp[j]; - prod_low += c; - prodp[j] = prod_low; - if (prod_low < c) - goto cy_loop; - ncy_loop: - j++; - } - while (j < 0); - - prodp[j] = cy_dig; - prodp++; - continue; - - do - { - umul_ppmm (prod_high, prod_low, up[j], v_limb); - add_ssaaaa (cy_dig, prod_low, prod_high, prod_low, 0, cy_dig); - c = prodp[j]; - prod_low += c + 1; - prodp[j] = prod_low; - if (prod_low > c) - goto ncy_loop; - cy_loop: - j++; - } - while (j < 0); - - cy_dig += 1; - prodp[j] = cy_dig; - prodp++; - } - - return usize + vsize - (cy_dig == 0); -} - -dump_abort (multiplier, multiplicand) - mpz_t multiplier, multiplicand; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "multiplier = "); debug_mp (multiplier, -16); - fprintf (stderr, "multiplicand = "); debug_mp (multiplicand, -16); - abort(); -} - -void -debug_mp (x, base) - mpz_t x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/mpz/tests/t-powm.c b/gnu/lib/libgmp/mpz/tests/t-powm.c deleted file mode 100644 index 02d7ca5..0000000 --- a/gnu/lib/libgmp/mpz/tests/t-powm.c +++ /dev/null @@ -1,125 +0,0 @@ -/* Test mpz_powm, mpz_mul. mpz_mod, mpz_mod_ui, mpz_div_ui. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 8 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpz_t base, exp, mod; - mpz_t r1, r2, t1, exp2, base2; - mp_size_t base_size, exp_size, mod_size; - int i; - int reps = 10000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (base); - mpz_init (exp); - mpz_init (mod); - mpz_init (r1); - mpz_init (r2); - mpz_init (t1); - mpz_init (exp2); - mpz_init (base2); - - for (i = 0; i < reps; i++) - { - base_size = urandom () % SIZE - SIZE/2; - mpz_random2 (base, base_size); - - exp_size = urandom () % SIZE; - mpz_random2 (exp, exp_size); - - mod_size = urandom () % SIZE /* - SIZE/2 */; - mpz_random2 (mod, mod_size); - if (mpz_cmp_ui (mod, 0) == 0) - continue; - - /* This is mathematically undefined. */ - if (mpz_cmp_ui (base, 0) == 0 && mpz_cmp_ui (exp, 0) == 0) - continue; - -#if 0 - putc ('\n', stderr); - debug_mp (base, -16); - debug_mp (exp, -16); - debug_mp (mod, -16); -#endif - - mpz_powm (r1, base, exp, mod); - - mpz_set_ui (r2, 1); - mpz_set (base2, base); - mpz_set (exp2, exp); - - mpz_mod (r2, r2, mod); /* needed when exp==0 and mod==1 */ - while (mpz_cmp_ui (exp2, 0) != 0) - { - mpz_mod_ui (t1, exp2, 2); - if (mpz_cmp_ui (t1, 0) != 0) - { - mpz_mul (r2, r2, base2); - mpz_mod (r2, r2, mod); - } - mpz_mul (base2, base2, base2); - mpz_mod (base2, base2, mod); - mpz_div_ui (exp2, exp2, 2); - } - -#if 0 - debug_mp (r1, -16); - debug_mp (r2, -16); -#endif - - if (mpz_cmp (r1, r2) != 0) - abort (); - } - - exit (0); -} - -dump_abort (dividend, divisor) - MP_INT *dividend, *divisor; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = "); debug_mp (divisor, -16); - abort(); -} - -void -debug_mp (x, base) - MP_INT *x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/mpz/tests/t-powm_ui.c b/gnu/lib/libgmp/mpz/tests/t-powm_ui.c deleted file mode 100644 index b88fa98..0000000 --- a/gnu/lib/libgmp/mpz/tests/t-powm_ui.c +++ /dev/null @@ -1,120 +0,0 @@ -/* Test mpz_powm_ui, mpz_mul. mpz_mod, mpz_mod_ui, mpz_div_ui. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 8 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpz_t base, mod; - mpz_t r1, r2, base2; - mp_size_t base_size, mod_size; - mp_limb_t exp, exp2; - int i; - int reps = 10000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (base); - mpz_init (mod); - mpz_init (r1); - mpz_init (r2); - mpz_init (base2); - - for (i = 0; i < reps; i++) - { - base_size = urandom () % SIZE /* - SIZE/2 */; - mpz_random2 (base, base_size); - - mpn_random2 (&exp, 1); - - mod_size = urandom () % SIZE /* - SIZE/2 */; - mpz_random2 (mod, mod_size); - if (mpz_cmp_ui (mod, 0) == 0) - continue; - - /* This is mathematically undefined. */ - if (mpz_cmp_ui (base, 0) == 0 && exp == 0) - continue; - -#if 0 - putc ('\n', stderr); - debug_mp (base, -16); - debug_mp (mod, -16); -#endif - - mpz_powm_ui (r1, base, (unsigned long int) exp, mod); - - mpz_set_ui (r2, 1); - mpz_set (base2, base); - exp2 = exp; - - mpz_mod (r2, r2, mod); /* needed when exp==0 and mod==1 */ - while (exp2 != 0) - { - if (exp2 % 2 != 0) - { - mpz_mul (r2, r2, base2); - mpz_mod (r2, r2, mod); - } - mpz_mul (base2, base2, base2); - mpz_mod (base2, base2, mod); - exp2 = exp2 / 2; - } - -#if 0 - debug_mp (r1, -16); - debug_mp (r2, -16); -#endif - - if (mpz_cmp (r1, r2) != 0) - abort (); - } - - exit (0); -} - -dump_abort (dividend, divisor) - MP_INT *dividend, *divisor; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = "); debug_mp (divisor, -16); - abort(); -} - -void -debug_mp (x, base) - MP_INT *x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/mpz/tests/t-sqrtrem.c b/gnu/lib/libgmp/mpz/tests/t-sqrtrem.c deleted file mode 100644 index f5fcd09..0000000 --- a/gnu/lib/libgmp/mpz/tests/t-sqrtrem.c +++ /dev/null @@ -1,98 +0,0 @@ -/* Test mpz_add, mpz_add_ui, mpz_cmp, mpz_cmp, mpz_mul, mpz_sqrtrem. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 16 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpz_t x2; - mpz_t x, rem; - mpz_t temp, temp2; - mp_size_t x2_size; - int i; - int reps = 100000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (x2); - mpz_init (x); - mpz_init (rem); - mpz_init (temp); - mpz_init (temp2); - - for (i = 0; i < reps; i++) - { - x2_size = urandom () % SIZE; - - mpz_random2 (x2, x2_size); - - mpz_sqrtrem (x, rem, x2); - mpz_mul (temp, x, x); - - /* Is square of result > argument? */ - if (mpz_cmp (temp, x2) > 0) - dump_abort (x2, x, rem); - - mpz_add_ui (temp2, x, 1); - mpz_mul (temp2, temp2, temp2); - - /* Is square of (result + 1) <= argument? */ - if (mpz_cmp (temp2, x2) <= 0) - dump_abort (x2, x, rem); - - mpz_add (temp2, temp, rem); - - /* Is the remainder wrong? */ - if (mpz_cmp (x2, temp2) != 0) - dump_abort (x2, x, rem); - } - - exit (0); -} - -dump_abort (x2, x, rem) - mpz_t x2, x, rem; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "x2 = "); debug_mp (x2, -16); - fprintf (stderr, "x = "); debug_mp (x, -16); - fprintf (stderr, "remainder = "); debug_mp (rem, -16); - abort(); -} - -void -debug_mp (x, base) - mpz_t x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/mpz/tests/t-tdiv.c b/gnu/lib/libgmp/mpz/tests/t-tdiv.c deleted file mode 100644 index d646ed8..0000000 --- a/gnu/lib/libgmp/mpz/tests/t-tdiv.c +++ /dev/null @@ -1,118 +0,0 @@ -/* Test mpz_abs, mpz_add, mpz_cmp, mpz_cmp_ui, mpz_tdiv_qr, mpz_tdiv_q, - mpz_tdiv_r, mpz_mul. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 16 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpz_t dividend, divisor; - mpz_t quotient, remainder; - mpz_t quotient2, remainder2; - mpz_t temp; - mp_size_t dividend_size, divisor_size; - int i; - int reps = 100000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (dividend); - mpz_init (divisor); - mpz_init (quotient); - mpz_init (remainder); - mpz_init (quotient2); - mpz_init (remainder2); - mpz_init (temp); - - for (i = 0; i < reps; i++) - { - dividend_size = urandom () % SIZE - SIZE/2; - mpz_random2 (dividend, dividend_size); - - divisor_size = urandom () % SIZE - SIZE/2; - mpz_random2 (divisor, divisor_size); - if (mpz_cmp_ui (divisor, 0) == 0) - continue; - - mpz_tdiv_qr (quotient, remainder, dividend, divisor); - mpz_tdiv_q (quotient2, dividend, divisor); - mpz_tdiv_r (remainder2, dividend, divisor); - - /* First determine that the quotients and remainders computed - with different functions are equal. */ - if (mpz_cmp (quotient, quotient2) != 0) - dump_abort (dividend, divisor); - if (mpz_cmp (remainder, remainder2) != 0) - dump_abort (dividend, divisor); - - /* Check if the sign of the quotient is correct. */ - if (mpz_cmp_ui (quotient, 0) != 0) - if ((mpz_cmp_ui (quotient, 0) < 0) - != ((mpz_cmp_ui (dividend, 0) ^ mpz_cmp_ui (divisor, 0)) < 0)) - dump_abort (dividend, divisor); - - /* Check if the remainder has the same sign as the dividend - (quotient rounded towards 0). */ - if (mpz_cmp_ui (remainder, 0) != 0) - if ((mpz_cmp_ui (remainder, 0) < 0) != (mpz_cmp_ui (dividend, 0) < 0)) - dump_abort (dividend, divisor); - - mpz_mul (temp, quotient, divisor); - mpz_add (temp, temp, remainder); - if (mpz_cmp (temp, dividend) != 0) - dump_abort (dividend, divisor); - - mpz_abs (temp, divisor); - mpz_abs (remainder, remainder); - if (mpz_cmp (remainder, temp) >= 0) - dump_abort (dividend, divisor); - } - - exit (0); -} - -dump_abort (dividend, divisor) - mpz_t dividend, divisor; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = "); debug_mp (divisor, -16); - abort(); -} - -void -debug_mp (x, base) - mpz_t x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/mpz/tests/t-tdiv_ui.c b/gnu/lib/libgmp/mpz/tests/t-tdiv_ui.c deleted file mode 100644 index 8d73b11..0000000 --- a/gnu/lib/libgmp/mpz/tests/t-tdiv_ui.c +++ /dev/null @@ -1,117 +0,0 @@ -/* Test mpz_abs, mpz_add, mpz_cmp, mpz_cmp_ui, mpz_tdiv_qr_ui, mpz_tdiv_q_ui, - mpz_tdiv_r_ui, mpz_mul_ui. - -Copyright (C) 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 16 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - mpz_t dividend; - mpz_t quotient, remainder; - mpz_t quotient2, remainder2; - mpz_t temp; - mp_size_t dividend_size; - mp_limb_t divisor; - int i; - int reps = 100000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (dividend); - mpz_init (quotient); - mpz_init (remainder); - mpz_init (quotient2); - mpz_init (remainder2); - mpz_init (temp); - - for (i = 0; i < reps; i++) - { - dividend_size = urandom () % SIZE - SIZE/2; - mpz_random2 (dividend, dividend_size); - - divisor = urandom (); - if (divisor == 0) - continue; - - mpz_tdiv_qr_ui (quotient, remainder, dividend, divisor); - mpz_tdiv_q_ui (quotient2, dividend, divisor); - mpz_tdiv_r_ui (remainder2, dividend, divisor); - - /* First determine that the quotients and remainders computed - with different functions are equal. */ - if (mpz_cmp (quotient, quotient2) != 0) - dump_abort (dividend, divisor); - if (mpz_cmp (remainder, remainder2) != 0) - dump_abort (dividend, divisor); - - /* Check if the sign of the quotient is correct. */ - if (mpz_cmp_ui (quotient, 0) != 0) - if ((mpz_cmp_ui (quotient, 0) < 0) - != (mpz_cmp_ui (dividend, 0) < 0)) - dump_abort (dividend, divisor); - - /* Check if the remainder has the same sign as the dividend - (quotient rounded towards 0). */ - if (mpz_cmp_ui (remainder, 0) != 0) - if ((mpz_cmp_ui (remainder, 0) < 0) != (mpz_cmp_ui (dividend, 0) < 0)) - dump_abort (dividend, divisor); - - mpz_mul_ui (temp, quotient, divisor); - mpz_add (temp, temp, remainder); - if (mpz_cmp (temp, dividend) != 0) - dump_abort (dividend, divisor); - - mpz_abs (remainder, remainder); - if (mpz_cmp_ui (remainder, divisor) >= 0) - dump_abort (dividend, divisor); - } - - exit (0); -} - -dump_abort (dividend, divisor) - mpz_t dividend; - mp_limb_t divisor; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = %lX\n", divisor); - abort(); -} - -void -debug_mp (x, base) - mpz_t x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/mpz/ui_pow_ui.c b/gnu/lib/libgmp/mpz/ui_pow_ui.c deleted file mode 100644 index 19baca1..0000000 --- a/gnu/lib/libgmp/mpz/ui_pow_ui.c +++ /dev/null @@ -1,111 +0,0 @@ -/* mpz_ui_pow_ui(res, base, exp) -- Set RES to BASE**EXP. - -Copyright (C) 1991, 1993, 1994, 1996 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 Library General Public License as published by -the Free Software Foundation; either version 2 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 Library General Public -License for more details. - -You should have received a copy of the GNU Library General Public License -along with the GNU MP Library; see the file COPYING.LIB. If not, write to -the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, -MA 02111-1307, USA. */ - -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void -#if __STDC__ -mpz_ui_pow_ui (mpz_ptr r, unsigned long int b, unsigned long int e) -#else -mpz_ui_pow_ui (r, b, e) - mpz_ptr r; - unsigned long int b; - unsigned long int e; -#endif -{ - mp_ptr rp, tp, xp; - mp_size_t rsize; - int cnt, i; - mp_limb_t blimb = b; - TMP_DECL (marker); - - /* Single out cases that give result == 0 or 1. These tests are here - to simplify the general code below, not to optimize. */ - if (e == 0) - { - r->_mp_d[0] = 1; - r->_mp_size = 1; - return; - } - if (blimb == 0) - { - r->_mp_size = 0; - return; - } - - if (blimb < 0x100) - { - /* Estimate space requirements accurately. Using the code from the - `else' path would over-estimate space requirements wildly. */ - float lb = __mp_bases[blimb].chars_per_bit_exactly; - rsize = 2 + ((mp_size_t) (e / lb) / BITS_PER_MP_LIMB); - } - else - { - /* Over-estimate space requirements somewhat. */ - count_leading_zeros (cnt, blimb); - rsize = e - cnt * e / BITS_PER_MP_LIMB + 1; - } - - TMP_MARK (marker); - - /* The two areas are used to alternatingly hold the input and recieve the - product for mpn_mul. (This scheme is used to fulfill the requirements - of mpn_mul; that the product space may not be the same as any of the - input operands.) */ - rp = (mp_ptr) TMP_ALLOC (rsize * BYTES_PER_MP_LIMB); - tp = (mp_ptr) TMP_ALLOC (rsize * BYTES_PER_MP_LIMB); - - rp[0] = blimb; - rsize = 1; - count_leading_zeros (cnt, e); - - for (i = BITS_PER_MP_LIMB - cnt - 2; i >= 0; i--) - { - mpn_mul_n (tp, rp, rp, rsize); - rsize = 2 * rsize; - rsize -= tp[rsize - 1] == 0; - xp = tp; tp = rp; rp = xp; - - if ((e & ((mp_limb_t) 1 << i)) != 0) - { - mp_limb_t cy; - cy = mpn_mul_1 (tp, rp, rsize, blimb); - if (cy != 0) - { - tp[rsize] = cy; - rsize++; - } - xp = tp; tp = rp; rp = xp; - } - } - - /* Now then we know the exact space requirements, reallocate if - necessary. */ - if (r->_mp_alloc < rsize) - _mpz_realloc (r, rsize); - - MPN_COPY (r->_mp_d, rp, rsize); - r->_mp_size = rsize; - TMP_FREE (marker); -} diff --git a/gnu/lib/libgmp/tests/Makefile b/gnu/lib/libgmp/tests/Makefile deleted file mode 100644 index 06a6749..0000000 --- a/gnu/lib/libgmp/tests/Makefile +++ /dev/null @@ -1,66 +0,0 @@ -# Makefile for tests for GNU MP - -# Copyright (C) 1991, 1993 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 General Public License as published by -# the Free Software Foundation; either version 2, 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 General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with the GNU MP Library; see the file COPYING. If not, write to -# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -.PATH: ${.CURDIR}/.. ${.OBJDIR} ${.OBJDIR}/../libgmp - -CC = gcc - -TEST_LIBS = -lgmp -OPT = -O -g -CFLAGS = -I${.CURDIR} -I${.CURDIR}/.. -I${.OBJDIR}/.. -I${.CURDIR}/../libgmp -I${.OBJDIR}/../libgmp $(OPT) - -TEST_SRCS = tst-mul.c tst-dm.c tst-dm_ui.c tst-mdm.c tst-mdm_ui.c tst-gcd.c \ - tst-sqrtrem.c tst-convert.c -TEST_OBJS = tst-mul.o tst-dm.o tst-dm_ui.o tst-mdm.o tst-mdm_ui.o tst-gcd.o \ - tst-sqrtrem.o tst-convert.o -TESTS = tst-mul tst-dm tst-dm_ui tst-mdm tst-mdm_ui tst-gcd \ - tst-sqrtrem tst-convert - -tests: $(TESTS) - for i in $(TESTS); do echo $$i; ./$$i; done - -tst-mul: tst-mul.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) -tst-dm: tst-dm.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) -tst-dm_ui: tst-dm_ui.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) -tst-mdm: tst-mdm.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) -tst-mdm_ui: tst-mdm_ui.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) -tst-gcd: tst-gcd.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) -tst-sqrtrem: tst-sqrtrem.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) -tst-convert: tst-convert.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) - -$(TEST_PREFIX)clean: - rm -f $(TESTS) $(TEST_OBJS) core - -tst-convert.o : tst-convert.c gmp.h urandom.h -tst-dm.o : tst-dm.c gmp.h urandom.h -tst-dm_ui.o : tst-dm_ui.c gmp.h urandom.h -tst-gcd.o : tst-gcd.c gmp.h urandom.h -tst-mdm.o : tst-mdm.c gmp.h urandom.h -tst-mdm_ui.o : tst-mdm_ui.c gmp.h urandom.h -tst-mul.o : tst-mul.c gmp.h gmp-impl.h gmp-mparam.h longlong.h urandom.h -tst-sqrtrem.o : tst-sqrtrem.c gmp.h urandom.h diff --git a/gnu/lib/libgmp/tests/Makefile.GNU b/gnu/lib/libgmp/tests/Makefile.GNU deleted file mode 100644 index aa18015..0000000 --- a/gnu/lib/libgmp/tests/Makefile.GNU +++ /dev/null @@ -1,64 +0,0 @@ -# Makefile for tests for GNU MP - -# Copyright (C) 1991, 1993 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 General Public License as published by -# the Free Software Foundation; either version 2, 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 General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with the GNU MP Library; see the file COPYING. If not, write to -# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - -CC = gcc - -TEST_LIBS = ../libgmp.a -OPT = -O -g -CFLAGS = -I. -I.. $(OPT) - -TEST_SRCS = tst-mul.c tst-dm.c tst-dm_ui.c tst-mdm.c tst-mdm_ui.c tst-gcd.c \ - tst-sqrtrem.c tst-convert.c -TEST_OBJS = tst-mul.o tst-dm.o tst-dm_ui.o tst-mdm.o tst-mdm_ui.o tst-gcd.o \ - tst-sqrtrem.o tst-convert.o -TESTS = tst-mul tst-dm tst-dm_ui tst-mdm tst-mdm_ui tst-gcd \ - tst-sqrtrem tst-convert - -tests: $(TESTS) - for i in $(TESTS); do echo $$i; ./$$i; done - -tst-mul: tst-mul.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) -tst-dm: tst-dm.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) -tst-dm_ui: tst-dm_ui.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) -tst-mdm: tst-mdm.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) -tst-mdm_ui: tst-mdm_ui.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) -tst-gcd: tst-gcd.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) -tst-sqrtrem: tst-sqrtrem.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) -tst-convert: tst-convert.o $(TEST_LIBS) - $(CC) $(CFLAGS) -o $@ $@.o $(TEST_LIBS) - -$(TEST_PREFIX)clean: - rm -f $(TESTS) $(TEST_OBJS) core - -tst-convert.o : tst-convert.c ../gmp.h urandom.h -tst-dm.o : tst-dm.c ../gmp.h urandom.h -tst-dm_ui.o : tst-dm_ui.c ../gmp.h urandom.h -tst-gcd.o : tst-gcd.c ../gmp.h urandom.h -tst-mdm.o : tst-mdm.c ../gmp.h urandom.h -tst-mdm_ui.o : tst-mdm_ui.c ../gmp.h urandom.h -tst-mul.o : tst-mul.c ../gmp.h ../gmp-impl.h ../gmp-mparam.h ../longlong.h urandom.h -tst-sqrtrem.o : tst-sqrtrem.c ../gmp.h urandom.h diff --git a/gnu/lib/libgmp/tests/tst-convert.c b/gnu/lib/libgmp/tests/tst-convert.c deleted file mode 100644 index bbc0dab..0000000 --- a/gnu/lib/libgmp/tests/tst-convert.c +++ /dev/null @@ -1,80 +0,0 @@ -/* Test mpz_add, mpz_cmp, mpz_cmp_ui, mpz_gcd, mpz_gcdext, mpz_get_str, - mpz_mod, mpz_mul, mpz_set_str. - -Copyright (C) 1993 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 General Public License as published by -the Free Software Foundation; either version 2, 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with the GNU MP Library; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 8 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - MP_INT op1, op2; - mp_size size; - int i; - int reps = 100000; - char *str; - int base; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (&op1); - mpz_init (&op2); - - for (i = 0; i < reps; i++) - { - size = urandom () % SIZE - SIZE/2; - - mpz_random2 (&op1, size); - base = urandom () % 36 + 1; - if (base == 1) - base = 0; - - str = mpz_get_str ((char *) 0, base, &op1); - mpz_set_str (&op2, str, base); - free (str); - - if (mpz_cmp (&op1, &op2)) - { - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "op1 = "); debug_mp (&op1, -16); - fprintf (stderr, "base = %d\n", base); - abort (); - } - } - - exit (0); -} - -void -debug_mp (x, base) - MP_INT *x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/tests/tst-dm.c b/gnu/lib/libgmp/tests/tst-dm.c deleted file mode 100644 index 92c4194..0000000 --- a/gnu/lib/libgmp/tests/tst-dm.c +++ /dev/null @@ -1,117 +0,0 @@ -/* Test mpz_abs, mpz_add, mpz_cmp, mpz_cmp_ui, mpz_div, mpz_divmod, mpz_mod, - mpz_mul. - -Copyright (C) 1991, 1993 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 General Public License as published by -the Free Software Foundation; either version 2, 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with the GNU MP Library; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 8 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - MP_INT dividend, divisor; - MP_INT quotient, remainder; - MP_INT quotient2, remainder2; - MP_INT temp; - mp_size dividend_size, divisor_size; - int i; - int reps = 100000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (÷nd); - mpz_init (&divisor); - mpz_init ("ient); - mpz_init (&remainder); - mpz_init ("ient2); - mpz_init (&remainder2); - mpz_init (&temp); - - for (i = 0; i < reps; i++) - { - dividend_size = urandom () % SIZE - SIZE/2; - mpz_random2 (÷nd, dividend_size); - - divisor_size = urandom () % SIZE - SIZE/2; - mpz_random2 (&divisor, divisor_size); - if (mpz_cmp_ui (&divisor, 0) == 0) - continue; - - mpz_divmod ("ient, &remainder, ÷nd, &divisor); - mpz_div ("ient2, ÷nd, &divisor); - mpz_mod (&remainder2, ÷nd, &divisor); - - /* First determine that the quotients and remainders computed - with different functions are equal. */ - if (mpz_cmp ("ient, "ient2) != 0) - dump_abort (÷nd, &divisor); - if (mpz_cmp (&remainder, &remainder2) != 0) - dump_abort (÷nd, &divisor); - - /* Check if the sign of the quotient is correct. */ - if (mpz_cmp_ui ("ient, 0) != 0) - if ((mpz_cmp_ui ("ient, 0) < 0) - != ((mpz_cmp_ui (÷nd, 0) ^ mpz_cmp_ui (&divisor, 0)) < 0)) - dump_abort (÷nd, &divisor); - - /* Check if the remainder has the same sign as the dividend - (quotient rounded towards 0). */ - if (mpz_cmp_ui (&remainder, 0) != 0) - if ((mpz_cmp_ui (&remainder, 0) < 0) != (mpz_cmp_ui (÷nd, 0) < 0)) - dump_abort (÷nd, &divisor); - - mpz_mul (&temp, "ient, &divisor); - mpz_add (&temp, &temp, &remainder); - if (mpz_cmp (&temp, ÷nd) != 0) - dump_abort (÷nd, &divisor); - - mpz_abs (&temp, &divisor); - mpz_abs (&remainder, &remainder); - if (mpz_cmp (&remainder, &temp) >= 0) - dump_abort (÷nd, &divisor); - } - - exit (0); -} - -dump_abort (dividend, divisor) - MP_INT *dividend, *divisor; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = "); debug_mp (divisor, -16); - abort(); -} - -void -debug_mp (x, base) - MP_INT *x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/tests/tst-dm_ui.c b/gnu/lib/libgmp/tests/tst-dm_ui.c deleted file mode 100644 index 9f69841..0000000 --- a/gnu/lib/libgmp/tests/tst-dm_ui.c +++ /dev/null @@ -1,116 +0,0 @@ -/* Test mpz_abs, mpz_add, mpz_cmp, mpz_cmp_ui, mpz_div, mpz_div_ui, - mpz_divmod, mpz_divmod_ui, mpz_mod, mpz_mod_ui, mpz_mul, mpz_mul_ui. - -Copyright (C) 1993 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 General Public License as published by -the Free Software Foundation; either version 2, 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with the GNU MP Library; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 8 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - MP_INT dividend; - MP_INT quotient, remainder; - MP_INT quotient2, remainder2; - MP_INT temp; - mp_size dividend_size; - mp_limb divisor; - int i; - int reps = 100000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (÷nd); - mpz_init ("ient); - mpz_init (&remainder); - mpz_init ("ient2); - mpz_init (&remainder2); - mpz_init (&temp); - - for (i = 0; i < reps; i++) - { - dividend_size = urandom () % SIZE - SIZE/2; - mpz_random2 (÷nd, dividend_size); - - divisor = urandom (); - if (divisor == 0) - continue; - - mpz_divmod_ui ("ient, &remainder, ÷nd, divisor); - mpz_div_ui ("ient2, ÷nd, divisor); - mpz_mod_ui (&remainder2, ÷nd, divisor); - - /* First determine that the quotients and remainders computed - with different functions are equal. */ - if (mpz_cmp ("ient, "ient2) != 0) - dump_abort (÷nd, divisor); - if (mpz_cmp (&remainder, &remainder2) != 0) - dump_abort (÷nd, divisor); - - /* Check if the sign of the quotient is correct. */ - if (mpz_cmp_ui ("ient, 0) != 0) - if ((mpz_cmp_ui ("ient, 0) < 0) - != (mpz_cmp_ui (÷nd, 0) < 0)) - dump_abort (÷nd, divisor); - - /* Check if the remainder has the same sign as the dividend - (quotient rounded towards 0). */ - if (mpz_cmp_ui (&remainder, 0) != 0) - if ((mpz_cmp_ui (&remainder, 0) < 0) != (mpz_cmp_ui (÷nd, 0) < 0)) - dump_abort (÷nd, divisor); - - mpz_mul_ui (&temp, "ient, divisor); - mpz_add (&temp, &temp, &remainder); - if (mpz_cmp (&temp, ÷nd) != 0) - dump_abort (÷nd, divisor); - - mpz_abs (&remainder, &remainder); - if (mpz_cmp_ui (&remainder, divisor) >= 0) - dump_abort (÷nd, divisor); - } - - exit (0); -} - -dump_abort (dividend, divisor) - MP_INT *dividend; - mp_limb divisor; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = %lX\n", divisor); - abort(); -} - -void -debug_mp (x, base) - MP_INT *x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/tests/tst-gcd.c b/gnu/lib/libgmp/tests/tst-gcd.c deleted file mode 100644 index 166aa56..0000000 --- a/gnu/lib/libgmp/tests/tst-gcd.c +++ /dev/null @@ -1,131 +0,0 @@ -/* Test mpz_gcd, mpz_gcdext, mpz_mul, mpz_mod, mpz_add, mpz_cmp, - mpz_cmp_ui. mpz_init_set, mpz_set, mpz_clear. - -Copyright (C) 1991, 1993 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 General Public License as published by -the Free Software Foundation; either version 2, 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with the GNU MP Library; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void mpz_refgcd (), debug_mp (); - -#ifndef SIZE -#define SIZE 8 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - MP_INT op1, op2; - MP_INT refgcd, gcd, s, t; - MP_INT temp1, temp2; - mp_size op1_size, op2_size; - int i; - int reps = 10000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (&op1); - mpz_init (&op2); - mpz_init (&refgcd); - mpz_init (&gcd); - mpz_init (&temp1); - mpz_init (&temp2); - mpz_init (&s); - mpz_init (&t); - - for (i = 0; i < reps; i++) - { - op1_size = urandom () % SIZE; - op2_size = urandom () % SIZE; - - mpz_random2 (&op1, op1_size); - mpz_random2 (&op2, op2_size); - - mpz_refgcd (&refgcd, &op1, &op2); - - mpz_gcd (&gcd, &op1, &op2); - if (mpz_cmp (&refgcd, &gcd)) - dump_abort (&op1, &op2); - - mpz_gcdext (&gcd, &s, &t, &op1, &op2); - if (mpz_cmp (&refgcd, &gcd)) - dump_abort (&op1, &op2); - - mpz_mul (&temp1, &s, &op1); - mpz_mul (&temp2, &t, &op2); - mpz_add (&gcd, &temp1, &temp2); - if (mpz_cmp (&refgcd, &gcd)) - dump_abort (&op1, &op2); - } - - exit (0); -} - -void -mpz_refgcd (g, x, y) - MP_INT *g; - MP_INT *x, *y; -{ - MP_INT xx, yy; - - mpz_init (&xx); - mpz_init (&yy); - - mpz_abs (&xx, x); - mpz_abs (&yy, y); - - for (;;) - { - if (mpz_cmp_ui (&yy, 0) == 0) - { - mpz_set (g, &xx); - break; - } - mpz_mod (&xx, &xx, &yy); - if (mpz_cmp_ui (&xx, 0) == 0) - { - mpz_set (g, &yy); - break; - } - mpz_mod (&yy, &yy, &xx); - } - - mpz_clear (&xx); - mpz_clear (&yy); -} - -dump_abort (op1, op2) - MP_INT *op1, *op2; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "op1 = "); debug_mp (op1, -16); - fprintf (stderr, "op2 = "); debug_mp (op2, -16); - abort(); -} - -void -debug_mp (x, base) - MP_INT *x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/tests/tst-mdm.c b/gnu/lib/libgmp/tests/tst-mdm.c deleted file mode 100644 index a515ddf..0000000 --- a/gnu/lib/libgmp/tests/tst-mdm.c +++ /dev/null @@ -1,117 +0,0 @@ -/* Test mpz_abs, mpz_add, mpz_cmp, mpz_cmp_ui, mpz_divmod, mpz_mdiv, - mpz_mdivmod, mpz_mmod, mpz_mul. - -Copyright (C) 1993 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 General Public License as published by -the Free Software Foundation; either version 2, 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with the GNU MP Library; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 8 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - MP_INT dividend, divisor; - MP_INT quotient, remainder; - MP_INT quotient2, remainder2; - MP_INT temp; - mp_size dividend_size, divisor_size; - int i; - int reps = 100000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (÷nd); - mpz_init (&divisor); - mpz_init ("ient); - mpz_init (&remainder); - mpz_init ("ient2); - mpz_init (&remainder2); - mpz_init (&temp); - - for (i = 0; i < reps; i++) - { - dividend_size = urandom () % SIZE - SIZE/2; - mpz_random2 (÷nd, dividend_size); - - divisor_size = urandom () % SIZE - SIZE/2; - mpz_random2 (&divisor, divisor_size); - if (mpz_cmp_ui (&divisor, 0) == 0) - continue; - - mpz_mdivmod ("ient, &remainder, ÷nd, &divisor); - mpz_mdiv ("ient2, ÷nd, &divisor); - mpz_mmod (&remainder2, ÷nd, &divisor); - - /* First determine that the quotients and remainders computed - with different functions are equal. */ - if (mpz_cmp ("ient, "ient2) != 0) - dump_abort (÷nd, &divisor); - if (mpz_cmp (&remainder, &remainder2) != 0) - dump_abort (÷nd, &divisor); - - /* Check if the sign of the quotient is correct. */ - if (mpz_cmp_ui ("ient, 0) != 0) - if ((mpz_cmp_ui ("ient, 0) < 0) - != ((mpz_cmp_ui (÷nd, 0) ^ mpz_cmp_ui (&divisor, 0)) < 0)) - dump_abort (÷nd, &divisor); - - /* Check if the remainder has the same sign as the divisor - (quotient rounded towards minus infinity). */ - if (mpz_cmp_ui (&remainder, 0) != 0) - if ((mpz_cmp_ui (&remainder, 0) < 0) != (mpz_cmp_ui (&divisor, 0) < 0)) - dump_abort (÷nd, &divisor); - - mpz_mul (&temp, "ient, &divisor); - mpz_add (&temp, &temp, &remainder); - if (mpz_cmp (&temp, ÷nd) != 0) - dump_abort (÷nd, &divisor); - - mpz_abs (&temp, &divisor); - mpz_abs (&remainder, &remainder); - if (mpz_cmp (&remainder, &temp) >= 0) - dump_abort (÷nd, &divisor); - } - - exit (0); -} - -dump_abort (dividend, divisor) - MP_INT *dividend, *divisor; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = "); debug_mp (divisor, -16); - abort(); -} - -void -debug_mp (x, base) - MP_INT *x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/tests/tst-mdm_ui.c b/gnu/lib/libgmp/tests/tst-mdm_ui.c deleted file mode 100644 index 26befbe..0000000 --- a/gnu/lib/libgmp/tests/tst-mdm_ui.c +++ /dev/null @@ -1,116 +0,0 @@ -/* Test mpz_abs, mpz_add, mpz_cmp. mpz_cmp_si, mpz_cmp_ui, mpz_divmod, - mpz_mdiv_ui, mpz_mdivmod_ui, mpz_mmod_ui, mpz_mul, mpz_mul_ui. - -Copyright (C) 1993 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 General Public License as published by -the Free Software Foundation; either version 2, 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with the GNU MP Library; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 8 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - MP_INT dividend; - MP_INT quotient, remainder; - MP_INT quotient2, remainder2; - MP_INT temp; - mp_size dividend_size; - mp_limb divisor; - int i; - int reps = 100000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (÷nd); - mpz_init ("ient); - mpz_init (&remainder); - mpz_init ("ient2); - mpz_init (&remainder2); - mpz_init (&temp); - - for (i = 0; i < reps; i++) - { - dividend_size = urandom () % SIZE - SIZE/2; - mpz_random2 (÷nd, dividend_size); - - divisor = urandom (); - if (divisor == 0) - continue; - - mpz_mdivmod_ui ("ient, &remainder, ÷nd, divisor); - mpz_mdiv_ui ("ient2, ÷nd, divisor); - mpz_mmod_ui (&remainder2, ÷nd, divisor); - - /* First determine that the quotients and remainders computed - with different functions are equal. */ - if (mpz_cmp ("ient, "ient2) != 0) - dump_abort (÷nd, divisor); - if (mpz_cmp (&remainder, &remainder2) != 0) - dump_abort (÷nd, divisor); - - /* Check if the sign of the quotient is correct. */ - if (mpz_cmp_ui ("ient, 0) != 0) - if ((mpz_cmp_ui ("ient, 0) < 0) - != (mpz_cmp_ui (÷nd, 0) < 0)) - dump_abort (÷nd, divisor); - - /* Check if the remainder has the same sign as the divisor - (quotient rounded towards minus infinity). */ - if (mpz_cmp_ui (&remainder, 0) != 0) - if (mpz_cmp_ui (&remainder, 0) < 0) - dump_abort (÷nd, divisor); - - mpz_mul_ui (&temp, "ient, divisor); - mpz_add (&temp, &temp, &remainder); - if (mpz_cmp (&temp, ÷nd) != 0) - dump_abort (÷nd, divisor); - - mpz_abs (&remainder, &remainder); - if (mpz_cmp_ui (&remainder, divisor) >= 0) - dump_abort (÷nd, divisor); - } - - exit (0); -} - -dump_abort (dividend, divisor) - MP_INT *dividend; - mp_limb divisor; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = %lX\n", divisor); - abort(); -} - -void -debug_mp (x, base) - MP_INT *x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/tests/tst-mul.c b/gnu/lib/libgmp/tests/tst-mul.c deleted file mode 100644 index 0eab422..0000000 --- a/gnu/lib/libgmp/tests/tst-mul.c +++ /dev/null @@ -1,261 +0,0 @@ -/* Test mpz_add, mpz_cmp, mpz_cmp_ui, mpz_divmod, mpz_mul. - -Copyright (C) 1991, 1993 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 General Public License as published by -the Free Software Foundation; either version 2, 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with the GNU MP Library; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" -#include "urandom.h" - -void debug_mp (); -mp_size _mpn_mul_classic (); -void mpz_refmul (); - -#ifndef SIZE -#define SIZE 8 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - MP_INT multiplier, multiplicand; - MP_INT product, ref_product; - MP_INT quotient, remainder; - mp_size multiplier_size, multiplicand_size; - int i; - int reps = 100000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (&multiplier); - mpz_init (&multiplicand); - mpz_init (&product); - mpz_init (&ref_product); - mpz_init ("ient); - mpz_init (&remainder); - - for (i = 0; i < reps; i++) - { - multiplier_size = urandom () % SIZE - SIZE/2; - multiplicand_size = urandom () % SIZE - SIZE/2; - - mpz_random2 (&multiplier, multiplier_size); - mpz_random2 (&multiplicand, multiplicand_size); - - mpz_mul (&product, &multiplier, &multiplicand); - mpz_refmul (&ref_product, &multiplier, &multiplicand); - if (mpz_cmp_ui (&multiplicand, 0) != 0) - mpz_divmod ("ient, &remainder, &product, &multiplicand); - - if (mpz_cmp (&product, &ref_product)) - dump_abort (&multiplier, &multiplicand); - - if (mpz_cmp_ui (&multiplicand, 0) != 0) - if (mpz_cmp_ui (&remainder, 0) || mpz_cmp ("ient, &multiplier)) - dump_abort (&multiplier, &multiplicand); - } - - exit (0); -} - -void -mpz_refmul (w, u, v) - MP_INT *w; - const MP_INT *u; - const MP_INT *v; -{ - mp_size usize = u->size; - mp_size vsize = v->size; - mp_size wsize; - mp_size sign_product; - mp_ptr up, vp; - mp_ptr wp; - mp_ptr free_me = NULL; - size_t free_me_size; - - sign_product = usize ^ vsize; - usize = ABS (usize); - vsize = ABS (vsize); - - if (usize < vsize) - { - /* Swap U and V. */ - {const MP_INT *t = u; u = v; v = t;} - {mp_size t = usize; usize = vsize; vsize = t;} - } - - up = u->d; - vp = v->d; - wp = w->d; - - /* Ensure W has space enough to store the result. */ - wsize = usize + vsize; - if (w->alloc < wsize) - { - if (wp == up || wp == vp) - { - free_me = wp; - free_me_size = w->alloc; - } - else - (*_mp_free_func) (wp, w->alloc * BYTES_PER_MP_LIMB); - - w->alloc = wsize; - wp = (mp_ptr) (*_mp_allocate_func) (wsize * BYTES_PER_MP_LIMB); - w->d = wp; - } - else - { - /* Make U and V not overlap with W. */ - if (wp == up) - { - /* W and U are identical. Allocate temporary space for U. */ - up = (mp_ptr) alloca (usize * BYTES_PER_MP_LIMB); - /* Is V identical too? Keep it identical with U. */ - if (wp == vp) - vp = up; - /* Copy to the temporary space. */ - MPN_COPY (up, wp, usize); - } - else if (wp == vp) - { - /* W and V are identical. Allocate temporary space for V. */ - vp = (mp_ptr) alloca (vsize * BYTES_PER_MP_LIMB); - /* Copy to the temporary space. */ - MPN_COPY (vp, wp, vsize); - } - } - - wsize = _mpn_mul_classic (wp, up, usize, vp, vsize); - w->size = sign_product < 0 ? -wsize : wsize; - if (free_me != NULL) - (*_mp_free_func) (free_me, free_me_size * BYTES_PER_MP_LIMB); - - alloca (0); -} - -mp_size -_mpn_mul_classic (prodp, up, usize, vp, vsize) - mp_ptr prodp; - mp_srcptr up; - mp_size usize; - mp_srcptr vp; - mp_size vsize; -{ - mp_size n; - mp_size prod_size; - mp_limb cy; - mp_size i, j; - mp_limb prod_low, prod_high; - mp_limb cy_dig; - mp_limb v_limb, c; - - if (vsize == 0) - return 0; - - /* Offset UP and PRODP so that the inner loop can be faster. */ - up += usize; - prodp += usize; - - /* Multiply by the first limb in V separately, as the result can - be stored (not added) to PROD. We also avoid a loop for zeroing. */ - v_limb = vp[0]; - cy_dig = 0; - j = -usize; - do - { - umul_ppmm (prod_high, prod_low, up[j], v_limb); - add_ssaaaa (cy_dig, prodp[j], prod_high, prod_low, 0, cy_dig); - j++; - } - while (j < 0); - - prodp[j] = cy_dig; - prodp++; - - /* For each iteration in the outer loop, multiply one limb from - U with one limb from V, and add it to PROD. */ - for (i = 1; i < vsize; i++) - { - v_limb = vp[i]; - cy_dig = 0; - j = -usize; - - /* Inner loops. Simulate the carry flag by jumping between - these loops. The first is used when there was no carry - in the previois iteration; the second when there was carry. */ - - do - { - umul_ppmm (prod_high, prod_low, up[j], v_limb); - add_ssaaaa (cy_dig, prod_low, prod_high, prod_low, 0, cy_dig); - c = prodp[j]; - prod_low += c; - prodp[j] = prod_low; - if (prod_low < c) - goto cy_loop; - ncy_loop: - j++; - } - while (j < 0); - - prodp[j] = cy_dig; - prodp++; - continue; - - do - { - umul_ppmm (prod_high, prod_low, up[j], v_limb); - add_ssaaaa (cy_dig, prod_low, prod_high, prod_low, 0, cy_dig); - c = prodp[j]; - prod_low += c + 1; - prodp[j] = prod_low; - if (prod_low > c) - goto ncy_loop; - cy_loop: - j++; - } - while (j < 0); - - cy_dig += 1; - prodp[j] = cy_dig; - prodp++; - } - - return usize + vsize - (cy_dig == 0); -} - -dump_abort (multiplier, multiplicand) - MP_INT *multiplier, *multiplicand; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "multiplier = "); debug_mp (multiplier, -16); - fprintf (stderr, "multiplicand = "); debug_mp (multiplicand, -16); - abort(); -} - -void -debug_mp (x, base) - MP_INT *x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/tests/tst-pow_ui.c b/gnu/lib/libgmp/tests/tst-pow_ui.c deleted file mode 100644 index c7d929a..0000000 --- a/gnu/lib/libgmp/tests/tst-pow_ui.c +++ /dev/null @@ -1,120 +0,0 @@ -/* Test mpz_abs, mpz_add, mpz_cmp, mpz_cmp_ui, mpz_div, mpz_divmod, mpz_mod, - mpz_mul. - -Copyright (C) 1991, 1993 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 General Public License as published by -the Free Software Foundation; either version 2, 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with the GNU MP Library; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 8 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - MP_INT dividend, divisor; - MP_INT quotient, remainder; - MP_INT quotient2, remainder2; - MP_INT temp; - mp_size dividend_size, divisor_size; - int i; - int reps = 100000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (÷nd); - mpz_init (&divisor); - mpz_init ("ient); - mpz_init (&remainder); - mpz_init ("ient2); - mpz_init (&remainder2); - mpz_init (&temp); - - for (i = 0; i < reps; i++) - { - base_size = urandom () % SIZE - SIZE/2; - mpz_random2 (&base, base_size); - - divisor_size = urandom () % SIZE - SIZE/2; - mpz_random2 (&divisor, divisor_size); - if (mpz_cmp_ui (&divisor, 0) == 0) - continue; - - exp_size = urandom () % SIZE/2; - mpz_random2 (&exp, exp_size); - - mpz_powm (&result1, &base, &exp, &divisor); - mpz_div ("ient2, ÷nd, &divisor); - mpz_mod (&remainder2, ÷nd, &divisor); - - /* First determine that the quotients and remainders computed - with different functions are equal. */ - if (mpz_cmp ("ient, "ient2) != 0) - dump_abort (÷nd, &divisor); - if (mpz_cmp (&remainder, &remainder2) != 0) - dump_abort (÷nd, &divisor); - - /* Check if the sign of the quotient is correct. */ - if (mpz_cmp_ui ("ient, 0) != 0) - if ((mpz_cmp_ui ("ient, 0) < 0) - != ((mpz_cmp_ui (÷nd, 0) ^ mpz_cmp_ui (&divisor, 0)) < 0)) - dump_abort (÷nd, &divisor); - - /* Check if the remainder has the same sign as the dividend - (quotient rounded towards 0). */ - if (mpz_cmp_ui (&remainder, 0) != 0) - if ((mpz_cmp_ui (&remainder, 0) < 0) != (mpz_cmp_ui (÷nd, 0) < 0)) - dump_abort (÷nd, &divisor); - - mpz_mul (&temp, "ient, &divisor); - mpz_add (&temp, &temp, &remainder); - if (mpz_cmp (&temp, ÷nd) != 0) - dump_abort (÷nd, &divisor); - - mpz_abs (&temp, &divisor); - mpz_abs (&remainder, &remainder); - if (mpz_cmp (&remainder, &temp) >= 0) - dump_abort (÷nd, &divisor); - } - - exit (0); -} - -dump_abort (dividend, divisor) - MP_INT *dividend, *divisor; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "dividend = "); debug_mp (dividend, -16); - fprintf (stderr, "divisor = "); debug_mp (divisor, -16); - abort(); -} - -void -debug_mp (x, base) - MP_INT *x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/tests/tst-sqrtrem.c b/gnu/lib/libgmp/tests/tst-sqrtrem.c deleted file mode 100644 index b62350a..0000000 --- a/gnu/lib/libgmp/tests/tst-sqrtrem.c +++ /dev/null @@ -1,97 +0,0 @@ -/* Test mpz_add, mpz_add_ui, mpz_cmp, mpz_cmp, mpz_mul, mpz_sqrtrem. - -Copyright (C) 1991, 1993 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 General Public License as published by -the Free Software Foundation; either version 2, 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 General Public License for more details. - -You should have received a copy of the GNU General Public License -along with the GNU MP Library; see the file COPYING. If not, write to -the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ - -#include -#include "gmp.h" -#include "gmp-impl.h" -#include "urandom.h" - -void debug_mp (); - -#ifndef SIZE -#define SIZE 8 -#endif - -main (argc, argv) - int argc; - char **argv; -{ - MP_INT x2; - MP_INT x, rem; - MP_INT temp, temp2; - mp_size x2_size; - int i; - int reps = 100000; - - if (argc == 2) - reps = atoi (argv[1]); - - mpz_init (&x2); - mpz_init (&x); - mpz_init (&rem); - mpz_init (&temp); - mpz_init (&temp2); - - for (i = 0; i < reps; i++) - { - x2_size = urandom () % SIZE; - - mpz_random2 (&x2, x2_size); - - mpz_sqrtrem (&x, &rem, &x2); - mpz_mul (&temp, &x, &x); - - /* Is square of result > argument? */ - if (mpz_cmp (&temp, &x2) > 0) - dump_abort (&x2, &x, &rem); - - mpz_add_ui (&temp2, &x, 1); - mpz_mul (&temp2, &temp2, &temp2); - - /* Is square of (result + 1) <= argument? */ - if (mpz_cmp (&temp2, &x2) <= 0) - dump_abort (&x2, &x, &rem); - - mpz_add (&temp2, &temp, &rem); - - /* Is the remainder wrong? */ - if (mpz_cmp (&x2, &temp2) != 0) - dump_abort (&x2, &x, &rem); - } - - exit (0); -} - -dump_abort (x2, x, rem) - MP_INT *x2, *x, *rem; -{ - fprintf (stderr, "ERROR\n"); - fprintf (stderr, "x2 = "); debug_mp (x2, -16); - fprintf (stderr, "x = "); debug_mp (x, -16); - fprintf (stderr, "remainder = "); debug_mp (rem, -16); - abort(); -} - -void -debug_mp (x, base) - MP_INT *x; -{ - mpz_out_str (stderr, base, x); fputc ('\n', stderr); -} diff --git a/gnu/lib/libgmp/tests/urandom.h b/gnu/lib/libgmp/tests/urandom.h deleted file mode 100644 index e018580..0000000 --- a/gnu/lib/libgmp/tests/urandom.h +++ /dev/null @@ -1,17 +0,0 @@ -#if defined (hpux) || defined (__alpha__) -/* HPUX lacks random(). DEC Alpha's random() returns a double. */ -static inline unsigned long -urandom () -{ - return mrand48 (); -} -#else -long random (); - -static inline unsigned long -urandom () -{ - /* random() returns 31 bits, we want 32. */ - return random() ^ (random() << 1); -} -#endif -- cgit v1.1