├── AUTHORS ├── ChangeLog ├── gmp-impl.h ├── doc ├── tasks.html ├── projects.html ├── stamp-vti ├── version.texi └── Makefile.am ├── mpz ├── divexact.c ├── nextprime.c ├── add.c ├── sub.c ├── add_ui.c ├── sub_ui.c ├── fits_uint.c ├── fits_ulong.c ├── fits_ushort.c ├── getlimbn.c ├── mul_si.c ├── mul_ui.c ├── set_q.c ├── get_ui.c ├── size.c ├── fits_sint.c ├── fits_slong.c ├── fits_sshort.c ├── perfsqr.c ├── popcount.c ├── clear.c ├── perfpow.c ├── random.c ├── get_d.c ├── iset_d.c ├── divis.c ├── sizeinbase.c ├── init.c ├── fib2_ui.c └── abs.c ├── mpn ├── generic │ ├── gcd.c │ ├── gcdext_1.c │ ├── dcpi1_bdiv_q.c │ ├── matrix22_mul.c │ ├── mulmod_bnm1.c │ ├── sbpi1_bdiv_q.c │ ├── sbpi1_div_q.c │ ├── sbpi1_div_qr.c │ ├── sqrmod_bnm1.c │ ├── toom32_mul.c │ ├── dcpi1_bdiv_qr.c │ ├── sbpi1_bdiv_qr.c │ ├── toom_eval_pm1.c │ ├── toom_eval_pm2.c │ ├── sbpi1_divappr_q.c │ ├── toom_eval_pm2exp.c │ ├── toom_eval_dgr3_pm1.c │ ├── toom_eval_dgr3_pm2.c │ ├── toom_interpolate_7pts.c │ ├── add.c │ ├── add_1.c │ ├── neg.c │ ├── sub.c │ ├── sub_1.c │ ├── cmp.c │ ├── gmp-mparam.h │ ├── zero.c │ ├── copyd.c │ ├── copyi.c │ ├── com.c │ └── random.c ├── x86 │ ├── invert_limb.asm │ ├── fat │ │ ├── gcd_1.c │ │ ├── mod_1.c │ │ ├── mode1o.c │ │ └── diveby3.c │ ├── p6 │ │ ├── sse2 │ │ │ ├── submul_1.asm │ │ │ ├── mod_1_4.asm │ │ │ ├── mul_basecase.asm │ │ │ ├── sqr_basecase.asm │ │ │ ├── popcount.asm │ │ │ ├── addmul_1.asm │ │ │ └── mul_1.asm │ │ ├── mmx │ │ │ ├── lshift.asm │ │ │ ├── rshift.asm │ │ │ └── popham.asm │ │ └── p3mmx │ │ │ └── popham.asm │ ├── pentium4 │ │ └── mmx │ │ │ ├── lshift.asm │ │ │ └── rshift.asm │ ├── gmp-mparam.h │ ├── pentium │ │ └── mmx │ │ │ └── hamdist.asm │ └── umul.asm ├── x86_64 │ ├── invert_limb.asm │ ├── fat │ │ ├── gcd_1.c │ │ ├── mod_1.c │ │ ├── mode1o.c │ │ └── diveby3.c │ ├── core2 │ │ └── popcount.asm │ ├── pentium4 │ │ └── popcount.asm │ └── darwin.m4 ├── i960 │ └── README ├── sparc32 │ ├── v9 │ │ └── README │ └── v8 │ │ └── umul.asm ├── z8000 │ └── gmp-mparam.h ├── a29k │ ├── umul.s │ └── udiv.s ├── power │ ├── sdiv.asm │ └── umul.asm ├── s390 │ └── README ├── cray │ ├── popcount.c │ ├── hamdist.c │ └── cfp │ │ ├── mul_1.c │ │ ├── addmul_1.c │ │ └── submul_1.c ├── powerpc32 │ ├── vmx │ │ └── popcount.asm │ └── umul.asm ├── mips64 │ └── umul.asm ├── mips32 │ └── umul.asm ├── alpha │ └── umul.asm ├── m68k │ └── mc68020 │ │ ├── umul.asm │ │ └── udiv.asm ├── pyr │ ├── mul_1.s │ └── addmul_1.s ├── pa32 │ └── hppa1_1 │ │ └── umul.asm ├── powerpc64 │ └── umul.asm └── arm │ └── README ├── emscripten.sh ├── libmp.sym ├── tests ├── mpn │ ├── t-toom32.c │ ├── t-toom43.c │ ├── t-toom42.c │ ├── t-toom52.c │ ├── t-toom53.c │ ├── t-toom62.c │ ├── t-toom63.c │ ├── t-toom22.c │ ├── t-toom6h.c │ ├── t-toom33.c │ ├── t-toom44.c │ └── t-toom8h.c ├── cxx │ └── t-headers.cc ├── devel │ └── README └── rand │ └── zdiv_round.c ├── demos ├── calc │ ├── calc-config-h.in │ └── calc-common.h ├── perl │ └── GMP │ │ └── Rand.pm └── expr │ └── exprv.c ├── mp_bpl.c ├── cxx ├── dummy.cc ├── Makefile.am ├── osmpq.cc └── osmpz.cc ├── mpf ├── fits_uint.c ├── fits_ulong.c ├── fits_ushort.c ├── fits_sint.c ├── fits_slong.c ├── fits_sshort.c ├── get_prc.c ├── get_dfl_prec.c ├── size.c ├── clear.c ├── set_dfl_prec.c ├── set_prc_raw.c ├── init.c ├── iset_d.c ├── init2.c ├── sub_ui.c ├── get_d.c ├── iset_str.c ├── set_ui.c └── pow_ui.c ├── version.c ├── README.markdown ├── tune ├── powm_mod.c ├── jacbase1.c ├── jacbase2.c ├── jacbase3.c ├── pre_divrem_1.c ├── gcdext_double.c ├── gcdext_single.c ├── gcdextod.c ├── gcdextos.c ├── divrem2inv.c ├── divrem2div.c ├── powm_redc.c ├── divrem1inv.c ├── hppa.asm ├── divrem1div.c ├── powerpc64.asm ├── ia64.asm ├── powerpc.asm ├── sparcv9.asm ├── hppa2.asm ├── hppa2w.asm ├── set_strp.c ├── mod_1_inv.c └── set_strs.c ├── randdef.c ├── randclr.c ├── mpbsd ├── mfree.c └── rpow.c ├── randiset.c ├── randsd.c ├── scanf ├── Makefile.am ├── vscanf.c └── vfscanf.c ├── mpq ├── clear.c ├── get_den.c ├── get_num.c ├── set_num.c ├── set_den.c └── Makefile.am ├── printf ├── vprintf.c ├── vfprintf.c └── Makefile.am ├── randsdui.c ├── rands.c └── mp_get_fns.c /AUTHORS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/AUTHORS -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/ChangeLog -------------------------------------------------------------------------------- /gmp-impl.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/gmp-impl.h -------------------------------------------------------------------------------- /doc/tasks.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/doc/tasks.html -------------------------------------------------------------------------------- /mpz/divexact.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpz/divexact.c -------------------------------------------------------------------------------- /mpz/nextprime.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpz/nextprime.c -------------------------------------------------------------------------------- /doc/projects.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/doc/projects.html -------------------------------------------------------------------------------- /mpn/generic/gcd.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/gcd.c -------------------------------------------------------------------------------- /mpn/generic/gcdext_1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/gcdext_1.c -------------------------------------------------------------------------------- /mpn/x86/invert_limb.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/x86/invert_limb.asm -------------------------------------------------------------------------------- /mpn/generic/dcpi1_bdiv_q.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/dcpi1_bdiv_q.c -------------------------------------------------------------------------------- /mpn/generic/matrix22_mul.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/matrix22_mul.c -------------------------------------------------------------------------------- /mpn/generic/mulmod_bnm1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/mulmod_bnm1.c -------------------------------------------------------------------------------- /mpn/generic/sbpi1_bdiv_q.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/sbpi1_bdiv_q.c -------------------------------------------------------------------------------- /mpn/generic/sbpi1_div_q.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/sbpi1_div_q.c -------------------------------------------------------------------------------- /mpn/generic/sbpi1_div_qr.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/sbpi1_div_qr.c -------------------------------------------------------------------------------- /mpn/generic/sqrmod_bnm1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/sqrmod_bnm1.c -------------------------------------------------------------------------------- /mpn/generic/toom32_mul.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/toom32_mul.c -------------------------------------------------------------------------------- /mpn/x86_64/invert_limb.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/x86_64/invert_limb.asm -------------------------------------------------------------------------------- /mpn/generic/dcpi1_bdiv_qr.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/dcpi1_bdiv_qr.c -------------------------------------------------------------------------------- /mpn/generic/sbpi1_bdiv_qr.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/sbpi1_bdiv_qr.c -------------------------------------------------------------------------------- /mpn/generic/toom_eval_pm1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/toom_eval_pm1.c -------------------------------------------------------------------------------- /mpn/generic/toom_eval_pm2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/toom_eval_pm2.c -------------------------------------------------------------------------------- /mpn/generic/sbpi1_divappr_q.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/sbpi1_divappr_q.c -------------------------------------------------------------------------------- /mpn/generic/toom_eval_pm2exp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/toom_eval_pm2exp.c -------------------------------------------------------------------------------- /mpn/generic/toom_eval_dgr3_pm1.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/toom_eval_dgr3_pm1.c -------------------------------------------------------------------------------- /mpn/generic/toom_eval_dgr3_pm2.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/toom_eval_dgr3_pm2.c -------------------------------------------------------------------------------- /doc/stamp-vti: -------------------------------------------------------------------------------- 1 | @set UPDATED 8 May 2011 2 | @set UPDATED-MONTH May 2011 3 | @set EDITION 5.0.2 4 | @set VERSION 5.0.2 5 | -------------------------------------------------------------------------------- /doc/version.texi: -------------------------------------------------------------------------------- 1 | @set UPDATED 8 May 2011 2 | @set UPDATED-MONTH May 2011 3 | @set EDITION 5.0.2 4 | @set VERSION 5.0.2 5 | -------------------------------------------------------------------------------- /mpn/generic/toom_interpolate_7pts.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ailisp/gmp.js/master/mpn/generic/toom_interpolate_7pts.c -------------------------------------------------------------------------------- /emscripten.sh: -------------------------------------------------------------------------------- 1 | echo "bitcode ==> javascript" 2 | ~/Dev/emscripten/emcc -O2 test.c .libs/libgmp.a -o complete.js -s ASM_JS=1 -g --llvm-lto 1 3 | 4 | -------------------------------------------------------------------------------- /libmp.sym: -------------------------------------------------------------------------------- 1 | itom 2 | xtom 3 | move 4 | madd 5 | msub 6 | mult 7 | mdiv 8 | sdiv 9 | msqrt 10 | pow 11 | rpow 12 | gcd 13 | mcmp 14 | min 15 | mout 16 | mtox 17 | mfree 18 | __gmp_set_memory_functions 19 | -------------------------------------------------------------------------------- /tests/mpn/t-toom32.c: -------------------------------------------------------------------------------- 1 | #define mpn_toomMN_mul mpn_toom32_mul 2 | #define mpn_toomMN_mul_itch mpn_toom32_mul_itch 3 | 4 | #define MIN_AN 6 5 | #define MIN_BN(an) (((an) + 8) / (size_t) 3) 6 | #define MAX_BN(an) ((an) - 2) 7 | 8 | #include "toom-shared.h" 9 | -------------------------------------------------------------------------------- /tests/mpn/t-toom43.c: -------------------------------------------------------------------------------- 1 | #define mpn_toomMN_mul mpn_toom43_mul 2 | #define mpn_toomMN_mul_itch mpn_toom43_mul_itch 3 | 4 | #define MIN_AN 25 5 | #define MIN_BN(an) (1 + 2*(((an)+3) >> 2)) 6 | #define MAX_BN(an) ((an)-3) 7 | 8 | #include "toom-shared.h" 9 | -------------------------------------------------------------------------------- /mpn/i960/README: -------------------------------------------------------------------------------- 1 | This directory contains mpn functions for Intel i960 processors. 2 | 3 | RELEVANT OPTIMIZATION ISSUES 4 | 5 | The code in this directory is not well optimized. 6 | 7 | STATUS 8 | 9 | The code in this directory has not been tested. 10 | -------------------------------------------------------------------------------- /tests/mpn/t-toom42.c: -------------------------------------------------------------------------------- 1 | #define mpn_toomMN_mul mpn_toom42_mul 2 | #define mpn_toomMN_mul_itch mpn_toom42_mul_itch 3 | 4 | #define MIN_AN 10 5 | #define MIN_BN(an) (((an) + 7) >> 2) 6 | #define MAX_BN(an) ((2*(an)-5) / (size_t) 3) 7 | 8 | #include "toom-shared.h" 9 | -------------------------------------------------------------------------------- /tests/mpn/t-toom52.c: -------------------------------------------------------------------------------- 1 | #define mpn_toomMN_mul mpn_toom52_mul 2 | #define mpn_toomMN_mul_itch mpn_toom52_mul_itch 3 | 4 | #define MIN_AN 32 5 | #define MIN_BN(an) (((an) + 9) / (size_t) 5) 6 | #define MAX_BN(an) (((an) - 3) >> 1) 7 | 8 | #include "toom-shared.h" 9 | -------------------------------------------------------------------------------- /tests/mpn/t-toom53.c: -------------------------------------------------------------------------------- 1 | #define mpn_toomMN_mul mpn_toom53_mul 2 | #define mpn_toomMN_mul_itch mpn_toom53_mul_itch 3 | 4 | #define MIN_AN 17 5 | #define MIN_BN(an) (1 + 2*(((an) + 4) / (size_t) 5)) 6 | #define MAX_BN(an) ((3*(an) - 11) >> 2) 7 | 8 | #include "toom-shared.h" 9 | -------------------------------------------------------------------------------- /tests/mpn/t-toom62.c: -------------------------------------------------------------------------------- 1 | #define mpn_toomMN_mul mpn_toom62_mul 2 | #define mpn_toomMN_mul_itch mpn_toom62_mul_itch 3 | 4 | #define MIN_AN 31 5 | #define MIN_BN(an) (((an) + 11) / (size_t) 6) 6 | #define MAX_BN(an) ((2*(an) - 7) / (size_t) 5) 7 | 8 | #include "toom-shared.h" 9 | -------------------------------------------------------------------------------- /mpn/sparc32/v9/README: -------------------------------------------------------------------------------- 1 | Code for SPARC processors implementing version 9 of the SPARC architecture. 2 | This code is for systems that doesn't preserve the full 64-bit contents of 3 | integer register at context switch. For other systems (such as Solaris 7 or 4 | later) use the code in ../../sparc64. 5 | -------------------------------------------------------------------------------- /tests/mpn/t-toom63.c: -------------------------------------------------------------------------------- 1 | #define mpn_toomMN_mul mpn_toom63_mul 2 | #define mpn_toomMN_mul_itch mpn_toom63_mul_itch 3 | 4 | #define MIN_AN 49 5 | #define MIN_BN(an) (2*(((an) + 23) / (size_t) 6)) /* 2/6 */ 6 | #define MAX_BN(an) ((3*(an) - 23) / (size_t) 5) /* 3/5 */ 7 | 8 | #include "toom-shared.h" 9 | -------------------------------------------------------------------------------- /tests/mpn/t-toom22.c: -------------------------------------------------------------------------------- 1 | #define mpn_toomMN_mul mpn_toom22_mul 2 | #define mpn_toomMN_mul_itch mpn_toom22_mul_itch 3 | #define MIN_AN 2 4 | 5 | #define MIN_BN(an) \ 6 | ((an) >= 2*MUL_TOOM22_THRESHOLD \ 7 | ? (an) + 2 - MUL_TOOM22_THRESHOLD \ 8 | : ((an)+1)/2 + 1) 9 | 10 | #include "toom-shared.h" 11 | -------------------------------------------------------------------------------- /tests/mpn/t-toom6h.c: -------------------------------------------------------------------------------- 1 | #define mpn_toomMN_mul mpn_toom6h_mul 2 | #define mpn_toomMN_mul_itch mpn_toom6h_mul_itch 3 | 4 | /* Smaller sizes not supported; may lead to recursive calls to 5 | toom22_mul, toom33_mul, or toom44_mul with invalid input size. */ 6 | #define MIN_AN MUL_TOOM6H_THRESHOLD 7 | #define MIN_BN(an) (MAX ((an*3)>>3, 42) ) 8 | 9 | #include "toom-shared.h" 10 | -------------------------------------------------------------------------------- /tests/mpn/t-toom33.c: -------------------------------------------------------------------------------- 1 | #define mpn_toomMN_mul mpn_toom33_mul 2 | #define mpn_toomMN_mul_itch mpn_toom33_mul_itch 3 | 4 | /* Smaller sizes not supported; may lead to recursive calls to 5 | toom22_mul with invalid input size. */ 6 | #define MIN_AN MUL_TOOM33_THRESHOLD 7 | #define MIN_BN(an) (1 + 2*(((an)+2)/(size_t) 3)) 8 | 9 | #define COUNT 1000 10 | 11 | #include "toom-shared.h" 12 | -------------------------------------------------------------------------------- /tests/mpn/t-toom44.c: -------------------------------------------------------------------------------- 1 | #define mpn_toomMN_mul mpn_toom44_mul 2 | #define mpn_toomMN_mul_itch mpn_toom44_mul_itch 3 | 4 | /* Smaller sizes not supported; may lead to recursive calls to 5 | toom22_mul or toom33_mul with invalid input size. */ 6 | #define MIN_AN MUL_TOOM44_THRESHOLD 7 | #define MIN_BN(an) (1 + 3*(((an)+3)>>2)) 8 | 9 | #define COUNT 1000 10 | 11 | #include "toom-shared.h" 12 | -------------------------------------------------------------------------------- /tests/mpn/t-toom8h.c: -------------------------------------------------------------------------------- 1 | #define mpn_toomMN_mul mpn_toom8h_mul 2 | #define mpn_toomMN_mul_itch mpn_toom8h_mul_itch 3 | 4 | /* Smaller sizes not supported; may lead to recursive calls to 5 | toom{22,33,44,6h}_mul with invalid input size. */ 6 | #define MIN_AN MUL_TOOM8H_THRESHOLD 7 | 8 | #if GMP_NUMB_BITS <= 10*3 9 | #define MIN_BN(an) (MAX ((an*6)/10, 86) ) 10 | #else 11 | #if GMP_NUMB_BITS <= 11*3 12 | #define MIN_BN(an) (MAX ((an*5)/11, 86) ) 13 | #else 14 | #if GMP_NUMB_BITS <= 12*3 15 | #define MIN_BN(an) (MAX ((an*4)/12, 86) ) 16 | #else 17 | #define MIN_BN(an) (MAX ((an*4)/13, 86) ) 18 | #endif 19 | #endif 20 | #endif 21 | 22 | #include "toom-shared.h" 23 | -------------------------------------------------------------------------------- /mpz/add.c: -------------------------------------------------------------------------------- 1 | /* mpz_add -- add integers. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #define OPERATION_add 22 | #include "aors.h" 23 | -------------------------------------------------------------------------------- /mpn/x86/fat/gcd_1.c: -------------------------------------------------------------------------------- 1 | /* Fat binary fallback mpn_gcd_1. 2 | 3 | Copyright 2003 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #include "mpn/generic/gcd_1.c" 22 | -------------------------------------------------------------------------------- /mpn/x86_64/fat/gcd_1.c: -------------------------------------------------------------------------------- 1 | /* Fat binary fallback mpn_gcd_1. 2 | 3 | Copyright 2003 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #include "mpn/generic/gcd_1.c" 22 | -------------------------------------------------------------------------------- /mpz/sub.c: -------------------------------------------------------------------------------- 1 | /* mpz_sub -- subtract integers. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #define OPERATION_sub 22 | #include "aors.h" 23 | -------------------------------------------------------------------------------- /mpn/x86/fat/mod_1.c: -------------------------------------------------------------------------------- 1 | /* Fat binary fallback mpn_mod_1. 2 | 3 | Copyright 2003, 2009 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #include "mpn/generic/mod_1.c" 22 | -------------------------------------------------------------------------------- /mpn/x86/fat/mode1o.c: -------------------------------------------------------------------------------- 1 | /* Fat binary fallback mpn_modexact_1c_odd. 2 | 3 | Copyright 2003 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #include "mpn/generic/mode1o.c" 22 | -------------------------------------------------------------------------------- /mpn/x86_64/fat/mod_1.c: -------------------------------------------------------------------------------- 1 | /* Fat binary fallback mpn_mod_1. 2 | 3 | Copyright 2003, 2009 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #include "mpn/generic/mod_1.c" 22 | -------------------------------------------------------------------------------- /mpn/x86/fat/diveby3.c: -------------------------------------------------------------------------------- 1 | /* Fat binary fallback mpn_divexact_by3c. 2 | 3 | Copyright 2003, 2009 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #include "mpn/generic/diveby3.c" 22 | -------------------------------------------------------------------------------- /mpn/x86_64/fat/mode1o.c: -------------------------------------------------------------------------------- 1 | /* Fat binary fallback mpn_modexact_1c_odd. 2 | 3 | Copyright 2003 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #include "mpn/generic/mode1o.c" 22 | -------------------------------------------------------------------------------- /mpn/x86_64/fat/diveby3.c: -------------------------------------------------------------------------------- 1 | /* Fat binary fallback mpn_divexact_by3c. 2 | 3 | Copyright 2003, 2009 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #include "mpn/generic/diveby3.c" 22 | -------------------------------------------------------------------------------- /mpn/generic/add.c: -------------------------------------------------------------------------------- 1 | /* mpn_add - add mpn to mpn. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define __GMP_FORCE_mpn_add 1 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | -------------------------------------------------------------------------------- /mpz/add_ui.c: -------------------------------------------------------------------------------- 1 | /* mpz_add_ui -- Add an mpz_t and an unsigned one-word integer. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #define OPERATION_add_ui 22 | #include "aors_ui.h" 23 | -------------------------------------------------------------------------------- /mpn/generic/add_1.c: -------------------------------------------------------------------------------- 1 | /* mpn_add_1 - add limb to mpn. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define __GMP_FORCE_mpn_add_1 1 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | -------------------------------------------------------------------------------- /mpn/generic/neg.c: -------------------------------------------------------------------------------- 1 | /* mpn_neg - negate an mpn. 2 | 3 | Copyright 2001, 2009 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define __GMP_FORCE_mpn_neg 1 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | -------------------------------------------------------------------------------- /mpn/generic/sub.c: -------------------------------------------------------------------------------- 1 | /* mpn_sub - subtract mpn from mpn. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define __GMP_FORCE_mpn_sub 1 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | -------------------------------------------------------------------------------- /mpz/sub_ui.c: -------------------------------------------------------------------------------- 1 | /* mpz_sub_ui -- Subtract an mpz_t and an unsigned one-word integer. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #define OPERATION_sub_ui 22 | #include "aors_ui.h" 23 | -------------------------------------------------------------------------------- /demos/calc/calc-config-h.in: -------------------------------------------------------------------------------- 1 | /* Templates for calc program configuration. -*- mode:c -*- 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | This program is free software; you can redistribute it and/or modify it under 8 | the terms of the GNU General Public License as published by the Free Software 9 | Foundation; either version 3 of the License, or (at your option) any later 10 | version. 11 | 12 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 | PARTICULAR PURPOSE. See the GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program. If not, see http://www.gnu.org/licenses/. */ 18 | 19 | 20 | /* Define if GNU readline should be used. */ 21 | #define WITH_READLINE @WITH_READLINE_01@ 22 | -------------------------------------------------------------------------------- /mpn/generic/sub_1.c: -------------------------------------------------------------------------------- 1 | /* mpn_sub_1 - subtract limb from mpn. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define __GMP_FORCE_mpn_sub_1 1 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | -------------------------------------------------------------------------------- /mp_bpl.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 1996 Free Software Foundation, Inc. 3 | 4 | This file is part of the GNU MP Library. 5 | 6 | The GNU MP Library is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or (at your 9 | option) any later version. 10 | 11 | The GNU MP Library is distributed in the hope that it will be useful, but 12 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 14 | License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 18 | 19 | #include "gmp.h" 20 | #include "gmp-impl.h" 21 | 22 | const int mp_bits_per_limb = GMP_LIMB_BITS; 23 | const int __gmp_0 = 0; 24 | int __gmp_junk; 25 | -------------------------------------------------------------------------------- /tests/cxx/t-headers.cc: -------------------------------------------------------------------------------- 1 | /* Test that gmpxx.h compiles correctly. 2 | 3 | Copyright 2001, 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmpxx.h" 21 | 22 | int 23 | main (void) 24 | { 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /mpn/z8000/gmp-mparam.h: -------------------------------------------------------------------------------- 1 | /* gmp-mparam.h -- Compiler/machine parameter header file. 2 | 3 | Copyright 1991, 1993, 1994, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define GMP_LIMB_BITS 16 21 | #define BYTES_PER_MP_LIMB 2 22 | -------------------------------------------------------------------------------- /cxx/dummy.cc: -------------------------------------------------------------------------------- 1 | /* Dummy file to make automake treat libgmpxx.la as C++. 2 | 3 | Copyright 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | /* some compilers reputedly dislike completely empty files */ 22 | typedef int foo; 23 | -------------------------------------------------------------------------------- /mpf/fits_uint.c: -------------------------------------------------------------------------------- 1 | /* mpf_fits_uint_p -- test whether an mpf fits an unsigned int. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #define FUNCTION mpf_fits_uint_p 22 | #define MAXIMUM UINT_MAX 23 | 24 | #include "fits_u.h" 25 | -------------------------------------------------------------------------------- /mpz/fits_uint.c: -------------------------------------------------------------------------------- 1 | /* mpz_fits_uint_p -- test whether z fits an unsigned int. 2 | 3 | Copyright 1997, 2000, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define __GMP_FORCE_mpz_fits_uint_p 1 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | -------------------------------------------------------------------------------- /mpz/fits_ulong.c: -------------------------------------------------------------------------------- 1 | /* mpz_fits_ulong_p -- test whether z fits an unsigned long. 2 | 3 | Copyright 1997, 2000, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define __GMP_FORCE_mpz_fits_ulong_p 1 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | -------------------------------------------------------------------------------- /mpz/fits_ushort.c: -------------------------------------------------------------------------------- 1 | /* mpz_fits_ushort_p -- test whether z fits an unsigned short. 2 | 3 | Copyright 1997, 2000, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define __GMP_FORCE_mpz_fits_ushort_p 1 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | -------------------------------------------------------------------------------- /version.c: -------------------------------------------------------------------------------- 1 | /* gmp_version -- version number compiled into the library. 2 | 3 | Copyright 1996, 1999, 2000, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | const char * const gmp_version = VERSION; 24 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | gmp.js 2 | ====== 3 | 4 | gmp.js is a port of the GNU Multiple-Precision Library (GMP), a library 5 | for arbitrary precision arithmetic, to JavaScript using Emscripten. 6 | 7 | GMP website: http://gmplib.org/ 8 | 9 | 10 | Steps to build 11 | -------------- 12 | 13 | * First run configure and make natively/normally. You will need some 14 | of the generated executables. Optionally, also build ``test.c`` and see 15 | that it works (see instructions inside ``test.c``). 16 | 17 | * Run configure using something like 18 | 19 | EMCONFIGURE_JS=1 emconfigure ./configure ABI=longlong --build=none --host=none 20 | 21 | * Edit ``config.h`` and disable ``HAVE_QUAD_T``, ``HAVE_OBSTACK_VPRINTF`` 22 | 23 | * Run make using something like 24 | 25 | make -j 2 26 | 27 | * Run ``emscripten.sh`` which will build the main test file, link it, then 28 | compile to JavaScript using Emscripten 29 | 30 | * Run the code using something like 31 | 32 | node complete.js 500 33 | 34 | -------------------------------------------------------------------------------- /mpf/fits_ulong.c: -------------------------------------------------------------------------------- 1 | /* mpf_fits_ulong_p -- test whether an mpf fits an unsigned long. 2 | 3 | Copyright 2001, 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #define FUNCTION mpf_fits_ulong_p 22 | #define MAXIMUM ULONG_MAX 23 | 24 | #include "fits_u.h" 25 | -------------------------------------------------------------------------------- /mpf/fits_ushort.c: -------------------------------------------------------------------------------- 1 | /* mpf_fits_ushort_p -- test whether an mpf fits an unsigned short. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #define FUNCTION mpf_fits_ushort_p 22 | #define MAXIMUM USHRT_MAX 23 | 24 | #include "fits_u.h" 25 | -------------------------------------------------------------------------------- /mpn/generic/cmp.c: -------------------------------------------------------------------------------- 1 | /* mpn_cmp -- Compare two low-level natural-number integers. 2 | 3 | Copyright 1991, 1993, 1994, 1996, 2000, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define __GMP_FORCE_mpn_cmp 1 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | -------------------------------------------------------------------------------- /mpz/getlimbn.c: -------------------------------------------------------------------------------- 1 | /* mpz_getlimbn(integer,n) -- Return the N:th limb from INTEGER. 2 | 3 | Copyright 1993, 1994, 1995, 1996, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define __GMP_FORCE_mpz_getlimbn 1 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | -------------------------------------------------------------------------------- /mpz/mul_si.c: -------------------------------------------------------------------------------- 1 | /* mpz_mul_si (product, multiplier, small_multiplicand) -- Set PRODUCT to 2 | MULTIPLICATOR times SMALL_MULTIPLICAND. 3 | 4 | Copyright 2001 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | 22 | #define OPERATION_mul_si 23 | #include "mul_i.h" 24 | -------------------------------------------------------------------------------- /mpz/mul_ui.c: -------------------------------------------------------------------------------- 1 | /* mpz_mul_ui (product, multiplier, small_multiplicand) -- Set PRODUCT to 2 | MULTIPLICATOR times SMALL_MULTIPLICAND. 3 | 4 | Copyright 2001 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | 22 | #define OPERATION_mul_ui 23 | #include "mul_i.h" 24 | -------------------------------------------------------------------------------- /mpz/set_q.c: -------------------------------------------------------------------------------- 1 | /* mpz_set_q (dest_integer, src_rational) -- Assign DEST_INTEGER from 2 | SRC_rational. 3 | 4 | Copyright 1996, 2001 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #define __GMP_FORCE_mpz_set_q 1 22 | 23 | #include "gmp.h" 24 | #include "gmp-impl.h" 25 | -------------------------------------------------------------------------------- /mpz/get_ui.c: -------------------------------------------------------------------------------- 1 | /* mpz_get_ui(integer) -- Return the least significant digit from INTEGER. 2 | 3 | Copyright 1991, 1993, 1994, 1995, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define __GMP_FORCE_mpz_get_ui 1 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | -------------------------------------------------------------------------------- /mpf/fits_sint.c: -------------------------------------------------------------------------------- 1 | /* mpf_fits_sint_p -- test whether an mpf fits an int. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #define FUNCTION mpf_fits_sint_p 22 | #define MAXIMUM INT_MAX 23 | #define MINIMUM INT_MIN 24 | 25 | #include "fits_s.h" 26 | -------------------------------------------------------------------------------- /mpf/fits_slong.c: -------------------------------------------------------------------------------- 1 | /* mpf_fits_slong_p -- test whether an mpf fits a long. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #define FUNCTION mpf_fits_slong_p 22 | #define MAXIMUM LONG_MAX 23 | #define MINIMUM LONG_MIN 24 | 25 | #include "fits_s.h" 26 | -------------------------------------------------------------------------------- /mpf/fits_sshort.c: -------------------------------------------------------------------------------- 1 | /* mpf_fits_sshort_p -- test whether an mpf fits a short. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #define FUNCTION mpf_fits_sshort_p 22 | #define MAXIMUM SHRT_MAX 23 | #define MINIMUM SHRT_MIN 24 | 25 | #include "fits_s.h" 26 | -------------------------------------------------------------------------------- /mpn/generic/gmp-mparam.h: -------------------------------------------------------------------------------- 1 | /* Generic C gmp-mparam.h -- Compiler/machine parameter header file. 2 | 3 | Copyright 1991, 1993, 1994, 2000 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | /* Values for GMP_LIMB_BITS etc will be determined by ./configure and put 22 | in config.h. */ 23 | -------------------------------------------------------------------------------- /mpz/size.c: -------------------------------------------------------------------------------- 1 | /* mpz_size(x) -- return the number of lims currently used by the 2 | value of integer X. 3 | 4 | Copyright 1991, 1993, 1994, 1995, 2001 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #define __GMP_FORCE_mpz_size 1 22 | 23 | #include "gmp.h" 24 | #include "gmp-impl.h" 25 | -------------------------------------------------------------------------------- /mpz/fits_sint.c: -------------------------------------------------------------------------------- 1 | /* int mpz_fits_sint_p (mpz_t z) -- test whether z fits a int. 2 | 3 | Copyright 1997, 2000, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #define FUNCTION mpz_fits_sint_p 22 | #define MAXIMUM INT_MAX 23 | #define MINIMUM INT_MIN 24 | 25 | #include "fits_s.h" 26 | -------------------------------------------------------------------------------- /mpz/fits_slong.c: -------------------------------------------------------------------------------- 1 | /* int mpz_fits_slong_p (mpz_t z) -- test whether z fits a long. 2 | 3 | Copyright 1997, 2000, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #define FUNCTION mpz_fits_slong_p 22 | #define MAXIMUM LONG_MAX 23 | #define MINIMUM LONG_MIN 24 | 25 | #include "fits_s.h" 26 | -------------------------------------------------------------------------------- /mpz/fits_sshort.c: -------------------------------------------------------------------------------- 1 | /* int mpz_fits_sshort_p (mpz_t z) -- test whether z fits a short. 2 | 3 | Copyright 1997, 2000, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #define FUNCTION mpz_fits_sshort_p 22 | #define MAXIMUM SHRT_MAX 23 | #define MINIMUM SHRT_MIN 24 | 25 | #include "fits_s.h" 26 | -------------------------------------------------------------------------------- /mpn/a29k/umul.s: -------------------------------------------------------------------------------- 1 | ; Copyright 1999, 2000 Free Software Foundation, Inc. 2 | 3 | ; This file is part of the GNU MP Library. 4 | 5 | ; The GNU MP Library is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU Lesser General Public License as published by 7 | ; the Free Software Foundation; either version 3 of the License, or (at your 8 | ; option) any later version. 9 | 10 | ; The GNU MP Library is distributed in the hope that it will be useful, but 11 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | ; License for more details. 14 | 15 | ; You should have received a copy of the GNU Lesser General Public License 16 | ; along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 17 | 18 | .sect .lit,lit 19 | .text 20 | .align 4 21 | .global ___umul_ppmm 22 | .word 0x50000 23 | ___umul_ppmm: 24 | multiplu gr116,lr3,lr4 25 | multmu gr96,lr3,lr4 26 | jmpi lr0 27 | store 0,0,gr116,lr2 28 | -------------------------------------------------------------------------------- /mpn/generic/zero.c: -------------------------------------------------------------------------------- 1 | /* mpn_zero 2 | 3 | Copyright 2009 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpn_zero (mp_ptr rp, mp_size_t n) 25 | { 26 | mp_size_t i; 27 | 28 | rp += n; 29 | for (i = -n; i != 0; i++) 30 | rp[i] = 0; 31 | } 32 | -------------------------------------------------------------------------------- /mpn/x86/p6/sse2/submul_1.asm: -------------------------------------------------------------------------------- 1 | dnl Intel P6/SSE2 mpn_submul_1. 2 | 3 | dnl Copyright 2008 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | MULFUNC_PROLOGUE(mpn_submul_1) 24 | include_mpn(`x86/k6/aorsmul_1.asm') 25 | -------------------------------------------------------------------------------- /mpz/perfsqr.c: -------------------------------------------------------------------------------- 1 | /* mpz_perfect_square_p(arg) -- Return non-zero if ARG is a perfect square, 2 | zero otherwise. 3 | 4 | Copyright 1991, 1993, 1994, 1996, 2000, 2001 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #define __GMP_FORCE_mpz_perfect_square_p 1 22 | 23 | #include "gmp.h" 24 | #include "gmp-impl.h" 25 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to generate Makefile.in 2 | 3 | 4 | # Copyright 2003 Free Software Foundation, Inc. 5 | # 6 | # This file is part of the GNU MP Library. 7 | # 8 | # The GNU MP Library is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU Lesser General Public License as published by 10 | # the Free Software Foundation; either version 3 of the License, or (at your 11 | # option) any later version. 12 | # 13 | # The GNU MP Library is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | # License for more details. 17 | # 18 | # You should have received a copy of the GNU Lesser General Public License 19 | # along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 20 | 21 | 22 | EXTRA_DIST = configuration isa_abi_headache projects.html tasks.html 23 | 24 | info_TEXINFOS = gmp.texi 25 | gmp_TEXINFOS = fdl-1.3.texi 26 | -------------------------------------------------------------------------------- /mpf/get_prc.c: -------------------------------------------------------------------------------- 1 | /* mpf_get_prec(x) -- Return the precision in bits of x. 2 | 3 | Copyright 1996, 2000, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | mp_bitcnt_t 24 | mpf_get_prec (mpf_srcptr x) 25 | { 26 | return __GMPF_PREC_TO_BITS (x->_mp_prec); 27 | } 28 | -------------------------------------------------------------------------------- /mpn/a29k/udiv.s: -------------------------------------------------------------------------------- 1 | ; Copyright 1999, 2000 Free Software Foundation, Inc. 2 | 3 | ; This file is part of the GNU MP Library. 4 | 5 | ; The GNU MP Library is free software; you can redistribute it and/or modify 6 | ; it under the terms of the GNU Lesser General Public License as published by 7 | ; the Free Software Foundation; either version 3 of the License, or (at your 8 | ; option) any later version. 9 | 10 | ; The GNU MP Library is distributed in the hope that it will be useful, but 11 | ; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | ; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | ; License for more details. 14 | 15 | ; You should have received a copy of the GNU Lesser General Public License 16 | ; along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 17 | 18 | .sect .lit,lit 19 | .text 20 | .align 4 21 | .global ___udiv_qrnnd 22 | .word 0x60000 23 | ___udiv_qrnnd: 24 | mtsr q,lr3 25 | dividu gr96,lr4,lr5 26 | mfsr gr116,q 27 | jmpi lr0 28 | store 0,0,gr116,lr2 29 | -------------------------------------------------------------------------------- /mpn/generic/copyd.c: -------------------------------------------------------------------------------- 1 | /* mpn_copyd 2 | 3 | Copyright 2009 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpn_copyd (mp_ptr rp, mp_srcptr up, mp_size_t n) 25 | { 26 | mp_size_t i; 27 | 28 | for (i = n - 1; i >= 0; i--) 29 | rp[i] = up[i]; 30 | } 31 | -------------------------------------------------------------------------------- /tune/powm_mod.c: -------------------------------------------------------------------------------- 1 | /* mpz/powm.c forced to use division. */ 2 | 3 | /* 4 | Copyright 2000 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | #undef POWM_THRESHOLD 25 | #define POWM_THRESHOLD 1 26 | #define __gmpz_powm mpz_powm_mod 27 | 28 | #include "../mpz/powm.c" 29 | -------------------------------------------------------------------------------- /mpn/x86/p6/sse2/mod_1_4.asm: -------------------------------------------------------------------------------- 1 | dnl Intel P6/SSE2 mpn_mod_1_4. 2 | 3 | dnl Copyright 2009, 2011 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or modify 8 | dnl it under the terms of the GNU Lesser General Public License as published 9 | dnl by the Free Software Foundation; either version 3 of the License, or (at 10 | dnl your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, but 13 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | dnl License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | MULFUNC_PROLOGUE(mpn_mod_1s_4p) 23 | include_mpn(`x86/pentium4/sse2/mod_1_4.asm') 24 | -------------------------------------------------------------------------------- /randdef.c: -------------------------------------------------------------------------------- 1 | /* gmp_randinit_default -- initialize a random state with a default algorithm. 2 | 3 | Copyright 2001, 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | gmp_randinit_default (gmp_randstate_t rstate) 25 | { 26 | gmp_randinit_mt (rstate); 27 | } 28 | -------------------------------------------------------------------------------- /mpn/power/sdiv.asm: -------------------------------------------------------------------------------- 1 | dnl Copyright 1999, 2001 Free Software Foundation, Inc. 2 | 3 | dnl This file is part of the GNU MP Library. 4 | 5 | dnl The GNU MP Library is free software; you can redistribute it and/or modify 6 | dnl it under the terms of the GNU Lesser General Public License as published 7 | dnl by the Free Software Foundation; either version 3 of the License, or (at 8 | dnl your option) any later version. 9 | 10 | dnl The GNU MP Library is distributed in the hope that it will be useful, but 11 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | dnl License for more details. 14 | 15 | dnl You should have received a copy of the GNU Lesser General Public License 16 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 17 | 18 | include(`../config.m4') 19 | 20 | ASM_START() 21 | PROLOGUE(mpn_sdiv_qrnnd) 22 | mtmq 5 23 | div 0,4,6 24 | mfmq 9 25 | st 9,0(3) 26 | mr 3,0 27 | br 28 | EPILOGUE(mpn_sdiv_qrnnd) 29 | -------------------------------------------------------------------------------- /mpn/s390/README: -------------------------------------------------------------------------------- 1 | All current (2001) S/390 and z/Architecture machines are single-issue, 2 | but some newer machines have a deep pipeline. Software-pipelining is 3 | therefore beneficial. 4 | 5 | * mpn_add_n, mpn_sub_n: Use code along the lines below. Two-way unrolling 6 | would be adequate. 7 | 8 | mp_limb_t 9 | mpn_add_n (mp_ptr rp, mp_srcptr up, mp_srcptr vp, mp_size_t n) 10 | { 11 | mp_limb_t a, b, r, cy; 12 | mp_size_t i; 13 | mp_limb_t mm = -1; 14 | 15 | cy = 0; 16 | up += n; 17 | vp += n; 18 | rp += n; 19 | i = -n; 20 | do 21 | { 22 | a = up[i]; 23 | b = vp[i]; 24 | r = a + b + cy; 25 | rp[i] = r; 26 | cy = (((a & b) | ((a | b) & (r ^ mm)))) >> 31; 27 | i++; 28 | } 29 | while (i < 0); 30 | return cy; 31 | } 32 | 33 | * mpn_lshift, mpn_rshift: Use SLDL/SRDL, and two-way unrolling. 34 | 35 | * mpn_mul_1, mpn_addmul_1, mpn_submul_1: For machines with just signed 36 | multiply (MR), use two loops, similar to the corresponding VAX or 37 | POWER functions. Handle carry like for mpn_add_n. 38 | -------------------------------------------------------------------------------- /mpn/x86_64/core2/popcount.asm: -------------------------------------------------------------------------------- 1 | dnl x86-64 mpn_popcount optimized for "Core 2". 2 | 3 | dnl Copyright 2007 Free Software Foundation, Inc. 4 | 5 | dnl This file is part of the GNU MP Library. 6 | 7 | dnl The GNU MP Library is free software; you can redistribute it and/or modify 8 | dnl it under the terms of the GNU Lesser General Public License as published 9 | dnl by the Free Software Foundation; either version 3 of the License, or (at 10 | dnl your option) any later version. 11 | 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, but 13 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | dnl License for more details. 16 | 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | 21 | include(`../config.m4') 22 | 23 | MULFUNC_PROLOGUE(mpn_popcount) 24 | include_mpn(`x86/pentium4/sse2/popcount.asm') 25 | -------------------------------------------------------------------------------- /mpz/popcount.c: -------------------------------------------------------------------------------- 1 | /* mpz_popcount(mpz_ptr op) -- Population count of OP. If the operand is 2 | negative, return ~0 (a novel representation of infinity). 3 | 4 | Copyright 1994, 1996, 2001 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #define __GMP_FORCE_mpz_popcount 1 22 | 23 | #include "gmp.h" 24 | #include "gmp-impl.h" 25 | -------------------------------------------------------------------------------- /mpn/x86_64/pentium4/popcount.asm: -------------------------------------------------------------------------------- 1 | dnl x86-64 mpn_popcount optimized for Pentium 4. 2 | 3 | dnl Copyright 2007 Free Software Foundation, Inc. 4 | 5 | dnl This file is part of the GNU MP Library. 6 | 7 | dnl The GNU MP Library is free software; you can redistribute it and/or modify 8 | dnl it under the terms of the GNU Lesser General Public License as published 9 | dnl by the Free Software Foundation; either version 3 of the License, or (at 10 | dnl your option) any later version. 11 | 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, but 13 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | dnl License for more details. 16 | 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | 21 | include(`../config.m4') 22 | 23 | MULFUNC_PROLOGUE(mpn_popcount) 24 | include_mpn(`x86/pentium4/sse2/popcount.asm') 25 | -------------------------------------------------------------------------------- /tune/jacbase1.c: -------------------------------------------------------------------------------- 1 | /* mpn/generic/jacbase.c method 1. 2 | 3 | Copyright 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | #undef JACOBI_BASE_METHOD 24 | #define JACOBI_BASE_METHOD 1 25 | #define __gmpn_jacobi_base mpn_jacobi_base_1 26 | 27 | #include "mpn/generic/jacbase.c" 28 | -------------------------------------------------------------------------------- /tune/jacbase2.c: -------------------------------------------------------------------------------- 1 | /* mpn/generic/jacbase.c method 2. 2 | 3 | Copyright 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | #undef JACOBI_BASE_METHOD 24 | #define JACOBI_BASE_METHOD 2 25 | #define __gmpn_jacobi_base mpn_jacobi_base_2 26 | 27 | #include "mpn/generic/jacbase.c" 28 | -------------------------------------------------------------------------------- /tune/jacbase3.c: -------------------------------------------------------------------------------- 1 | /* mpn/generic/jacbase.c method 3. 2 | 3 | Copyright 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | #undef JACOBI_BASE_METHOD 24 | #define JACOBI_BASE_METHOD 3 25 | #define __gmpn_jacobi_base mpn_jacobi_base_3 26 | 27 | #include "mpn/generic/jacbase.c" 28 | -------------------------------------------------------------------------------- /mpf/get_dfl_prec.c: -------------------------------------------------------------------------------- 1 | /* mpf_get_default_prec -- return default precision in bits. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | 24 | mp_bitcnt_t 25 | mpf_get_default_prec (void) 26 | { 27 | return __GMPF_PREC_TO_BITS (__gmp_default_fp_limb_precision); 28 | } 29 | -------------------------------------------------------------------------------- /mpn/x86/p6/sse2/mul_basecase.asm: -------------------------------------------------------------------------------- 1 | dnl Intel P6/SSE2 mpn_mul_basecase. 2 | 3 | dnl Copyright 2008 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | MULFUNC_PROLOGUE(mpn_mul_basecase) 24 | include_mpn(`x86/pentium4/sse2/mul_basecase.asm') 25 | -------------------------------------------------------------------------------- /mpn/x86/p6/sse2/sqr_basecase.asm: -------------------------------------------------------------------------------- 1 | dnl Intel P6/SSE2 mpn_sqr_basecase. 2 | 3 | dnl Copyright 2008 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | MULFUNC_PROLOGUE(mpn_sqr_basecase) 24 | include_mpn(`x86/pentium4/sse2/sqr_basecase.asm') 25 | -------------------------------------------------------------------------------- /mpf/size.c: -------------------------------------------------------------------------------- 1 | /* mpf_size(x) -- return the number of limbs currently used by the 2 | value of the float X. 3 | 4 | Copyright 1993, 1994, 1995, 2001 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | size_t 25 | mpf_size (mpf_srcptr f) 26 | { 27 | return __GMP_ABS (f->_mp_size); 28 | } 29 | -------------------------------------------------------------------------------- /mpn/x86/p6/sse2/popcount.asm: -------------------------------------------------------------------------------- 1 | dnl Intel P6/SSE2 mpn_popcount -- population count. 2 | 3 | dnl Copyright 2008 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | MULFUNC_PROLOGUE(mpn_popcount) 24 | include_mpn(`x86/pentium4/sse2/popcount.asm') 25 | -------------------------------------------------------------------------------- /mpn/generic/copyi.c: -------------------------------------------------------------------------------- 1 | /* mpn_copyi 2 | 3 | Copyright 2009 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpn_copyi (mp_ptr rp, mp_srcptr up, mp_size_t n) 25 | { 26 | mp_size_t i; 27 | 28 | up += n; 29 | rp += n; 30 | for (i = -n; i != 0; i++) 31 | rp[i] = up[i]; 32 | } 33 | -------------------------------------------------------------------------------- /randclr.c: -------------------------------------------------------------------------------- 1 | /* gmp_randclear (state) -- Clear and deallocate random state STATE. 2 | 3 | Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | gmp_randclear (gmp_randstate_t rstate) 25 | { 26 | (*((gmp_randfnptr_t *) RNG_FNPTR (rstate))->randclear_fn) (rstate); 27 | } 28 | -------------------------------------------------------------------------------- /tune/pre_divrem_1.c: -------------------------------------------------------------------------------- 1 | /* mpn_preinv_divrem_1 -- if not already in libgmp. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | #if ! USE_PREINV_DIVREM_1 24 | 25 | #undef USE_PREINV_DIVREM_1 26 | #define USE_PREINV_DIVREM_1 1 27 | 28 | #include "mpn/generic/pre_divrem_1.c" 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /mpn/x86/p6/sse2/addmul_1.asm: -------------------------------------------------------------------------------- 1 | dnl Intel P6/SSE2 mpn_addmul_1. 2 | 3 | dnl Copyright 2008 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | C TODO 23 | C * Write P6 specific SSE2 code. 24 | 25 | MULFUNC_PROLOGUE(mpn_addmul_1) 26 | include_mpn(`x86/pentium4/sse2/addmul_1.asm') 27 | -------------------------------------------------------------------------------- /tune/gcdext_double.c: -------------------------------------------------------------------------------- 1 | /* mpn/generic/gcdext.c forced to use double limb calculations. */ 2 | 3 | /* 4 | Copyright 2000 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | #undef GCDEXT_THRESHOLD 25 | #define GCDEXT_THRESHOLD 0 26 | #define __gmpn_gcdext mpn_gcdext_double 27 | 28 | #include "../mpn/generic/gcdext.c" 29 | -------------------------------------------------------------------------------- /mpbsd/mfree.c: -------------------------------------------------------------------------------- 1 | /* mfree -- BSD compatible mfree. 2 | 3 | Copyright 1991, 1994, 1995, 2000, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "mp.h" 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | void 25 | mfree (MINT *m) 26 | { 27 | (*__gmp_free_func) (m->_mp_d, m->_mp_alloc * BYTES_PER_MP_LIMB); 28 | (*__gmp_free_func) (m, sizeof (MINT)); 29 | } 30 | -------------------------------------------------------------------------------- /mpf/clear.c: -------------------------------------------------------------------------------- 1 | /* mpf_clear -- de-allocate the space occupied by the dynamic digit space of 2 | an integer. 3 | 4 | Copyright 1993, 1994, 1995, 2000, 2001 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | void 25 | mpf_clear (mpf_ptr m) 26 | { 27 | (*__gmp_free_func) (m->_mp_d, (m->_mp_prec + 1) * BYTES_PER_MP_LIMB); 28 | } 29 | -------------------------------------------------------------------------------- /mpz/clear.c: -------------------------------------------------------------------------------- 1 | /* mpz_clear -- de-allocate the space occupied by the dynamic digit space of 2 | an integer. 3 | 4 | Copyright 1991, 1993, 1994, 1995, 2000, 2001 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | void 25 | mpz_clear (mpz_ptr m) 26 | { 27 | (*__gmp_free_func) (m->_mp_d, m->_mp_alloc * BYTES_PER_MP_LIMB); 28 | } 29 | -------------------------------------------------------------------------------- /randiset.c: -------------------------------------------------------------------------------- 1 | /* gmp_randinit_set -- initialize with a copy of another gmp_randstate_t. 2 | 3 | Copyright 2003 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | 24 | void 25 | gmp_randinit_set (gmp_randstate_ptr dst, gmp_randstate_srcptr src) 26 | { 27 | (*((gmp_randfnptr_t *) RNG_FNPTR (src))->randiset_fn) (dst, src); 28 | } 29 | -------------------------------------------------------------------------------- /tune/gcdext_single.c: -------------------------------------------------------------------------------- 1 | /* mpn/generic/gcdext.c forced to use single limb calculations. */ 2 | 3 | /* 4 | Copyright 2000 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | #undef GCDEXT_THRESHOLD 25 | #define GCDEXT_THRESHOLD MP_SIZE_T_MAX 26 | #define __gmpn_gcdext mpn_gcdext_single 27 | 28 | #include "../mpn/generic/gcdext.c" 29 | -------------------------------------------------------------------------------- /randsd.c: -------------------------------------------------------------------------------- 1 | /* gmp_randseed (state, seed) -- Set initial seed SEED in random state STATE. 2 | 3 | Copyright 2000, 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | gmp_randseed (gmp_randstate_t rstate, 25 | mpz_srcptr seed) 26 | { 27 | (*((gmp_randfnptr_t *) RNG_FNPTR (rstate))->randseed_fn) (rstate, seed); 28 | } 29 | -------------------------------------------------------------------------------- /mpbsd/rpow.c: -------------------------------------------------------------------------------- 1 | /* rpow -- MINT raised to short. */ 2 | 3 | /* 4 | Copyright 2001 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "mp.h" 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | 25 | void 26 | rpow (const MINT *b, short e, MINT *r) 27 | { 28 | if (e >= 0) 29 | mpz_n_pow_ui (r, PTR(b), (mp_size_t) SIZ(b), (unsigned long) e); 30 | else 31 | SIZ(r) = 0; 32 | } 33 | -------------------------------------------------------------------------------- /mpz/perfpow.c: -------------------------------------------------------------------------------- 1 | /* mpz_perfect_power_p(arg) -- Return non-zero if ARG is a perfect power, 2 | zero otherwise. 3 | 4 | Copyright 1998, 1999, 2000, 2001, 2005, 2008, 2009 Free Software Foundation, 5 | Inc. 6 | 7 | This file is part of the GNU MP Library. 8 | 9 | The GNU MP Library is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published by 11 | the Free Software Foundation; either version 3 of the License, or (at your 12 | option) any later version. 13 | 14 | The GNU MP Library is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 17 | License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | 25 | int 26 | mpz_perfect_power_p (mpz_srcptr u) 27 | { 28 | return mpn_perfect_power_p (PTR (u), SIZ (u)); 29 | } 30 | -------------------------------------------------------------------------------- /tune/gcdextod.c: -------------------------------------------------------------------------------- 1 | /* mpn/generic/gcdext.c forced to one double limb step. */ 2 | 3 | /* 4 | Copyright 2000 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | #undef GCDEXT_THRESHOLD 25 | #define GCDEXT_THRESHOLD 0 26 | #define WANT_GCDEXT_ONE_STEP 1 27 | #define __gmpn_gcdext mpn_gcdext_one_double 28 | 29 | #include "../mpn/generic/gcdext.c" 30 | -------------------------------------------------------------------------------- /mpn/power/umul.asm: -------------------------------------------------------------------------------- 1 | dnl Copyright 1999, 2001 Free Software Foundation, Inc. 2 | 3 | dnl This file is part of the GNU MP Library. 4 | 5 | dnl The GNU MP Library is free software; you can redistribute it and/or modify 6 | dnl it under the terms of the GNU Lesser General Public License as published 7 | dnl by the Free Software Foundation; either version 3 of the License, or (at 8 | dnl your option) any later version. 9 | 10 | dnl The GNU MP Library is distributed in the hope that it will be useful, but 11 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | dnl License for more details. 14 | 15 | dnl You should have received a copy of the GNU Lesser General Public License 16 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 17 | 18 | include(`../config.m4') 19 | 20 | ASM_START() 21 | PROLOGUE(mpn_umul_ppmm) 22 | mul 9,4,5 23 | srai 0,4,31 24 | and 0,0,5 25 | srai 5,5,31 26 | and 5,5,4 27 | cax 0,0,5 28 | mfmq 11 29 | st 11,0(3) 30 | cax 3,9,0 31 | br 32 | EPILOGUE(mpn_umul_ppmm) 33 | -------------------------------------------------------------------------------- /mpz/random.c: -------------------------------------------------------------------------------- 1 | /* mpz_random -- Generate a random mpz_t of specified size in limbs. 2 | 3 | Copyright 2001, 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpz_random (mpz_ptr x, mp_size_t size) 25 | { 26 | mpz_urandomb (x, RANDS, (unsigned long) (ABS (size) * GMP_NUMB_BITS)); 27 | if (size < 0) 28 | SIZ(x) = -SIZ(x); 29 | } 30 | -------------------------------------------------------------------------------- /mpn/sparc32/v8/umul.asm: -------------------------------------------------------------------------------- 1 | dnl SPARC v8 mpn_umul_ppmm -- support for longlong.h for non-gcc. 2 | 3 | dnl Copyright 1995, 1996, 2000 Free Software Foundation, Inc. 4 | 5 | dnl This file is part of the GNU MP Library. 6 | 7 | dnl The GNU MP Library is free software; you can redistribute it and/or modify 8 | dnl it under the terms of the GNU Lesser General Public License as published 9 | dnl by the Free Software Foundation; either version 3 of the License, or (at 10 | dnl your option) any later version. 11 | 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, but 13 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | dnl License for more details. 16 | 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | 21 | include(`../config.m4') 22 | 23 | ASM_START() 24 | PROLOGUE(mpn_umul_ppmm) 25 | umul %o1,%o2,%g2 26 | st %g2,[%o0] 27 | retl 28 | rd %y,%o0 29 | EPILOGUE(mpn_umul_ppmm) 30 | -------------------------------------------------------------------------------- /tune/gcdextos.c: -------------------------------------------------------------------------------- 1 | /* mpn/generic/gcdext.c forced to one single limb step. */ 2 | 3 | /* 4 | Copyright 2000 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | #undef GCDEXT_THRESHOLD 25 | #define GCDEXT_THRESHOLD MP_SIZE_T_MAX 26 | #define WANT_GCDEXT_ONE_STEP 1 27 | #define __gmpn_gcdext mpn_gcdext_one_single 28 | 29 | #include "../mpn/generic/gcdext.c" 30 | -------------------------------------------------------------------------------- /scanf/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to generate Makefile.in 2 | 3 | # Copyright 2001, 2002 Free Software Foundation, Inc. 4 | # 5 | # This file is part of the GNU MP Library. 6 | # 7 | # The GNU MP Library is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU Lesser General Public License as published by 9 | # the Free Software Foundation; either version 3 of the License, or (at your 10 | # option) any later version. 11 | # 12 | # The GNU MP Library is distributed in the hope that it will be useful, but 13 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | # License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public License 18 | # along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | 21 | INCLUDES = -D__GMP_WITHIN_GMP -I$(top_srcdir) 22 | 23 | noinst_LTLIBRARIES = libscanf.la 24 | 25 | libscanf_la_SOURCES = \ 26 | doscan.c fscanf.c fscanffuns.c scanf.c sscanf.c sscanffuns.c \ 27 | vfscanf.c vscanf.c vsscanf.c 28 | -------------------------------------------------------------------------------- /tune/divrem2inv.c: -------------------------------------------------------------------------------- 1 | /* mpn/generic/divrem_2.c forced to use udiv_qrnnd_preinv. */ 2 | 3 | /* 4 | Copyright 2001 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | #ifdef DIVREM_2_THRESHOLD 25 | #undef DIVREM_2_THRESHOLD 26 | #endif 27 | #define DIVREM_2_THRESHOLD 0 28 | #define __gmpn_divrem_2 mpn_divrem_2_inv 29 | 30 | #include "mpn/generic/divrem_2.c" 31 | -------------------------------------------------------------------------------- /mpf/set_dfl_prec.c: -------------------------------------------------------------------------------- 1 | /* mpf_set_default_prec -- 2 | 3 | Copyright 1993, 1994, 1995, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | mp_size_t __gmp_default_fp_limb_precision = __GMPF_BITS_TO_PREC (53); 24 | 25 | void 26 | mpf_set_default_prec (mp_bitcnt_t prec_in_bits) 27 | { 28 | __gmp_default_fp_limb_precision = __GMPF_BITS_TO_PREC (prec_in_bits); 29 | } 30 | -------------------------------------------------------------------------------- /tune/divrem2div.c: -------------------------------------------------------------------------------- 1 | /* mpn/generic/divrem_2.c forced to use plain udiv_qrnnd. */ 2 | 3 | /* 4 | Copyright 2001 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | #ifdef DIVREM_2_THRESHOLD 25 | #undef DIVREM_2_THRESHOLD 26 | #endif 27 | #define DIVREM_2_THRESHOLD MP_SIZE_T_MAX 28 | #define __gmpn_divrem_2 mpn_divrem_2_div 29 | 30 | #include "mpn/generic/divrem_2.c" 31 | -------------------------------------------------------------------------------- /mpn/generic/com.c: -------------------------------------------------------------------------------- 1 | /* mpn_com - complement an mpn. 2 | 3 | Copyright 2009 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | #undef mpn_com 24 | #define mpn_com __MPN(com) 25 | 26 | void 27 | mpn_com (mp_ptr rp, mp_srcptr up, mp_size_t n) 28 | { 29 | mp_limb_t ul; 30 | do { 31 | ul = *up++; 32 | *rp++ = ~ul & GMP_NUMB_MASK; 33 | } while (--n != 0); 34 | } 35 | -------------------------------------------------------------------------------- /mpn/x86/p6/sse2/mul_1.asm: -------------------------------------------------------------------------------- 1 | dnl Intel P6/SSE2 mpn_mul_1. 2 | 3 | dnl Copyright 2008 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | C TODO 23 | C * Write P6 specific SSE2 code. It should reach 3 c/l. 24 | C The Pentium4 code runs at 4.2 c/l. 25 | 26 | MULFUNC_PROLOGUE(mpn_mul_1) 27 | include_mpn(`x86/pentium4/sse2/mul_1.asm') 28 | -------------------------------------------------------------------------------- /mpn/cray/popcount.c: -------------------------------------------------------------------------------- 1 | /* Cray mpn_popcount -- population count. 2 | 3 | Copyright 2000 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | unsigned long int 25 | mpn_popcount (mp_srcptr p, mp_size_t n) 26 | { 27 | unsigned long int result = 0; 28 | mp_size_t i; 29 | for (i = 0; i < n; i++) 30 | result += _popcnt (p[i]); 31 | return result; 32 | } 33 | -------------------------------------------------------------------------------- /mpn/x86/pentium4/mmx/lshift.asm: -------------------------------------------------------------------------------- 1 | dnl Intel Pentium-4 mpn_lshift -- left shift. 2 | 3 | dnl Copyright 2001, 2002 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | C P4 Willamette, Northwood: 1.75 cycles/limb 24 | C P4 Prescott: 2.0 cycles/limb 25 | 26 | 27 | MULFUNC_PROLOGUE(mpn_lshift) 28 | include_mpn(`x86/pentium/mmx/lshift.asm') 29 | -------------------------------------------------------------------------------- /mpn/x86/pentium4/mmx/rshift.asm: -------------------------------------------------------------------------------- 1 | dnl Intel Pentium-4 mpn_rshift -- right shift. 2 | 3 | dnl Copyright 2001, 2002 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | C P4 Willamette, Northwood: 1.75 cycles/limb 24 | C P4 Prescott: 2.0 cycles/limb 25 | 26 | 27 | MULFUNC_PROLOGUE(mpn_rshift) 28 | include_mpn(`x86/pentium/mmx/rshift.asm') 29 | -------------------------------------------------------------------------------- /mpn/powerpc32/vmx/popcount.asm: -------------------------------------------------------------------------------- 1 | dnl PowerPC-32/VMX mpn_popcount. 2 | 3 | dnl Copyright 2006 Free Software Foundation, Inc. 4 | 5 | dnl This file is part of the GNU MP Library. 6 | 7 | dnl The GNU MP Library is free software; you can redistribute it and/or modify 8 | dnl it under the terms of the GNU Lesser General Public License as published 9 | dnl by the Free Software Foundation; either version 3 of the License, or (at 10 | dnl your option) any later version. 11 | 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, but 13 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | dnl License for more details. 16 | 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | MULFUNC_PROLOGUE(mpn_popcount) 23 | include_mpn(`powerpc64/vmx/popcount.asm') 24 | 25 | C cycles/limb 26 | C 7400,7410 (G4): 2.75 27 | C 744x,745x (G4+): 2.25 28 | C 970 (G5): 5.3 29 | -------------------------------------------------------------------------------- /tune/powm_redc.c: -------------------------------------------------------------------------------- 1 | /* mpz/powm.c forced to use REDC. */ 2 | 3 | /* 4 | Copyright 2000 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | /* WANT_GLOBAL_REDC makes redc() available for speed and tune program use. */ 25 | #undef POWM_THRESHOLD 26 | #define POWM_THRESHOLD MP_SIZE_T_MAX 27 | #define WANT_REDC_GLOBAL 1 28 | #define __gmpz_powm mpz_powm_redc 29 | 30 | #include "../mpz/powm.c" 31 | -------------------------------------------------------------------------------- /cxx/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to generate Makefile.in 2 | 3 | # Copyright 2001, 2002, 2003 Free Software Foundation, Inc. 4 | # 5 | # This file is part of the GNU MP Library. 6 | # 7 | # The GNU MP Library is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU Lesser General Public License as published by 9 | # the Free Software Foundation; either version 3 of the License, or (at your 10 | # option) any later version. 11 | # 12 | # The GNU MP Library is distributed in the hope that it will be useful, but 13 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | # License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public License 18 | # along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | 21 | INCLUDES = -D__GMP_WITHIN_GMPXX -I$(top_srcdir) 22 | 23 | if WANT_CXX 24 | noinst_LTLIBRARIES = libcxx.la 25 | endif 26 | 27 | libcxx_la_SOURCES = \ 28 | isfuns.cc ismpf.cc ismpq.cc ismpz.cc ismpznw.cc \ 29 | osdoprnti.cc osfuns.cc osmpf.cc osmpq.cc osmpz.cc 30 | -------------------------------------------------------------------------------- /mpn/mips64/umul.asm: -------------------------------------------------------------------------------- 1 | dnl MIPS64 umul_ppmm -- longlong.h support. 2 | 3 | dnl Copyright 2002 Free Software Foundation, Inc. 4 | 5 | dnl This file is part of the GNU MP Library. 6 | 7 | dnl The GNU MP Library is free software; you can redistribute it and/or modify 8 | dnl it under the terms of the GNU Lesser General Public License as published 9 | dnl by the Free Software Foundation; either version 3 of the License, or (at 10 | dnl your option) any later version. 11 | 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, but 13 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | dnl License for more details. 16 | 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | C INPUT PARAMETERS 23 | C plp $4 24 | C u $5 25 | C v $6 26 | 27 | ASM_START() 28 | PROLOGUE(mpn_umul_ppmm) 29 | dmultu $5,$6 30 | mflo $3 31 | mfhi $2 32 | j $31 33 | sd $3,0($4) 34 | EPILOGUE(mpn_umul_ppmm) 35 | -------------------------------------------------------------------------------- /mpn/x86/p6/mmx/lshift.asm: -------------------------------------------------------------------------------- 1 | dnl Intel Pentium-II mpn_lshift -- mpn left shift. 2 | 3 | dnl Copyright 2001 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | 21 | dnl The P55 code runs well on P-II/III, but could stand some minor tweaks 22 | dnl at some stage probably. 23 | 24 | include(`../config.m4') 25 | 26 | MULFUNC_PROLOGUE(mpn_lshift) 27 | include_mpn(`x86/pentium/mmx/lshift.asm') 28 | -------------------------------------------------------------------------------- /mpn/x86/p6/mmx/rshift.asm: -------------------------------------------------------------------------------- 1 | dnl Intel Pentium-II mpn_rshift -- mpn left shift. 2 | 3 | dnl Copyright 2001 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | 21 | dnl The P55 code runs well on P-II/III, but could stand some minor tweaks 22 | dnl at some stage probably. 23 | 24 | include(`../config.m4') 25 | 26 | MULFUNC_PROLOGUE(mpn_rshift) 27 | include_mpn(`x86/pentium/mmx/rshift.asm') 28 | -------------------------------------------------------------------------------- /mpn/mips32/umul.asm: -------------------------------------------------------------------------------- 1 | dnl MIPS32 umul_ppmm -- longlong.h support. 2 | 3 | dnl Copyright 1999, 2002 Free Software Foundation, Inc. 4 | 5 | dnl This file is part of the GNU MP Library. 6 | 7 | dnl The GNU MP Library is free software; you can redistribute it and/or modify 8 | dnl it under the terms of the GNU Lesser General Public License as published 9 | dnl by the Free Software Foundation; either version 3 of the License, or (at 10 | dnl your option) any later version. 11 | 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, but 13 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | dnl License for more details. 16 | 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | C INPUT PARAMETERS 23 | C plp $4 24 | C u $5 25 | C v $6 26 | 27 | ASM_START() 28 | PROLOGUE(mpn_umul_ppmm) 29 | multu $5,$6 30 | mflo $3 31 | mfhi $2 32 | j $31 33 | sw $3,0($4) 34 | EPILOGUE(mpn_umul_ppmm) 35 | -------------------------------------------------------------------------------- /mpq/clear.c: -------------------------------------------------------------------------------- 1 | /* mpq_clear -- free the space occupied by a MP_RAT. 2 | 3 | Copyright 1991, 1994, 1995, 2000, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpq_clear (MP_RAT *m) 25 | { 26 | (*__gmp_free_func) (m->_mp_num._mp_d, 27 | m->_mp_num._mp_alloc * BYTES_PER_MP_LIMB); 28 | (*__gmp_free_func) (m->_mp_den._mp_d, 29 | m->_mp_den._mp_alloc * BYTES_PER_MP_LIMB); 30 | } 31 | -------------------------------------------------------------------------------- /mpn/x86_64/darwin.m4: -------------------------------------------------------------------------------- 1 | divert(-1) 2 | dnl Copyright 2008 Free Software Foundation, Inc. 3 | dnl 4 | dnl This file is part of the GNU MP Library. 5 | dnl 6 | dnl The GNU MP Library is free software; you can redistribute it and/or 7 | dnl modify it under the terms of the GNU Lesser General Public License as 8 | dnl published by the Free Software Foundation; either version 3 of the 9 | dnl License, or (at your option) any later version. 10 | dnl 11 | dnl The GNU MP Library is distributed in the hope that it will be useful, 12 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | dnl Lesser General Public License for more details. 15 | dnl 16 | dnl You should have received a copy of the GNU Lesser General Public License 17 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 18 | 19 | define(`DARWIN') 20 | 21 | define(`LEA',` 22 | lea $1(%rip), $2 23 | ') 24 | 25 | dnl Usage: CALL(funcname) 26 | dnl 27 | dnl Simply override the definition in x86_64-defs.m4. 28 | 29 | define(`CALL',`call GSYM_PREFIX`'$1') 30 | 31 | 32 | define(`JUMPTABSECT', `DATA') 33 | 34 | divert`'dnl 35 | -------------------------------------------------------------------------------- /mpz/get_d.c: -------------------------------------------------------------------------------- 1 | /* double mpz_get_d (mpz_t src) -- Return the double approximation to SRC. 2 | 3 | Copyright 1996, 1997, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | double 24 | mpz_get_d (mpz_srcptr z) 25 | { 26 | mp_size_t size; 27 | 28 | size = SIZ (z); 29 | if (UNLIKELY (size == 0)) 30 | return 0.0; 31 | 32 | return mpn_get_d (PTR (z), ABS (size), size, 0L); 33 | } 34 | -------------------------------------------------------------------------------- /mpf/set_prc_raw.c: -------------------------------------------------------------------------------- 1 | /* mpf_set_prec_raw(x,bits) -- Change the precision of x without changing 2 | allocation. For proper operation, the original precision need to be reset 3 | sooner or later. 4 | 5 | Copyright 1996, 2001 Free Software Foundation, Inc. 6 | 7 | This file is part of the GNU MP Library. 8 | 9 | The GNU MP Library is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published by 11 | the Free Software Foundation; either version 3 of the License, or (at your 12 | option) any later version. 13 | 14 | The GNU MP Library is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 17 | License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | 25 | void 26 | mpf_set_prec_raw (mpf_ptr x, mp_bitcnt_t prec_in_bits) 27 | { 28 | x->_mp_prec = __GMPF_BITS_TO_PREC (prec_in_bits); 29 | } 30 | -------------------------------------------------------------------------------- /mpn/cray/hamdist.c: -------------------------------------------------------------------------------- 1 | /* Cray mpn_hamdist -- hamming distance count. 2 | 3 | Copyright 2000 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | unsigned long int 25 | mpn_hamdist (mp_srcptr p1, mp_srcptr p2, mp_size_t n) 26 | { 27 | unsigned long int result = 0; 28 | mp_size_t i; 29 | for (i = 0; i < n; i++) 30 | result += _popcnt (p1[i] ^ p2[i]); 31 | return result; 32 | } 33 | -------------------------------------------------------------------------------- /mpz/iset_d.c: -------------------------------------------------------------------------------- 1 | /* mpz_init_set_d(integer, val) -- Initialize and assign INTEGER with a double 2 | value VAL. 3 | 4 | Copyright 1996, 2000, 2001 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | void 25 | mpz_init_set_d (mpz_ptr dest, double val) 26 | { 27 | dest->_mp_alloc = 1; 28 | dest->_mp_d = (mp_ptr) (*__gmp_allocate_func) (BYTES_PER_MP_LIMB); 29 | dest->_mp_size = 0; 30 | mpz_set_d (dest, val); 31 | } 32 | -------------------------------------------------------------------------------- /mpz/divis.c: -------------------------------------------------------------------------------- 1 | /* mpz_divisible_p -- mpz by mpz divisibility test 2 | 3 | Copyright 2001, 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | int 24 | mpz_divisible_p (mpz_srcptr a, mpz_srcptr d) 25 | { 26 | mp_size_t dsize = SIZ(d); 27 | mp_size_t asize = SIZ(a); 28 | 29 | if (UNLIKELY (dsize == 0)) 30 | return (asize == 0); 31 | 32 | return mpn_divisible_p (PTR(a), ABS(asize), PTR(d), ABS(dsize)); 33 | } 34 | -------------------------------------------------------------------------------- /printf/vprintf.c: -------------------------------------------------------------------------------- 1 | /* gmp_vprintf -- formatted output. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "config.h" 21 | 22 | #if HAVE_STDARG 23 | #include 24 | #else 25 | #include 26 | #endif 27 | 28 | #include 29 | 30 | #include "gmp.h" 31 | #include "gmp-impl.h" 32 | 33 | 34 | int 35 | gmp_vprintf (const char *fmt, va_list ap) 36 | { 37 | return __gmp_doprnt (&__gmp_fprintf_funs, stdout, fmt, ap); 38 | } 39 | -------------------------------------------------------------------------------- /scanf/vscanf.c: -------------------------------------------------------------------------------- 1 | /* gmp_vscanf -- formatted input from stdin. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "config.h" 21 | 22 | #if HAVE_STDARG 23 | #include 24 | #else 25 | #include 26 | #endif 27 | 28 | #include 29 | 30 | #include "gmp.h" 31 | #include "gmp-impl.h" 32 | 33 | 34 | int 35 | gmp_vscanf (const char *fmt, va_list ap) 36 | { 37 | return __gmp_doscan (&__gmp_fscanf_funs, stdin, fmt, ap); 38 | } 39 | -------------------------------------------------------------------------------- /printf/vfprintf.c: -------------------------------------------------------------------------------- 1 | /* gmp_vfprintf -- formatted output. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "config.h" 21 | 22 | #if HAVE_STDARG 23 | #include 24 | #else 25 | #include 26 | #endif 27 | 28 | #include 29 | 30 | #include "gmp.h" 31 | #include "gmp-impl.h" 32 | 33 | 34 | int 35 | gmp_vfprintf (FILE *fp, const char *fmt, va_list ap) 36 | { 37 | return __gmp_doprnt (&__gmp_fprintf_funs, fp, fmt, ap); 38 | } 39 | -------------------------------------------------------------------------------- /randsdui.c: -------------------------------------------------------------------------------- 1 | /* gmp_randseed_ui (state, seed) -- Set initial seed SEED in random 2 | state STATE. 3 | 4 | Copyright 2000, 2002 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | void 25 | gmp_randseed_ui (gmp_randstate_t rstate, 26 | unsigned long int seed) 27 | { 28 | mpz_t zseed; 29 | mp_limb_t zlimbs[LIMBS_PER_ULONG]; 30 | 31 | MPZ_FAKE_UI (zseed, zlimbs, seed); 32 | gmp_randseed (rstate, zseed); 33 | } 34 | -------------------------------------------------------------------------------- /mpf/init.c: -------------------------------------------------------------------------------- 1 | /* mpf_init() -- Make a new multiple precision number with value 0. 2 | 3 | Copyright 1993, 1994, 1995, 2000, 2001, 2004 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpf_init (mpf_ptr r) 25 | { 26 | mp_size_t prec = __gmp_default_fp_limb_precision; 27 | r->_mp_size = 0; 28 | r->_mp_exp = 0; 29 | r->_mp_prec = prec; 30 | r->_mp_d = (mp_ptr) (*__gmp_allocate_func) ((prec + 1) * BYTES_PER_MP_LIMB); 31 | } 32 | -------------------------------------------------------------------------------- /mpn/x86/p6/mmx/popham.asm: -------------------------------------------------------------------------------- 1 | dnl Intel Pentium-II mpn_popcount, mpn_hamdist -- population count and 2 | dnl hamming distance. 3 | 4 | dnl Copyright 2000, 2002 Free Software Foundation, Inc. 5 | dnl 6 | dnl This file is part of the GNU MP Library. 7 | dnl 8 | dnl The GNU MP Library is free software; you can redistribute it and/or 9 | dnl modify it under the terms of the GNU Lesser General Public License as 10 | dnl published by the Free Software Foundation; either version 3 of the 11 | dnl License, or (at your option) any later version. 12 | dnl 13 | dnl The GNU MP Library is distributed in the hope that it will be useful, 14 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | dnl Lesser General Public License for more details. 17 | dnl 18 | dnl You should have received a copy of the GNU Lesser General Public License 19 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 20 | 21 | include(`../config.m4') 22 | 23 | 24 | C P6MMX: popcount 11 cycles/limb (approx), hamdist 11.5 cycles/limb (approx) 25 | 26 | 27 | MULFUNC_PROLOGUE(mpn_popcount mpn_hamdist) 28 | include_mpn(`x86/k6/mmx/popham.asm') 29 | -------------------------------------------------------------------------------- /scanf/vfscanf.c: -------------------------------------------------------------------------------- 1 | /* gmp_vfscanf -- formatted input from a FILE. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "config.h" 21 | 22 | #if HAVE_STDARG 23 | #include 24 | #else 25 | #include 26 | #endif 27 | 28 | #include 29 | 30 | #include "gmp.h" 31 | #include "gmp-impl.h" 32 | 33 | 34 | int 35 | gmp_vfscanf (FILE *fp, const char *fmt, va_list ap) 36 | { 37 | return __gmp_doscan (&__gmp_fscanf_funs, fp, fmt, ap); 38 | } 39 | -------------------------------------------------------------------------------- /mpn/x86/gmp-mparam.h: -------------------------------------------------------------------------------- 1 | /* Generic x86 gmp-mparam.h -- Compiler/machine parameter header file. 2 | 3 | Copyright 1991, 1993, 1994, 2000, 2001, 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define GMP_LIMB_BITS 32 21 | #define BYTES_PER_MP_LIMB 4 22 | 23 | 24 | /* Generic x86 mpn_divexact_1 is faster than generic x86 mpn_divrem_1 on all 25 | of p5, p6, k6 and k7, so use it always. It's probably slower on 386 and 26 | 486, but that's too bad. */ 27 | #define DIVEXACT_1_THRESHOLD 0 28 | -------------------------------------------------------------------------------- /mpf/iset_d.c: -------------------------------------------------------------------------------- 1 | /* mpf_init_set_d -- Initialize a float and assign it from a double. 2 | 3 | Copyright 1993, 1994, 1995, 2000, 2001, 2004 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpf_init_set_d (mpf_ptr r, double val) 25 | { 26 | mp_size_t prec = __gmp_default_fp_limb_precision; 27 | r->_mp_prec = prec; 28 | r->_mp_d = (mp_ptr) (*__gmp_allocate_func) ((prec + 1) * BYTES_PER_MP_LIMB); 29 | 30 | mpf_set_d (r, val); 31 | } 32 | -------------------------------------------------------------------------------- /demos/perl/GMP/Rand.pm: -------------------------------------------------------------------------------- 1 | # GMP random numbers module. 2 | 3 | # Copyright 2001, 2003 Free Software Foundation, Inc. 4 | # 5 | # This file is part of the GNU MP Library. 6 | # 7 | # The GNU MP Library is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU Lesser General Public License as published 9 | # by the Free Software Foundation; either version 3 of the License, or (at 10 | # your option) any later version. 11 | # 12 | # The GNU MP Library is distributed in the hope that it will be useful, but 13 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | # License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public License 18 | # along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | 21 | package GMP::Rand; 22 | 23 | require GMP; 24 | require Exporter; 25 | @ISA = qw(GMP Exporter); 26 | @EXPORT = qw(); 27 | %EXPORT_TAGS = ('all' => [qw( 28 | randstate mpf_urandomb mpz_rrandomb 29 | mpz_urandomb mpz_urandomm gmp_urandomb_ui 30 | gmp_urandomm_ui)]); 31 | Exporter::export_ok_tags('all'); 32 | 1; 33 | __END__ 34 | -------------------------------------------------------------------------------- /mpn/alpha/umul.asm: -------------------------------------------------------------------------------- 1 | dnl mpn_umul_ppmm -- 1x1->2 limb multiplication 2 | 3 | dnl Copyright 1999, 2000, 2002 Free Software Foundation, Inc. 4 | 5 | dnl This file is part of the GNU MP Library. 6 | 7 | dnl The GNU MP Library is free software; you can redistribute it and/or modify 8 | dnl it under the terms of the GNU Lesser General Public License as published 9 | dnl by the Free Software Foundation; either version 3 of the License, or (at 10 | dnl your option) any later version. 11 | 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, but 13 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | dnl License for more details. 16 | 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | C mp_limb_t mpn_umul_ppmm (mp_limb_t *lowptr, mp_limb_t m1, mp_limb_t m2); 24 | C 25 | 26 | ASM_START() 27 | PROLOGUE(mpn_umul_ppmm) 28 | mulq r17, r18, r1 29 | umulh r17, r18, r0 30 | stq r1, 0(r16) 31 | ret r31, (r26), 1 32 | EPILOGUE() 33 | ASM_END() 34 | -------------------------------------------------------------------------------- /mpq/get_den.c: -------------------------------------------------------------------------------- 1 | /* mpq_get_den(den,rat_src) -- Set DEN to the denominator of RAT_SRC. 2 | 3 | Copyright 1991, 1994, 1995, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpq_get_den (MP_INT *den, const MP_RAT *src) 25 | { 26 | mp_size_t size = src->_mp_den._mp_size; 27 | 28 | if (den->_mp_alloc < size) 29 | _mpz_realloc (den, size); 30 | 31 | MPN_COPY (den->_mp_d, src->_mp_den._mp_d, size); 32 | den->_mp_size = size; 33 | } 34 | -------------------------------------------------------------------------------- /tune/divrem1inv.c: -------------------------------------------------------------------------------- 1 | /* mpn/generic/divrem_1.c forced to use mul-by-inverse udiv_qrnnd_preinv. 2 | 3 | Copyright 2000, 2003 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define OPERATION_divrem_1 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | 25 | #undef DIVREM_1_NORM_THRESHOLD 26 | #undef DIVREM_1_UNNORM_THRESHOLD 27 | #define DIVREM_1_NORM_THRESHOLD 0 28 | #define DIVREM_1_UNNORM_THRESHOLD 0 29 | #define __gmpn_divrem_1 mpn_divrem_1_inv 30 | 31 | #include "mpn/generic/divrem_1.c" 32 | -------------------------------------------------------------------------------- /tune/hppa.asm: -------------------------------------------------------------------------------- 1 | dnl HPPA 32-bit time stamp counter access routine. 2 | 3 | dnl Copyright 2000, 2002, 2005 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | dnl void speed_cyclecounter (unsigned p[2]); 23 | dnl 24 | dnl Get the HPPA interval timer. 25 | 26 | PROLOGUE(speed_cyclecounter) 27 | mfctl %cr16,%r28 28 | stw %r28,0(0,%r26) 29 | bv 0(%r2) 30 | stw %r0,4(0,%r26) 31 | EPILOGUE(speed_cyclecounter) 32 | -------------------------------------------------------------------------------- /tune/divrem1div.c: -------------------------------------------------------------------------------- 1 | /* mpn/generic/divrem_1.c forced to use plain udiv_qrnnd. 2 | 3 | Copyright 2000, 2003 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define OPERATION_divrem_1 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | 25 | #undef DIVREM_1_NORM_THRESHOLD 26 | #undef DIVREM_1_UNNORM_THRESHOLD 27 | #define DIVREM_1_NORM_THRESHOLD MP_SIZE_T_MAX 28 | #define DIVREM_1_UNNORM_THRESHOLD MP_SIZE_T_MAX 29 | #define __gmpn_divrem_1 mpn_divrem_1_div 30 | 31 | #include "mpn/generic/divrem_1.c" 32 | -------------------------------------------------------------------------------- /tune/powerpc64.asm: -------------------------------------------------------------------------------- 1 | dnl PowerPC mftb_function -- read time base registers, 64-bit integer. 2 | 3 | dnl Copyright 2002, 2003, 2004 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundationn; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | C void mftb_function (unsigned a[2]); 24 | C 25 | 26 | ASM_START() 27 | PROLOGUE(mftb_function) 28 | 29 | C r3 a 30 | 31 | mftb r5 32 | 33 | srdi r4, r5, 32 34 | stw r5, 0(r3) 35 | stw r4, 4(r3) 36 | blr 37 | 38 | EPILOGUE() 39 | -------------------------------------------------------------------------------- /demos/calc/calc-common.h: -------------------------------------------------------------------------------- 1 | /* Prototypes etc for calc program. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | This program is free software; you can redistribute it and/or modify it under 8 | the terms of the GNU General Public License as published by the Free Software 9 | Foundation; either version 3 of the License, or (at your option) any later 10 | version. 11 | 12 | This program is distributed in the hope that it will be useful, but WITHOUT ANY 13 | WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 | PARTICULAR PURPOSE. See the GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License along with 17 | this program. If not, see http://www.gnu.org/licenses/. */ 18 | 19 | #include /* for size_t */ 20 | #ifndef NO_CALC_H 21 | #include "calc.h" 22 | #endif 23 | #include "calc-config.h" 24 | 25 | struct calc_keywords_t { 26 | char *name; 27 | int value; 28 | }; 29 | 30 | extern int calc_option_readline; 31 | extern int calc_more_input; 32 | extern const struct calc_keywords_t calc_keywords[]; 33 | 34 | int calc_input (char *buf, size_t max_size); 35 | void calc_init_readline (void); 36 | -------------------------------------------------------------------------------- /mpn/x86/pentium/mmx/hamdist.asm: -------------------------------------------------------------------------------- 1 | dnl Intel P55 mpn_hamdist -- mpn hamming distance. 2 | 3 | dnl Copyright 2000, 2002 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | C P55: hamdist 12.0 cycles/limb 24 | 25 | C For reference, this code runs at 11.5 cycles/limb for popcount, which is 26 | C slower than the plain integer mpn/x86/pentium/popcount.asm. 27 | 28 | MULFUNC_PROLOGUE(mpn_hamdist) 29 | include_mpn(`x86/k6/mmx/popham.asm') 30 | -------------------------------------------------------------------------------- /mpf/init2.c: -------------------------------------------------------------------------------- 1 | /* mpf_init2() -- Make a new multiple precision number with value 0. 2 | 3 | Copyright 1993, 1994, 1995, 2000, 2001, 2004 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpf_init2 (mpf_ptr r, mp_bitcnt_t prec_in_bits) 25 | { 26 | mp_size_t prec; 27 | 28 | prec = __GMPF_BITS_TO_PREC (prec_in_bits); 29 | r->_mp_size = 0; 30 | r->_mp_exp = 0; 31 | r->_mp_prec = prec; 32 | r->_mp_d = (mp_ptr) (*__gmp_allocate_func) ((prec + 1) * BYTES_PER_MP_LIMB); 33 | } 34 | -------------------------------------------------------------------------------- /mpn/cray/cfp/mul_1.c: -------------------------------------------------------------------------------- 1 | /* mpn_mul_1 for Cray PVP. 2 | 3 | Copyright 1996, 2000, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | mp_limb_t 25 | mpn_mul_1 (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_limb_t limb) 26 | { 27 | mp_limb_t p0[n], p1[n]; 28 | mp_limb_t cy_limb; 29 | 30 | GMPN_MULWW (p1, p0, up, &n, &limb); 31 | rp[0] = p0[0]; 32 | cy_limb = p1[n - 1]; 33 | if (n != 1) 34 | cy_limb += mpn_add_n (rp + 1, p0 + 1, p1, n - 1); 35 | 36 | return cy_limb; 37 | } 38 | -------------------------------------------------------------------------------- /mpz/sizeinbase.c: -------------------------------------------------------------------------------- 1 | /* mpz_sizeinbase(x, base) -- return an approximation to the number of 2 | character the integer X would have printed in base BASE. The 3 | approximation is never too small. 4 | 5 | Copyright 1991, 1993, 1994, 1995, 2001, 2002 Free Software Foundation, Inc. 6 | 7 | This file is part of the GNU MP Library. 8 | 9 | The GNU MP Library is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU Lesser General Public License as published by 11 | the Free Software Foundation; either version 3 of the License, or (at your 12 | option) any later version. 13 | 14 | The GNU MP Library is distributed in the hope that it will be useful, but 15 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 16 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 17 | License for more details. 18 | 19 | You should have received a copy of the GNU Lesser General Public License 20 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | #include "longlong.h" 25 | 26 | size_t 27 | mpz_sizeinbase (mpz_srcptr x, int base) 28 | { 29 | size_t result; 30 | MPN_SIZEINBASE (result, PTR(x), ABSIZ(x), base); 31 | return result; 32 | } 33 | -------------------------------------------------------------------------------- /rands.c: -------------------------------------------------------------------------------- 1 | /* __gmp_rands -- global random state for old-style random functions. 2 | 3 | EVERYTHING IN THIS FILE IS FOR INTERNAL USE ONLY. IT'S ALMOST CERTAIN TO 4 | BE SUBJECT TO INCOMPATIBLE CHANGES OR DISAPPEAR COMPLETELY IN FUTURE GNU 5 | MP RELEASES. */ 6 | 7 | /* 8 | Copyright 2001 Free Software Foundation, Inc. 9 | 10 | This file is part of the GNU MP Library. 11 | 12 | The GNU MP Library is free software; you can redistribute it and/or modify 13 | it under the terms of the GNU Lesser General Public License as published by 14 | the Free Software Foundation; either version 3 of the License, or (at your 15 | option) any later version. 16 | 17 | The GNU MP Library is distributed in the hope that it will be useful, but 18 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 19 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 20 | License for more details. 21 | 22 | You should have received a copy of the GNU Lesser General Public License 23 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 24 | 25 | #include "gmp.h" 26 | #include "gmp-impl.h" 27 | 28 | 29 | /* Use this via the RANDS macro in gmp-impl.h */ 30 | char __gmp_rands_initialized = 0; 31 | gmp_randstate_t __gmp_rands; 32 | -------------------------------------------------------------------------------- /tune/ia64.asm: -------------------------------------------------------------------------------- 1 | dnl IA-64 time stamp counter access routine. 2 | 3 | dnl Copyright 2000, 2005 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | C void speed_cyclecounter (unsigned int p[2]); 24 | C 25 | 26 | ASM_START() 27 | PROLOGUE(speed_cyclecounter) 28 | mov r14 = ar.itc 29 | ;; 30 | st4 [r32] = r14, 4 31 | shr.u r14 = r14, 32 32 | ;; 33 | st4 [r32] = r14 34 | br.ret.sptk.many b0 35 | EPILOGUE(speed_cyclecounter) 36 | ASM_END() 37 | -------------------------------------------------------------------------------- /tune/powerpc.asm: -------------------------------------------------------------------------------- 1 | dnl PowerPC mftb_function -- read time base registers. 2 | 3 | dnl Copyright 2002 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundationn; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | C void mftb_function (unsigned a[2]); 24 | C 25 | 26 | ASM_START() 27 | PROLOGUE(mftb_function) 28 | 29 | C r3 a 30 | 31 | L(again): 32 | mftbu r4 33 | mftb r5 34 | mftbu r6 35 | cmpw cr0, r4, r6 36 | bne L(again) 37 | 38 | stw r5, 0(r3) 39 | stw r4, 4(r3) 40 | blr 41 | 42 | EPILOGUE() 43 | -------------------------------------------------------------------------------- /mpn/x86/p6/p3mmx/popham.asm: -------------------------------------------------------------------------------- 1 | dnl Intel Pentium-III mpn_popcount, mpn_hamdist -- population count and 2 | dnl hamming distance. 3 | 4 | dnl Copyright 2000, 2002, 2004, 2007 Free Software Foundation, Inc. 5 | dnl 6 | dnl This file is part of the GNU MP Library. 7 | dnl 8 | dnl The GNU MP Library is free software; you can redistribute it and/or 9 | dnl modify it under the terms of the GNU Lesser General Public License as 10 | dnl published by the Free Software Foundation; either version 3 of the 11 | dnl License, or (at your option) any later version. 12 | dnl 13 | dnl The GNU MP Library is distributed in the hope that it will be useful, 14 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | dnl Lesser General Public License for more details. 17 | dnl 18 | dnl You should have received a copy of the GNU Lesser General Public License 19 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 20 | 21 | include(`../config.m4') 22 | 23 | 24 | C popcount hamdist 25 | C P3 generic 6.5 7 26 | C P3 model 9 (Banias) ? ? 27 | C P3 model 13 (Dothan) 5.75 6 28 | 29 | 30 | MULFUNC_PROLOGUE(mpn_popcount mpn_hamdist) 31 | include_mpn(`x86/k7/mmx/popham.asm') 32 | -------------------------------------------------------------------------------- /mpz/init.c: -------------------------------------------------------------------------------- 1 | /* mpz_init() -- Make a new multiple precision number with value 0. 2 | 3 | Copyright 1991, 1993, 1994, 1995, 2000, 2001, 2002 Free Software Foundation, 4 | Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | void 25 | mpz_init (mpz_ptr x) 26 | { 27 | x->_mp_alloc = 1; 28 | x->_mp_d = (mp_ptr) (*__gmp_allocate_func) (BYTES_PER_MP_LIMB); 29 | x->_mp_size = 0; 30 | 31 | #ifdef __CHECKER__ 32 | /* let the low limb look initialized, for the benefit of mpz_get_ui etc */ 33 | x->_mp_d[0] = 0; 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /mpf/sub_ui.c: -------------------------------------------------------------------------------- 1 | /* mpf_sub_ui -- Subtract an unsigned integer from a float. 2 | 3 | Copyright 1993, 1994, 1996, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpf_sub_ui (mpf_ptr sum, mpf_srcptr u, unsigned long int v) 25 | { 26 | __mpf_struct vv; 27 | mp_limb_t vl; 28 | 29 | if (v == 0) 30 | { 31 | mpf_set (sum, u); 32 | return; 33 | } 34 | 35 | vl = v; 36 | vv._mp_size = 1; 37 | vv._mp_d = &vl; 38 | vv._mp_exp = 1; 39 | mpf_sub (sum, u, &vv); 40 | } 41 | -------------------------------------------------------------------------------- /mpn/m68k/mc68020/umul.asm: -------------------------------------------------------------------------------- 1 | dnl mc68020 mpn_umul_ppmm -- limb by limb multiplication 2 | 3 | dnl Copyright 1999, 2000, 2001 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | C mp_limb_t mpn_umul_ppmm (mp_limb_t *lp, mp_limb_t x, mp_limb_t y); 24 | C 25 | 26 | PROLOGUE(mpn_umul_ppmm) 27 | movel M(sp,4), a0 C lp 28 | movel M(sp,8), d1 C x 29 | movel M(sp,12), d0 C y 30 | mulul d0, d0:d1 31 | movel d1, M(a0) C low 32 | rts 33 | EPILOGUE(mpn_umul_ppmm) 34 | -------------------------------------------------------------------------------- /mpq/get_num.c: -------------------------------------------------------------------------------- 1 | /* mpq_get_num(num,rat_src) -- Set NUM to the numerator of RAT_SRC. 2 | 3 | Copyright 1991, 1994, 1995, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpq_get_num (MP_INT *num, const MP_RAT *src) 25 | { 26 | mp_size_t size = src->_mp_num._mp_size; 27 | mp_size_t abs_size = ABS (size); 28 | 29 | if (num->_mp_alloc < abs_size) 30 | _mpz_realloc (num, abs_size); 31 | 32 | MPN_COPY (num->_mp_d, src->_mp_num._mp_d, abs_size); 33 | num->_mp_size = size; 34 | } 35 | -------------------------------------------------------------------------------- /tune/sparcv9.asm: -------------------------------------------------------------------------------- 1 | dnl Sparc v9 32-bit time stamp counter access routine. 2 | 3 | dnl Copyright 2000, 2005 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | C void speed_cyclecounter (unsigned p[2]); 24 | C 25 | C Get the sparc v9 tick counter. 26 | 27 | ASM_START() 28 | PROLOGUE(speed_cyclecounter) 29 | rd %tick,%g1 30 | st %g1,[%o0] C low 32 bits 31 | srlx %g1,32,%g4 32 | retl 33 | st %g4,[%o0+4] C high 32 bits 34 | EPILOGUE(speed_cyclecounter) 35 | -------------------------------------------------------------------------------- /mpn/powerpc32/umul.asm: -------------------------------------------------------------------------------- 1 | dnl PowerPC-32 umul_ppmm -- support for longlong.h 2 | 3 | dnl Copyright 2000, 2001 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 15 | dnl General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | C mp_limb_t mpn_umul_ppmm (mp_limb_t *lowptr, mp_limb_t m1, mp_limb_t m2); 24 | C 25 | 26 | ASM_START() 27 | PROLOGUE(mpn_umul_ppmm) 28 | 29 | C r3 lowptr 30 | C r4 m1 31 | C r5 m2 32 | 33 | mullw r0, r4, r5 34 | mulhwu r9, r4, r5 35 | stw r0, 0(r3) 36 | mr r3, r9 37 | blr 38 | 39 | EPILOGUE(mpn_umul_ppmm) 40 | -------------------------------------------------------------------------------- /mpf/get_d.c: -------------------------------------------------------------------------------- 1 | /* double mpf_get_d (mpf_t src) -- return SRC truncated to a double. 2 | 3 | Copyright 1996, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | double 24 | mpf_get_d (mpf_srcptr src) 25 | { 26 | mp_size_t size, abs_size; 27 | long exp; 28 | 29 | size = SIZ (src); 30 | if (UNLIKELY (size == 0)) 31 | return 0.0; 32 | 33 | abs_size = ABS (size); 34 | exp = (EXP (src) - abs_size) * GMP_NUMB_BITS; 35 | return mpn_get_d (PTR (src), abs_size, size, exp); 36 | } 37 | -------------------------------------------------------------------------------- /mpf/iset_str.c: -------------------------------------------------------------------------------- 1 | /* mpf_init_set_str -- Initialize a float and assign it from a string. 2 | 3 | Copyright 1995, 1996, 2000, 2001, 2004 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | int 24 | mpf_init_set_str (mpf_ptr r, const char *s, int base) 25 | { 26 | mp_size_t prec = __gmp_default_fp_limb_precision; 27 | r->_mp_size = 0; 28 | r->_mp_exp = 0; 29 | r->_mp_prec = prec; 30 | r->_mp_d = (mp_ptr) (*__gmp_allocate_func) ((prec + 1) * BYTES_PER_MP_LIMB); 31 | 32 | return mpf_set_str (r, s, base); 33 | } 34 | -------------------------------------------------------------------------------- /mpf/set_ui.c: -------------------------------------------------------------------------------- 1 | /* mpf_set_ui() -- Assign a float from an unsigned int. 2 | 3 | Copyright 1993, 1994, 1995, 2001, 2002, 2004 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpf_set_ui (mpf_ptr f, unsigned long val) 25 | { 26 | mp_size_t size; 27 | 28 | f->_mp_d[0] = val & GMP_NUMB_MASK; 29 | size = val != 0; 30 | 31 | #if BITS_PER_ULONG > GMP_NUMB_BITS 32 | val >>= GMP_NUMB_BITS; 33 | f->_mp_d[1] = val; 34 | size += (val != 0); 35 | #endif 36 | 37 | f->_mp_exp = f->_mp_size = size; 38 | } 39 | -------------------------------------------------------------------------------- /tests/devel/README: -------------------------------------------------------------------------------- 1 | Copyright 2000, 2001 Free Software Foundation, Inc. 2 | 3 | This file is part of the GNU MP Library. 4 | 5 | The GNU MP Library is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU Lesser General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or (at your 8 | option) any later version. 9 | 10 | The GNU MP Library is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | License for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License 16 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 17 | 18 | 19 | 20 | 21 | DEVELOPMENT TEST PROGRAMS 22 | 23 | 24 | This directory contains various programs used during development. Casual 25 | GMP users are unlikely to find anything of interest. 26 | 27 | Nothing here is built or installed, nor even run in a "make check", but 28 | there's Makefile rules to build each program, or "allprogs" to build 29 | everything. 30 | 31 | 32 | 33 | ---------------- 34 | Local variables: 35 | mode: text 36 | fill-column: 76 37 | End: 38 | -------------------------------------------------------------------------------- /tune/hppa2.asm: -------------------------------------------------------------------------------- 1 | dnl HPPA 64-bit time stamp counter access routine. 2 | 3 | dnl Copyright 2000, 2002, 2005 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | dnl void speed_cyclecounter (unsigned p[2]); 23 | dnl 24 | dnl Get the HPPA interval timer. 25 | 26 | .level 2.0 27 | PROLOGUE(speed_cyclecounter) 28 | mfctl %cr16,%r28 29 | stw %r28,0(0,%r26) ; low word 30 | extrd,u %r28,31,32,%r28 31 | bve (%r2) 32 | stw %r28,4(0,%r26) ; high word 33 | EPILOGUE(speed_cyclecounter) 34 | -------------------------------------------------------------------------------- /mpq/set_num.c: -------------------------------------------------------------------------------- 1 | /* mpq_set_num(dest,num) -- Set the numerator of DEST from NUM. 2 | 3 | Copyright 1991, 1994, 1995, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpq_set_num (MP_RAT *dest, const MP_INT *num) 25 | { 26 | mp_size_t size = num->_mp_size; 27 | mp_size_t abs_size = ABS (size); 28 | 29 | if (dest->_mp_num._mp_alloc < abs_size) 30 | _mpz_realloc (&(dest->_mp_num), abs_size); 31 | 32 | MPN_COPY (dest->_mp_num._mp_d, num->_mp_d, abs_size); 33 | dest->_mp_num._mp_size = size; 34 | } 35 | -------------------------------------------------------------------------------- /tune/hppa2w.asm: -------------------------------------------------------------------------------- 1 | dnl HPPA 64-bit time stamp counter access routine. 2 | 3 | dnl Copyright 2000, 2002, 2005 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | dnl void speed_cyclecounter (unsigned p[2]); 23 | dnl 24 | dnl Get the HPPA interval timer. 25 | 26 | .level 2.0w 27 | PROLOGUE(speed_cyclecounter) 28 | mfctl %cr16,%r28 29 | stw %r28,0(0,%r26) ; low word 30 | extrd,u %r28,31,32,%r28 31 | bve (%r2) 32 | stw %r28,4(0,%r26) ; high word 33 | EPILOGUE(speed_cyclecounter) 34 | -------------------------------------------------------------------------------- /tune/set_strp.c: -------------------------------------------------------------------------------- 1 | /* mpn_set_str_subquad -- mpn_set_str forced to the sub-quadratic case. 2 | 3 | Copyright 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define TUNE_PROGRAM_BUILD 1 /* for gmp-impl.h */ 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | 25 | void 26 | mpn_pre_set_str (mp_ptr wp, unsigned char *str, size_t str_len, powers_t *powtab, mp_ptr tp) 27 | { 28 | if (BELOW_THRESHOLD (str_len, set_str_dc_threshold)) 29 | mpn_bc_set_str (wp, str, str_len, powtab->base); 30 | else 31 | mpn_dc_set_str (wp, str, str_len, powtab, tp); 32 | } 33 | -------------------------------------------------------------------------------- /mpq/set_den.c: -------------------------------------------------------------------------------- 1 | /* mpq_set_den(dest,den) -- Set the denominator of DEST from DEN. 2 | 3 | Copyright 1991, 1994, 1995, 1996, 2000, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpq_set_den (MP_RAT *dest, const MP_INT *den) 25 | { 26 | mp_size_t size = den->_mp_size; 27 | mp_size_t abs_size = ABS (size); 28 | 29 | if (dest->_mp_den._mp_alloc < abs_size) 30 | _mpz_realloc (&(dest->_mp_den), abs_size); 31 | 32 | MPN_COPY (dest->_mp_den._mp_d, den->_mp_d, abs_size); 33 | dest->_mp_den._mp_size = size; 34 | } 35 | -------------------------------------------------------------------------------- /mpn/pyr/mul_1.s: -------------------------------------------------------------------------------- 1 | # Pyramid __gmpn_mul_1 -- Multiply a limb vector with a limb and store 2 | # the result in a second limb vector. 3 | 4 | # Copyright 1995, 2000 Free Software Foundation, Inc. 5 | 6 | # This file is part of the GNU MP Library. 7 | 8 | # The GNU MP Library is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU Lesser General Public License as published by 10 | # the Free Software Foundation; either version 3 of the License, or (at your 11 | # option) any later version. 12 | 13 | # The GNU MP Library is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | # License for more details. 17 | 18 | # You should have received a copy of the GNU Lesser General Public License 19 | # along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 20 | 21 | .text 22 | .align 2 23 | .globl ___gmpn_mul_1 24 | ___gmpn_mul_1: 25 | mova (pr0)[pr2*4],pr0 26 | mova (pr1)[pr2*4],pr1 27 | mnegw pr2,pr2 28 | movw $0,tr3 29 | 30 | Loop: movw (pr1)[pr2*4],tr1 31 | uemul pr3,tr0 32 | addw tr3,tr1 33 | movw $0,tr3 34 | addwc tr0,tr3 35 | movw tr1,(pr0)[pr2*4] 36 | addw $1,pr2 37 | bne Loop 38 | 39 | movw tr3,pr0 40 | ret 41 | -------------------------------------------------------------------------------- /mpn/pa32/hppa1_1/umul.asm: -------------------------------------------------------------------------------- 1 | dnl Copyright 1999, 2001 Free Software Foundation, Inc. 2 | 3 | dnl This file is part of the GNU MP Library. 4 | 5 | dnl The GNU MP Library is free software; you can redistribute it and/or modify 6 | dnl it under the terms of the GNU Lesser General Public License as published 7 | dnl by the Free Software Foundation; either version 3 of the License, or (at 8 | dnl your option) any later version. 9 | 10 | dnl The GNU MP Library is distributed in the hope that it will be useful, but 11 | dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 | dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 13 | dnl License for more details. 14 | 15 | dnl You should have received a copy of the GNU Lesser General Public License 16 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 17 | 18 | include(`../config.m4') 19 | 20 | ASM_START() 21 | PROLOGUE(mpn_umul_ppmm) 22 | C .callinfo frame=64,no_calls 23 | 24 | ldo 64(%r30),%r30 25 | stw %r25,-16(0,%r30) 26 | fldws -16(0,%r30),%fr22R 27 | stw %r24,-16(0,%r30) 28 | fldws -16(0,%r30),%fr22L 29 | xmpyu %fr22R,%fr22L,%fr22 30 | fstds %fr22,-16(0,%r30) 31 | ldw -16(0,%r30),%r28 32 | ldw -12(0,%r30),%r29 33 | stw %r29,0(0,%r26) 34 | bv 0(%r2) 35 | ldo -64(%r30),%r30 36 | EPILOGUE() 37 | -------------------------------------------------------------------------------- /mpn/cray/cfp/addmul_1.c: -------------------------------------------------------------------------------- 1 | /* mpn_addmul_1 for Cray PVP. 2 | 3 | Copyright 1996, 2000, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | mp_limb_t 25 | mpn_addmul_1 (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_limb_t limb) 26 | { 27 | mp_limb_t p0[n], p1[n], tp[n]; 28 | mp_limb_t cy_limb; 29 | 30 | GMPN_MULWW (p1, p0, up, &n, &limb); 31 | cy_limb = mpn_add_n (tp, rp, p0, n); 32 | rp[0] = tp[0]; 33 | if (n != 1) 34 | cy_limb += mpn_add_n (rp + 1, tp + 1, p1, n - 1); 35 | cy_limb += p1[n - 1]; 36 | 37 | return cy_limb; 38 | } 39 | -------------------------------------------------------------------------------- /mpn/cray/cfp/submul_1.c: -------------------------------------------------------------------------------- 1 | /* mpn_submul_1 for Cray PVP. 2 | 3 | Copyright 1996, 2000, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | mp_limb_t 25 | mpn_submul_1 (mp_ptr rp, mp_srcptr up, mp_size_t n, mp_limb_t limb) 26 | { 27 | mp_limb_t p0[n], p1[n], tp[n]; 28 | mp_limb_t cy_limb; 29 | 30 | GMPN_MULWW (p1, p0, up, &n, &limb); 31 | cy_limb = mpn_sub_n (tp, rp, p0, n); 32 | rp[0] = tp[0]; 33 | if (n != 1) 34 | cy_limb += mpn_sub_n (rp + 1, tp + 1, p1, n - 1); 35 | cy_limb += p1[n - 1]; 36 | 37 | return cy_limb; 38 | } 39 | -------------------------------------------------------------------------------- /mpn/m68k/mc68020/udiv.asm: -------------------------------------------------------------------------------- 1 | dnl mc68020 mpn_udiv_qrnnd -- 2x1 limb division 2 | 3 | dnl Copyright 1999, 2000, 2001 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | C mp_limb_t mpn_udiv_qrnnd (mp_limb_t *rp, 24 | C mp_limb_t nh, mp_limb_t nl, mp_limb_t d); 25 | C 26 | 27 | PROLOGUE(mpn_udiv_qrnnd) 28 | movel M(sp,4), a0 C rp 29 | movel M(sp,8), d1 C nh 30 | movel M(sp,12), d0 C nl 31 | divul M(sp,16), d1:d0 32 | movel d1, M(a0) C r 33 | rts 34 | EPILOGUE(mpn_udiv_qrnnd) 35 | -------------------------------------------------------------------------------- /printf/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to generate Makefile.in 2 | 3 | # Copyright 2001, 2002 Free Software Foundation, Inc. 4 | # 5 | # This file is part of the GNU MP Library. 6 | # 7 | # The GNU MP Library is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU Lesser General Public License as published by 9 | # the Free Software Foundation; either version 3 of the License, or (at your 10 | # option) any later version. 11 | # 12 | # The GNU MP Library is distributed in the hope that it will be useful, but 13 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | # License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public License 18 | # along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | 21 | INCLUDES = -D__GMP_WITHIN_GMP -I$(top_srcdir) 22 | 23 | noinst_LTLIBRARIES = libprintf.la 24 | 25 | libprintf_la_SOURCES = \ 26 | asprintf.c asprntffuns.c doprnt.c doprntf.c doprnti.c \ 27 | fprintf.c obprintf.c obvprintf.c obprntffuns.c \ 28 | printf.c printffuns.c snprintf.c snprntffuns.c sprintf.c sprintffuns.c \ 29 | vasprintf.c vfprintf.c vprintf.c vsnprintf.c vsprintf.c \ 30 | repl-vsnprintf.c 31 | -------------------------------------------------------------------------------- /mpn/powerpc64/umul.asm: -------------------------------------------------------------------------------- 1 | dnl PowerPC-64 umul_ppmm -- support for longlong.h 2 | 3 | dnl Copyright 2000, 2001, 2005 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 15 | dnl General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | C mp_limb_t mpn_umul_ppmm (mp_limb_t *lowptr, mp_limb_t m1, mp_limb_t m2); 24 | C 25 | 26 | ASM_START() 27 | PROLOGUE(mpn_umul_ppmm) 28 | 29 | C r3 lowptr 30 | C r4 m1 31 | C r5 m2 32 | 33 | mulld r0, r4, r5 34 | mulhdu r4, r4, r5 35 | std r0, 0(r3) 36 | ifdef(`HAVE_ABI_mode32', 37 | ` srdi r3, r4, 32 38 | ',` mr r3, r4 39 | ') 40 | blr 41 | 42 | EPILOGUE(mpn_umul_ppmm) 43 | -------------------------------------------------------------------------------- /cxx/osmpq.cc: -------------------------------------------------------------------------------- 1 | /* operator<< -- mpq formatted output to an ostream. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include 21 | #include /* for va_list and hence doprnt_funs_t */ 22 | #include 23 | 24 | #include "gmp.h" 25 | #include "gmp-impl.h" 26 | 27 | using namespace std; 28 | 29 | 30 | ostream& 31 | operator<< (ostream &o, mpq_srcptr q) 32 | { 33 | struct doprnt_params_t param; 34 | __gmp_doprnt_params_from_ios (¶m, o); 35 | return __gmp_doprnt_integer_ostream (o, ¶m, 36 | mpq_get_str (NULL, param.base, q)); 37 | } 38 | -------------------------------------------------------------------------------- /cxx/osmpz.cc: -------------------------------------------------------------------------------- 1 | /* operator<< -- mpz formatted output to an ostream. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include 21 | #include /* for va_list and hence doprnt_funs_t */ 22 | #include 23 | 24 | #include "gmp.h" 25 | #include "gmp-impl.h" 26 | 27 | using namespace std; 28 | 29 | 30 | ostream& 31 | operator<< (ostream &o, mpz_srcptr z) 32 | { 33 | struct doprnt_params_t param; 34 | __gmp_doprnt_params_from_ios (¶m, o); 35 | return __gmp_doprnt_integer_ostream (o, ¶m, 36 | mpz_get_str (NULL, param.base, z)); 37 | } 38 | -------------------------------------------------------------------------------- /tests/rand/zdiv_round.c: -------------------------------------------------------------------------------- 1 | /* zdiv_round() -- divide integers, round to nearest */ 2 | 3 | /* 4 | Copyright 1999 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include "gmp.h" 22 | 23 | void 24 | zdiv_round (mpz_t rop, mpz_t n, mpz_t d) 25 | { 26 | mpf_t f_n, f_d; 27 | 28 | mpf_init (f_n); 29 | mpf_init (f_d); 30 | 31 | mpf_set_z (f_d, d); 32 | mpf_set_z (f_n, n); 33 | 34 | mpf_div (f_n, f_n, f_d); 35 | mpf_set_d (f_d, .5); 36 | if (mpf_sgn (f_n) < 0) 37 | mpf_neg (f_d, f_d); 38 | mpf_add (f_n, f_n, f_d); 39 | mpz_set_f (rop, f_n); 40 | 41 | mpf_clear (f_n); 42 | mpf_clear (f_d); 43 | return; 44 | } 45 | -------------------------------------------------------------------------------- /mpf/pow_ui.c: -------------------------------------------------------------------------------- 1 | /* mpf_pow_ui -- Compute b^e. 2 | 3 | Copyright 1998, 1999, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpf_pow_ui (mpf_ptr r, mpf_srcptr b, unsigned long int e) 25 | { 26 | mpf_t b2; 27 | unsigned long int e2; 28 | 29 | mpf_init2 (b2, mpf_get_prec (r)); 30 | mpf_set (b2, b); 31 | mpf_set_ui (r, 1); 32 | 33 | if ((e & 1) != 0) 34 | mpf_set (r, b2); 35 | for (e2 = e >> 1; e2 != 0; e2 >>= 1) 36 | { 37 | mpf_mul (b2, b2, b2); 38 | if ((e2 & 1) != 0) 39 | mpf_mul (r, r, b2); 40 | } 41 | 42 | mpf_clear (b2); 43 | } 44 | -------------------------------------------------------------------------------- /mpz/fib2_ui.c: -------------------------------------------------------------------------------- 1 | /* mpz_fib2_ui -- calculate Fibonacci numbers. 2 | 3 | Copyright 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | 25 | void 26 | mpz_fib2_ui (mpz_ptr fn, mpz_ptr fnsub1, unsigned long n) 27 | { 28 | mp_ptr fp, f1p; 29 | mp_size_t size; 30 | 31 | size = MPN_FIB2_SIZE (n); 32 | MPZ_REALLOC (fn, size); 33 | MPZ_REALLOC (fnsub1, size); 34 | fp = PTR (fn); 35 | f1p = PTR (fnsub1); 36 | 37 | size = mpn_fib2_ui (fp, f1p, n); 38 | 39 | SIZ(fn) = size - (n == 0); 40 | SIZ(fnsub1) = size - (f1p[size-1] == 0); 41 | } 42 | -------------------------------------------------------------------------------- /mpq/Makefile.am: -------------------------------------------------------------------------------- 1 | ## Process this file with automake to generate Makefile.in 2 | 3 | # Copyright 1996, 1998, 2000, 2001, 2002 Free Software Foundation, Inc. 4 | # 5 | # This file is part of the GNU MP Library. 6 | # 7 | # The GNU MP Library is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU Lesser General Public License as published by 9 | # the Free Software Foundation; either version 3 of the License, or (at your 10 | # option) any later version. 11 | # 12 | # The GNU MP Library is distributed in the hope that it will be useful, but 13 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | # License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public License 18 | # along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | 21 | INCLUDES = -D__GMP_WITHIN_GMP -I$(top_srcdir) 22 | 23 | noinst_LTLIBRARIES = libmpq.la 24 | libmpq_la_SOURCES = \ 25 | abs.c aors.c canonicalize.c clear.c clears.c \ 26 | cmp.c cmp_si.c cmp_ui.c div.c equal.c \ 27 | get_d.c get_den.c get_num.c get_str.c \ 28 | init.c inits.c inp_str.c inv.c md_2exp.c mul.c neg.c out_str.c \ 29 | set.c set_den.c set_num.c set_si.c set_str.c set_ui.c set_z.c set_d.c \ 30 | set_f.c swap.c 31 | -------------------------------------------------------------------------------- /mpz/abs.c: -------------------------------------------------------------------------------- 1 | /* mpz_abs(dst, src) -- Assign the absolute value of SRC to DST. 2 | 3 | Copyright 1991, 1993, 1994, 1995, 2001 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define __GMP_FORCE_mpz_abs 1 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | 25 | void 26 | mpz_abs (mpz_ptr w, mpz_srcptr u) 27 | { 28 | mp_ptr wp, up; 29 | mp_size_t size; 30 | 31 | size = ABS (u->_mp_size); 32 | 33 | if (u != w) 34 | { 35 | if (w->_mp_alloc < size) 36 | _mpz_realloc (w, size); 37 | 38 | wp = w->_mp_d; 39 | up = u->_mp_d; 40 | 41 | MPN_COPY (wp, up, size); 42 | } 43 | 44 | w->_mp_size = size; 45 | } 46 | -------------------------------------------------------------------------------- /mpn/generic/random.c: -------------------------------------------------------------------------------- 1 | /* mpn_random -- Generate random numbers. 2 | 3 | Copyright 2001, 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include "gmp.h" 21 | #include "gmp-impl.h" 22 | 23 | void 24 | mpn_random (mp_ptr ptr, mp_size_t size) 25 | { 26 | gmp_randstate_ptr rands; 27 | 28 | /* FIXME: Is size==0 supposed to be allowed? */ 29 | ASSERT (size >= 0); 30 | 31 | if (size == 0) 32 | return; 33 | 34 | rands = RANDS; 35 | _gmp_rand (ptr, rands, size * GMP_NUMB_BITS); 36 | 37 | /* Make sure the most significant limb is non-zero. */ 38 | while (ptr[size-1] == 0) 39 | _gmp_rand (&ptr[size-1], rands, GMP_NUMB_BITS); 40 | } 41 | -------------------------------------------------------------------------------- /tune/mod_1_inv.c: -------------------------------------------------------------------------------- 1 | /* mpn/generic/mod_1.c forced to use mul-by-inverse udiv_qrnnd_preinv. 2 | 3 | Copyright 2000 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define OPERATION_mod_1 21 | 22 | #include "gmp.h" 23 | #include "gmp-impl.h" 24 | 25 | #undef MOD_1_NORM_THRESHOLD 26 | #undef MOD_1_UNNORM_THRESHOLD 27 | #undef MOD_1N_TO_MOD_1_1_THRESHOLD 28 | #undef MOD_1U_TO_MOD_1_1_THRESHOLD 29 | #define MOD_1_NORM_THRESHOLD 0 30 | #define MOD_1_UNNORM_THRESHOLD 0 31 | #define MOD_1N_TO_MOD_1_1_THRESHOLD MP_SIZE_T_MAX 32 | #define MOD_1U_TO_MOD_1_1_THRESHOLD MP_SIZE_T_MAX 33 | #define __gmpn_mod_1 mpn_mod_1_inv 34 | 35 | #include "mpn/generic/mod_1.c" 36 | -------------------------------------------------------------------------------- /demos/expr/exprv.c: -------------------------------------------------------------------------------- 1 | /* mpz expression evaluation, simple part */ 2 | 3 | /* 4 | Copyright 2000, 2001 Free Software Foundation, Inc. 5 | 6 | This file is part of the GNU MP Library. 7 | 8 | The GNU MP Library is free software; you can redistribute it and/or modify 9 | it under the terms of the GNU Lesser General Public License as published by 10 | the Free Software Foundation; either version 3 of the License, or (at your 11 | option) any later version. 12 | 13 | The GNU MP Library is distributed in the hope that it will be useful, but 14 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | License for more details. 17 | 18 | You should have received a copy of the GNU Lesser General Public License 19 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 20 | 21 | #include 22 | #include "gmp.h" 23 | #include "expr-impl.h" 24 | 25 | 26 | int 27 | mpexpr_va_to_var (void *var[], va_list ap) 28 | { 29 | int i = 0; 30 | void *v; 31 | 32 | for (;;) 33 | { 34 | v = va_arg (ap, void *); 35 | if (v == NULL) 36 | break; 37 | if (i >= MPEXPR_VARIABLES) 38 | return MPEXPR_RESULT_BAD_VARIABLE; 39 | var[i++] = v; 40 | } 41 | 42 | while (i < MPEXPR_VARIABLES) 43 | var[i++] = NULL; 44 | 45 | return MPEXPR_RESULT_OK; 46 | } 47 | -------------------------------------------------------------------------------- /mpn/arm/README: -------------------------------------------------------------------------------- 1 | Copyright 2002 Free Software Foundation, Inc. 2 | 3 | This file is part of the GNU MP Library. 4 | 5 | The GNU MP Library is free software; you can redistribute it and/or modify it 6 | under the terms of the GNU Lesser General Public License as published by the 7 | Free Software Foundation; either version 3 of the License, or (at your option) 8 | any later version. 9 | 10 | The GNU MP Library is distributed in the hope that it will be useful, but 11 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 13 | for more details. 14 | 15 | You should have received a copy of the GNU Lesser General Public License along 16 | with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 17 | 18 | 19 | 20 | 21 | 22 | This directory contains mpn functions for ARM processors. 23 | It has been optimized for StrongARM. 24 | 25 | TODO 26 | 27 | Write mpn_addmul_2. The speed of mpn_addmul_1 is 9.75 c/l; 28 | mpn_addmul_2 could run at 8 c/l. mpn_addmul_N could 29 | approach 6 c/l, but register shortage will make this hard. 30 | 31 | Perhaps nails is the way to go even for an embedded processor like 32 | this, since the umlal accumulation could be used very effectively in 33 | that case. with just 2 nail bits, we should get close to 5 c/l for a 34 | mpn_addmul_N or mpn_mul_basecase. 35 | -------------------------------------------------------------------------------- /mpn/x86/umul.asm: -------------------------------------------------------------------------------- 1 | dnl mpn_umul_ppmm -- 1x1->2 limb multiplication 2 | 3 | dnl Copyright 1999, 2000, 2002 Free Software Foundation, Inc. 4 | dnl 5 | dnl This file is part of the GNU MP Library. 6 | dnl 7 | dnl The GNU MP Library is free software; you can redistribute it and/or 8 | dnl modify it under the terms of the GNU Lesser General Public License as 9 | dnl published by the Free Software Foundation; either version 3 of the 10 | dnl License, or (at your option) any later version. 11 | dnl 12 | dnl The GNU MP Library is distributed in the hope that it will be useful, 13 | dnl but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | dnl Lesser General Public License for more details. 16 | dnl 17 | dnl You should have received a copy of the GNU Lesser General Public License 18 | dnl along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 19 | 20 | include(`../config.m4') 21 | 22 | 23 | C mp_limb_t mpn_umul_ppmm (mp_limb_t *lowptr, mp_limb_t m1, mp_limb_t m2); 24 | C 25 | 26 | defframe(PARAM_M2, 12) 27 | defframe(PARAM_M1, 8) 28 | defframe(PARAM_LOWPTR, 4) 29 | 30 | TEXT 31 | ALIGN(8) 32 | PROLOGUE(mpn_umul_ppmm) 33 | deflit(`FRAME',0) 34 | movl PARAM_LOWPTR, %ecx 35 | movl PARAM_M1, %eax 36 | mull PARAM_M2 37 | movl %eax, (%ecx) 38 | movl %edx, %eax 39 | ret 40 | EPILOGUE() 41 | -------------------------------------------------------------------------------- /tune/set_strs.c: -------------------------------------------------------------------------------- 1 | /* mpn_set_str_subquad -- mpn_set_str forced to the sub-quadratic case. 2 | 3 | Copyright 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #define __gmpn_set_str mpn_set_str_subquad 21 | #define __gmpn_bc_set_str mpn_bc_set_str_subquad 22 | #define __gmpn_dc_set_str mpn_dc_set_str_subquad 23 | #define __gmpn_set_str_compute_powtab mpn_set_str_compute_powtab_subquad 24 | 25 | #include "gmp.h" 26 | #include "gmp-impl.h" 27 | 28 | #undef SET_STR_DC_THRESHOLD 29 | #define SET_STR_DC_THRESHOLD 2 /* never */ 30 | #undef SET_STR_PRECOMPUTE_THRESHOLD 31 | #define SET_STR_PRECOMPUTE_THRESHOLD 2 /* never */ 32 | 33 | #include "mpn/generic/set_str.c" 34 | -------------------------------------------------------------------------------- /mp_get_fns.c: -------------------------------------------------------------------------------- 1 | /* mp_get_memory_functions -- Get the allocate, reallocate, and free functions. 2 | 3 | Copyright 2002 Free Software Foundation, Inc. 4 | 5 | This file is part of the GNU MP Library. 6 | 7 | The GNU MP Library is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU Lesser General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or (at your 10 | option) any later version. 11 | 12 | The GNU MP Library is distributed in the hope that it will be useful, but 13 | WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 14 | or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 15 | License for more details. 16 | 17 | You should have received a copy of the GNU Lesser General Public License 18 | along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ 19 | 20 | #include /* for NULL */ 21 | #include "gmp.h" 22 | #include "gmp-impl.h" 23 | 24 | void 25 | mp_get_memory_functions (void *(**alloc_func) (size_t), 26 | void *(**realloc_func) (void *, size_t, size_t), 27 | void (**free_func) (void *, size_t)) 28 | { 29 | if (alloc_func != NULL) 30 | *alloc_func = __gmp_allocate_func; 31 | 32 | if (realloc_func != NULL) 33 | *realloc_func = __gmp_reallocate_func; 34 | 35 | if (free_func != NULL) 36 | *free_func = __gmp_free_func; 37 | } 38 | -------------------------------------------------------------------------------- /mpn/pyr/addmul_1.s: -------------------------------------------------------------------------------- 1 | # Pyramid __gmpn_addmul_1 -- Multiply a limb vector with a limb and add 2 | # the result to a second limb vector. 3 | 4 | # Copyright 1995, 2000 Free Software Foundation, Inc. 5 | 6 | # This file is part of the GNU MP Library. 7 | 8 | # The GNU MP Library is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU Lesser General Public License as published by 10 | # the Free Software Foundation; either version 3 of the License, or (at your 11 | # option) any later version. 12 | 13 | # The GNU MP Library is distributed in the hope that it will be useful, but 14 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 15 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 16 | # License for more details. 17 | 18 | # You should have received a copy of the GNU Lesser General Public License 19 | # along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. 20 | 21 | .text 22 | .align 2 23 | .globl ___gmpn_addmul_1 24 | ___gmpn_addmul_1: 25 | mova (pr0)[pr2*4],pr0 26 | mova (pr1)[pr2*4],pr1 27 | mnegw pr2,pr2 28 | movw $0,tr3 29 | 30 | Loop: movw (pr1)[pr2*4],tr1 31 | uemul pr3,tr0 32 | addw tr3,tr1 33 | movw $0,tr3 34 | addwc tr0,tr3 35 | movw (pr0)[pr2*0x4],tr0 36 | addw tr0,tr1 37 | addwc $0,tr3 38 | movw tr1,(pr0)[pr2*4] 39 | addw $1,pr2 40 | bne Loop 41 | 42 | movw tr3,pr0 43 | ret 44 | --------------------------------------------------------------------------------