diff options
author | Torbjorn Granlund <tege@gmplib.org> | 2010-11-12 22:06:32 +0100 |
---|---|---|
committer | Torbjorn Granlund <tege@gmplib.org> | 2010-11-12 22:06:32 +0100 |
commit | 3ee827409bd3a6f64b96e9fe082205da88128206 (patch) | |
tree | b314b9ff7aca8da5ae4c704af97c9c8ac79ec73b /mpbsd | |
parent | 9aa234de37f83e6d150afd8504d2c726c86d7b38 (diff) | |
download | gmp-3ee827409bd3a6f64b96e9fe082205da88128206.tar.gz |
Purge BSD mp compatible functions.
Diffstat (limited to 'mpbsd')
-rw-r--r-- | mpbsd/Makefile.am | 37 | ||||
-rw-r--r-- | mpbsd/itom.c | 47 | ||||
-rw-r--r-- | mpbsd/mfree.c | 29 | ||||
-rw-r--r-- | mpbsd/min.c | 88 | ||||
-rw-r--r-- | mpbsd/mout.c | 92 | ||||
-rw-r--r-- | mpbsd/mtox.c | 61 | ||||
-rw-r--r-- | mpbsd/rpow.c | 32 | ||||
-rw-r--r-- | mpbsd/sdiv.c | 67 | ||||
-rw-r--r-- | mpbsd/xtom.c | 87 |
9 files changed, 0 insertions, 540 deletions
diff --git a/mpbsd/Makefile.am b/mpbsd/Makefile.am deleted file mode 100644 index 4272bbf97..000000000 --- a/mpbsd/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -## Process this file with automake to generate Makefile.in - -# Copyright 1996, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. -# -# This file is part of the GNU MP Library. -# -# The GNU MP Library is free software; you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 3 of the License, or (at your -# option) any later version. -# -# The GNU MP Library is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. - - -# -I$(top_srcdir)/mpz is for #includes done by mpz .c files. Perhaps most -# compilers are smart enough to look in the same directory as the .c file -# already, but lets make absolutely sure. -# -INCLUDES = -DBERKELEY_MP -D__GMP_WITHIN_GMP -D__gmpz_realloc=_mp_realloc \ - -I$(top_srcdir) -I$(top_srcdir)/mpz - -# The mpz sources here all know to look for -DBERKELEY_MP to compile to in -# mpbsd form. -# -libmpbsd_la_SOURCES = itom.c mfree.c min.c mout.c mtox.c rpow.c sdiv.c xtom.c \ - ../mpz/add.c ../mpz/cmp.c ../mpz/gcd.c ../mpz/mul.c ../mpz/powm.c \ - ../mpz/realloc.c ../mpz/set.c ../mpz/sqrtrem.c ../mpz/sub.c ../mpz/tdiv_qr.c - -if WANT_MPBSD -noinst_LTLIBRARIES = libmpbsd.la -endif diff --git a/mpbsd/itom.c b/mpbsd/itom.c deleted file mode 100644 index 6f0e31c01..000000000 --- a/mpbsd/itom.c +++ /dev/null @@ -1,47 +0,0 @@ -/* itom -- BSD compatible allocate and initiate a MINT. - -Copyright 1991, 1994, 1995, 2000, 2001 Free Software Foundation, Inc. - -This file is part of the GNU MP Library. - -The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -The GNU MP Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ - -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" - -MINT * -itom (signed short int n) -{ - MINT *x; - mp_ptr xp; - - x = (MINT *) (*__gmp_allocate_func) (sizeof (MINT)); - x->_mp_alloc = 1; - x->_mp_d = xp = (mp_ptr) (*__gmp_allocate_func) (BYTES_PER_MP_LIMB); - if (n > 0) - { - x->_mp_size = 1; - xp[0] = n; - } - else if (n < 0) - { - x->_mp_size = -1; - xp[0] = (unsigned short) -n; - } - else - x->_mp_size = 0; - - return x; -} diff --git a/mpbsd/mfree.c b/mpbsd/mfree.c deleted file mode 100644 index 84e93f8cb..000000000 --- a/mpbsd/mfree.c +++ /dev/null @@ -1,29 +0,0 @@ -/* mfree -- BSD compatible mfree. - -Copyright 1991, 1994, 1995, 2000, 2001 Free Software Foundation, Inc. - -This file is part of the GNU MP Library. - -The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -The GNU MP Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ - -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" - -void -mfree (MINT *m) -{ - (*__gmp_free_func) (m->_mp_d, m->_mp_alloc * BYTES_PER_MP_LIMB); - (*__gmp_free_func) (m, sizeof (MINT)); -} diff --git a/mpbsd/min.c b/mpbsd/min.c deleted file mode 100644 index 4502dfc03..000000000 --- a/mpbsd/min.c +++ /dev/null @@ -1,88 +0,0 @@ -/* min(MINT) -- Do decimal input from standard input and store result in - MINT. - -Copyright 1991, 1994, 1996, 2000, 2001 Free Software Foundation, Inc. - -This file is part of the GNU MP Library. - -The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -The GNU MP Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ - -#include <stdio.h> -#include <ctype.h> -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" - -#define digit_value_tab __gmp_digit_value_tab - -void -min (MINT *dest) -{ - char *str; - size_t alloc_size, str_size; - int c; - int negative; - mp_size_t dest_size; - const unsigned char *digit_value; - - digit_value = digit_value_tab; - - alloc_size = 100; - str = (char *) (*__gmp_allocate_func) (alloc_size); - str_size = 0; - - /* Skip whitespace. */ - do - c = getc (stdin); - while (isspace (c)); - - negative = 0; - if (c == '-') - { - negative = 1; - c = getc (stdin); - } - - if (c == EOF || digit_value[c] >= 10) - return; /* error if no digits */ - - do - { - int dig; - dig = digit_value[c]; - if (dig >= 10) - break; - if (str_size >= alloc_size) - { - size_t old_alloc_size = alloc_size; - alloc_size = alloc_size * 3 / 2; - str = (char *) (*__gmp_reallocate_func) (str, old_alloc_size, alloc_size); - } - str[str_size++] = dig; - c = getc (stdin); - } - while (c != EOF); - - ungetc (c, stdin); - - dest_size = str_size / mp_bases[10].chars_per_limb + 1; - if (dest->_mp_alloc < dest_size) - _mp_realloc (dest, dest_size); - - dest_size = mpn_set_str (dest->_mp_d, (unsigned char *) str, str_size, 10); - dest->_mp_size = negative ? -dest_size : dest_size; - - (*__gmp_free_func) (str, alloc_size); - return; -} diff --git a/mpbsd/mout.c b/mpbsd/mout.c deleted file mode 100644 index 545539cce..000000000 --- a/mpbsd/mout.c +++ /dev/null @@ -1,92 +0,0 @@ -/* mout(MINT) -- Do decimal output of MINT to standard output. - -Copyright 1991, 1994, 1996, 2000, 2001, 2002, 2005 Free Software Foundation, -Inc. - -This file is part of the GNU MP Library. - -The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -The GNU MP Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ - -#include <stdio.h> -#include <string.h> -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void -mout (const MINT *x) -{ - mp_ptr xp; - mp_srcptr x_ptr; - mp_size_t x_size; - unsigned char *str; - size_t str_size; - int i; - TMP_DECL; - - x_size = x->_mp_size; - if (x_size == 0) - { - fputc ('0', stdout); - fputc ('\n', stdout); - return; - } - if (x_size < 0) - { - fputc ('-', stdout); - x_size = -x_size; - } - - TMP_MARK; - x_ptr = x->_mp_d; - MPN_SIZEINBASE (str_size, x_ptr, x_size, 10); - str_size += 2; - str = (unsigned char *) TMP_ALLOC (str_size); - - /* mpn_get_str clobbers its argument */ - xp = TMP_ALLOC_LIMBS (x_size); - MPN_COPY (xp, x_ptr, x_size); - - str_size = mpn_get_str (str, 10, xp, x_size); - - /* mpn_get_str might make a leading zero, skip it. */ - str_size -= (*str == 0); - str += (*str == 0); - ASSERT (*str != 0); - - /* Translate to printable chars. */ - for (i = 0; i < str_size; i++) - str[i] = "0123456789"[str[i]]; - str[str_size] = 0; - - str_size = strlen ((char *) str); - if (str_size % 10 != 0) - { - fwrite (str, 1, str_size % 10, stdout); - str += str_size % 10; - str_size -= str_size % 10; - if (str_size != 0) - fputc (' ', stdout); - } - for (i = 0; i < str_size; i += 10) - { - fwrite (str, 1, 10, stdout); - str += 10; - if (i + 10 < str_size) - fputc (' ', stdout); - } - fputc ('\n', stdout); - TMP_FREE; -} diff --git a/mpbsd/mtox.c b/mpbsd/mtox.c deleted file mode 100644 index 7babfdd07..000000000 --- a/mpbsd/mtox.c +++ /dev/null @@ -1,61 +0,0 @@ -/* mtox -- Convert OPERAND to hexadecimal and return a malloc'ed string - with the result of the conversion. - -Copyright 1991, 1994, 2000, 2001, 2002 Free Software Foundation, Inc. - -This file is part of the GNU MP Library. - -The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -The GNU MP Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ - -#include <string.h> -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -char * -mtox (const MINT *x) -{ - mp_size_t xsize = x->_mp_size; - mp_ptr xp; - mp_size_t xsign; - unsigned char *str, *s; - size_t str_size, alloc_size, i; - - xsign = xsize; - if (xsize < 0) - xsize = -xsize; - - /* digits, plus '\0', plus possible '-', for an exact size */ - xp = x->_mp_d; - MPN_SIZEINBASE_16 (alloc_size, xp, xsize); - alloc_size += 1 + (xsign < 0); - - str = (unsigned char *) (*__gmp_allocate_func) (alloc_size); - s = str; - - if (xsign < 0) - *s++ = '-'; - - str_size = mpn_get_str (s, 16, xp, xsize); - ASSERT (str_size <= alloc_size - (xsign < 0)); - ASSERT (str_size == 1 || *s != 0); - - for (i = 0; i < str_size; i++) - s[i] = "0123456789abcdef"[s[i]]; - s[str_size] = 0; - - ASSERT (strlen (str) + 1 == alloc_size); - return (char *) str; -} diff --git a/mpbsd/rpow.c b/mpbsd/rpow.c deleted file mode 100644 index 827aacb6b..000000000 --- a/mpbsd/rpow.c +++ /dev/null @@ -1,32 +0,0 @@ -/* rpow -- MINT raised to short. */ - -/* -Copyright 2001 Free Software Foundation, Inc. - -This file is part of the GNU MP Library. - -The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -The GNU MP Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ - -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" - -void -rpow (const MINT *b, short e, MINT *r) -{ - if (e >= 0) - mpz_n_pow_ui (r, PTR(b), (mp_size_t) SIZ(b), (unsigned long) e); - else - SIZ(r) = 0; -} diff --git a/mpbsd/sdiv.c b/mpbsd/sdiv.c deleted file mode 100644 index 802fe52a9..000000000 --- a/mpbsd/sdiv.c +++ /dev/null @@ -1,67 +0,0 @@ -/* sdiv -- Divide a MINT by a short integer. Produce a MINT quotient - and a short remainder. - -Copyright 1991, 1994, 1995, 2000, 2001 Free Software Foundation, Inc. - -This file is part of the GNU MP Library. - -The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -The GNU MP Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ - -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" -#include "longlong.h" - -void -sdiv (const MINT *dividend, signed short int divisor_short, MINT *quot, short *rem_ptr) -{ - mp_size_t sign_dividend; - signed long int sign_divisor; - mp_size_t dividend_size, quot_size; - mp_ptr dividend_ptr, quot_ptr; - mp_limb_t divisor_limb; - mp_limb_t remainder_limb; - - sign_dividend = dividend->_mp_size; - dividend_size = ABS (dividend->_mp_size); - - if (dividend_size == 0) - { - quot->_mp_size = 0; - *rem_ptr = 0; - return; - } - - sign_divisor = divisor_short; - divisor_limb = (unsigned short) ABS (divisor_short); - - /* No need for temporary allocation and copying even if QUOT == DIVIDEND - as the divisor is just one limb, and thus no intermediate remainders - need to be stored. */ - - if (quot->_mp_alloc < dividend_size) - _mp_realloc (quot, dividend_size); - - quot_ptr = quot->_mp_d; - dividend_ptr = dividend->_mp_d; - - remainder_limb = mpn_divmod_1 (quot_ptr, - dividend_ptr, dividend_size, divisor_limb); - - *rem_ptr = sign_dividend >= 0 ? remainder_limb : -remainder_limb; - /* The quotient is DIVIDEND_SIZE limbs, but the most significant - might be zero. Set QUOT_SIZE properly. */ - quot_size = dividend_size - (quot_ptr[dividend_size - 1] == 0); - quot->_mp_size = (sign_divisor ^ sign_dividend) >= 0 ? quot_size : -quot_size; -} diff --git a/mpbsd/xtom.c b/mpbsd/xtom.c deleted file mode 100644 index 0161b4248..000000000 --- a/mpbsd/xtom.c +++ /dev/null @@ -1,87 +0,0 @@ -/* xtom -- convert a hexadecimal string to a MINT, and return a pointer to - the MINT. - -Copyright 1991, 1994, 1995, 1996, 2000, 2001, 2002, 2005 Free Software -Foundation, Inc. - -This file is part of the GNU MP Library. - -The GNU MP Library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -The GNU MP Library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -License for more details. - -You should have received a copy of the GNU Lesser General Public License -along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */ - -#include <string.h> -#include <ctype.h> -#include "mp.h" -#include "gmp.h" -#include "gmp-impl.h" - -#define digit_value __gmp_digit_value_tab - -MINT * -xtom (const char *str) -{ - size_t str_size; - char *s, *begs; - size_t i; - mp_size_t xsize; - int c; - int negative; - MINT *x = (MINT *) (*__gmp_allocate_func) (sizeof (MINT)); - TMP_DECL; - - /* Skip whitespace. */ - do - c = (unsigned char) *str++; - while (isspace (c)); - - negative = 0; - if (c == '-') - { - negative = 1; - c = (unsigned char) *str++; - } - - if (digit_value[c] >= 16) - return 0; /* error if no digits */ - - TMP_MARK; - str_size = strlen (str - 1); - s = begs = (char *) TMP_ALLOC (str_size + 1); - - for (i = 0; i < str_size; i++) - { - if (!isspace (c)) - { - int dig = digit_value[c]; - if (dig >= 16) - { - TMP_FREE; - return 0; - } - *s++ = dig; - } - c = (unsigned char) *str++; - } - - str_size = s - begs; - - xsize = str_size / mp_bases[16].chars_per_limb + 1; - x->_mp_alloc = xsize; - x->_mp_d = (mp_ptr) (*__gmp_allocate_func) (xsize * BYTES_PER_MP_LIMB); - - xsize = mpn_set_str (x->_mp_d, (unsigned char *) begs, str_size, 16); - x->_mp_size = negative ? -xsize : xsize; - - TMP_FREE; - return x; -} |