diff options
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | Makefile | 9 | ||||
-rwxr-xr-x | configure | 53 | ||||
-rw-r--r-- | mpi-1.8.6.tar.gz | bin | 154702 -> 0 bytes | |||
-rw-r--r-- | mpi-patches/add-bitops | 484 | ||||
-rw-r--r-- | mpi-patches/add-mp-hash | 52 | ||||
-rw-r--r-- | mpi-patches/add-mp-set-intptr | 77 | ||||
-rw-r--r-- | mpi-patches/add-mpi-toradix-with-case | 54 | ||||
-rw-r--r-- | mpi-patches/bit-search-optimizations | 300 | ||||
-rw-r--r-- | mpi-patches/config-types | 122 | ||||
-rw-r--r-- | mpi-patches/disable-make | 18 | ||||
-rw-r--r-- | mpi-patches/eliminate-locale-dependencies | 45 | ||||
-rw-r--r-- | mpi-patches/export-mp-eq | 34 | ||||
-rw-r--r-- | mpi-patches/faster-square-root | 189 | ||||
-rw-r--r-- | mpi-patches/fix-bad-shifts | 49 | ||||
-rw-r--r-- | mpi-patches/fix-ctype-warnings | 31 | ||||
-rw-r--r-- | mpi-patches/fix-mult-bug | 58 | ||||
-rw-r--r-- | mpi-patches/fix-warnings | 61 | ||||
-rw-r--r-- | mpi-patches/mpi-set-double-intptr | 55 | ||||
-rw-r--r-- | mpi-patches/mpi-set-mpi-word | 32 | ||||
-rw-r--r-- | mpi-patches/mpi-to-double | 58 | ||||
-rw-r--r-- | mpi-patches/series | 19 | ||||
-rw-r--r-- | mpi-patches/shrink-mpi-int | 18 | ||||
-rw-r--r-- | mpi-patches/use-txr-allocator | 68 |
24 files changed, 20 insertions, 1884 deletions
@@ -1,5 +1,23 @@ 2015-04-22 Kaz Kylheku <kaz@kylheku.com> + Switch to in-tree mpi directory. + + * Makefile (CFLAGS, MPI_OBJS): Refer to mpi directory without version + number. + (repatch): Target removed. + (distclean): Don't try to remove old unpacked tarball mpi directory. + + * configure (mpi_version, have_quilt, have_patch): Variables removed. + (gen_config_make): Do not generate mpi_version make variable. + Do not test for quilt or patch. No longer extract MPI tarball or + try to apply patches. + + * mpi-1.8.6.tar.gz: File removed. + + * mpi-patches: Directory and all files under it removed. + +2015-04-22 Kaz Kylheku <kaz@kylheku.com> + delay/force overhaul. * eval.c (promise_forced_s, promise_inprogress_s): New symbol @@ -29,7 +29,7 @@ VERBOSE := CFLAGS := -iquote $(conf_dir) -iquote $(top_srcdir) \ $(LANG_FLAGS) $(DIAG_FLAGS) \ $(DBG_FLAGS) $(PLATFORM_FLAGS) $(EXTRA_FLAGS) -CFLAGS += -iquote mpi-$(mpi_version) +CFLAGS += -iquote mpi CFLAGS := $(filter-out $(REMOVE_FLAGS),$(CFLAGS)) ifneq ($(subst g++,@,$(notdir $(CC))),$(notdir $(CC))) @@ -63,7 +63,7 @@ endif # MPI objects MPI_OBJ_BASE=mpi.o mplogic.o -MPI_OBJS := $(addprefix mpi-$(mpi_version)/,$(MPI_OBJ_BASE)) +MPI_OBJS := $(addprefix mpi/,$(MPI_OBJ_BASE)) OBJS += $(MPI_OBJS) @@ -233,13 +233,8 @@ clean: conftest.clean tests.clean rm -f $(PROG)$(EXE) $(PROG)-dbg$(EXE) y.tab.c lex.yy.c y.tab.h y.output rm -rf opt dbg $(EXTRA_OBJS-y) -repatch: - cd mpi-$(mpi_version); quilt pop -af - cd mpi-$(mpi_version); quilt push -a - distclean: clean rm -rf $(conf_dir) - rm -rf mpi-$(mpi_version) endif TESTS_TMP := txr.test.out @@ -110,9 +110,6 @@ lit_align= extra_debugging= debug_support=y gen_gc=y -mpi_version=1.8.6 -have_quilt= -have_patch= have_unistd= have_sys_time= have_timegm= @@ -634,9 +631,6 @@ have_posix_sigs := $have_posix_sigs # do we compile in debug support? debug_support := $debug_support -# MPI version -mpi_version := $mpi_version - # EXE suffix EXE := $exe @@ -2014,30 +2008,6 @@ fi $make conftest.clean # -# What do we have for patch management. -# - -printf "Checking for quilt ... " - -if ! quilt --version > /dev/null 2>&1 ; then - printf "not found\n" -else - printf "found\n" - have_quilt=y -fi - -printf "Checking for patch ... " - -if ! patch --version > /dev/null 2>&1 ; then - printf "not found\n" - printf "\npatch tool required!\n\n" - exit 1 -else - printf "found\n" - have_patch=y -fi - -# # Function to apply patches. # apply_patches() @@ -2056,29 +2026,6 @@ apply_patches() } # -# Try to extract MPI if not already. -# - -printf "Extracting MPI ... " - -if [ -e mpi-${mpi_version} ] ; then - printf "already extracted\n" -else - tar -xzf $top_srcdir/mpi-${mpi_version}.tar.gz - printf "\n" - printf "Symlinking MPI patches ...\n" - ln -sf $top_srcdir/mpi-patches mpi-${mpi_version}/patches - printf "Applying MPI patches ...\n" - if [ -n "$have_quilt" ] ; then - ( cd mpi-${mpi_version}/patches ; - if [ -e series ] ; then quilt push -a ; else echo "no patches" ; fi ) - else - ( cd mpi-${mpi_version} ; - apply_patches ) - fi -fi - -# # Some final blurbs into config.h # diff --git a/mpi-1.8.6.tar.gz b/mpi-1.8.6.tar.gz Binary files differdeleted file mode 100644 index 43791a77..00000000 --- a/mpi-1.8.6.tar.gz +++ /dev/null diff --git a/mpi-patches/add-bitops b/mpi-patches/add-bitops deleted file mode 100644 index 19b9fee9..00000000 --- a/mpi-patches/add-bitops +++ /dev/null @@ -1,484 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-02-07 19:33:17.280186661 -0800 -+++ mpi-1.8.6/mpi.c 2015-02-07 19:33:19.412149446 -0800 -@@ -16,6 +16,9 @@ - #include <ctype.h> - #include <math.h> - -+#define MAX(A, B) ((A) > (B) ? (A) : (B)) -+#define MIN(A, B) ((A) < (B) ? (A) : (B)) -+ - typedef unsigned char mem_t; - extern mem_t *chk_calloc(size_t n, size_t size); - -@@ -157,6 +160,7 @@ - mp_err s_mp_grow(mp_int *mp, mp_size min); /* increase allocated size */ - mp_err s_mp_pad(mp_int *mp, mp_size min); /* left pad with zeroes */ - -+static int s_highest_bit(mp_digit n); - int s_highest_bit_mp(mp_int *a); - mp_err s_mp_set_bit(mp_int *a, int bit); - -@@ -2334,6 +2338,430 @@ - - /* }}} */ - -+/* -+ * Convert a's bit vector to its two's complement, up to the -+ * number of words that it contains, storing result in b. The numeric value of -+ * this result depends on the size of mpi_digit. This is a building block for -+ * handling negative operands in the bit operations. -+ */ -+mp_err mp_2comp(mp_int *a, mp_int *b, mp_size dig) -+{ -+ mp_err res; -+ mp_size ix, adig = USED(a); -+ mp_digit *pa, *pb; -+ mp_digit padding = ISNEG(a) ? MP_DIGIT_MAX : 0; -+ mp_word w; -+ -+ ARGCHK(a != NULL && b != NULL, MP_BADARG); -+ -+ if (a != b) { -+ if ((res = mp_init_size(b, dig)) != MP_OKAY) -+ return res; -+ SIGN(b) = SIGN(a); -+ } else { -+ if((res = s_mp_pad(b, dig)) != MP_OKAY) -+ return res; -+ } -+ -+ for (pa = DIGITS(a), pb = DIGITS(b), w = 0, ix = 0; ix < dig; ix++) { -+ w += (ix == 0); -+ w += (ix < adig) ? ~pa[ix] : padding; -+ pb[ix] = ACCUM(w); -+ w = CARRYOUT(w); -+ } -+ -+ USED(b) = dig; -+ -+ return MP_OKAY; -+} -+ -+mp_err mp_and(mp_int *a, mp_int *b, mp_int *c) -+{ -+ mp_err res = MP_OKAY; -+ mp_size ix, extent = 0; -+ mp_digit *pa, *pb, *pc; -+ mp_int tmp_a, tmp_b; -+ -+ ARGCHK(a != NULL && b != NULL && c != NULL, MP_BADARG); -+ -+ if (a == b) -+ return mp_copy(a, c); -+ -+ if (ISNEG(a)) { -+ extent = USED(b); -+ mp_init(&tmp_a); -+ if ((res = mp_2comp(a, &tmp_a, extent)) != MP_OKAY) -+ goto out; -+ a = &tmp_a; -+ } -+ -+ if (ISNEG(b)) { -+ extent = USED(a); -+ mp_init(&tmp_b); -+ if ((res = mp_2comp(b, &tmp_b, extent)) != MP_OKAY) -+ goto out; -+ b = &tmp_b; -+ } -+ -+ if (!extent) -+ extent = MIN(USED(a), USED(b)); -+ -+ if (c != a && c != b) { -+ if ((res = mp_init_size(c, extent)) != MP_OKAY) -+ goto out; -+ } -+ -+ for (pa = DIGITS(a), pb = DIGITS(b), pc = DIGITS(c), ix = 0; -+ ix < extent; ix++) -+ { -+ pc[ix] = pa[ix] & pb[ix]; -+ } -+ -+ USED(c) = extent; -+ -+ if (ISNEG(a) && ISNEG(b)) { -+ mp_2comp(c, c, extent); -+ SIGN(c) = MP_NEG; -+ } -+ -+ s_mp_clamp(c); -+ -+out: -+ if (ISNEG(a)) -+ mp_clear(&tmp_a); -+ -+ if (ISNEG(b)) -+ mp_clear(&tmp_b); -+ -+ return res; -+} -+ -+mp_err mp_or(mp_int *a, mp_int *b, mp_int *c) -+{ -+ mp_err res; -+ mp_size ix, extent = 0; -+ mp_digit *pa, *pb, *pc; -+ mp_int tmp_a, tmp_b; -+ -+ ARGCHK(a != NULL && b != NULL && c != NULL, MP_BADARG); -+ -+ extent = MAX(USED(a), USED(b)); -+ -+ if (a == b) -+ return mp_copy(a, c); -+ -+ if (ISNEG(a)) { -+ mp_init(&tmp_a); -+ if ((res = mp_2comp(a, &tmp_a, extent)) != MP_OKAY) -+ goto out; -+ a = &tmp_a; -+ } -+ -+ if (ISNEG(b)) { -+ mp_init(&tmp_b); -+ if ((res = mp_2comp(b, &tmp_b, extent)) != MP_OKAY) -+ goto out; -+ b = &tmp_b; -+ } -+ -+ -+ if (c != a && c != b) -+ res = mp_init_size(c, extent); -+ else -+ res = s_mp_pad(c, extent); -+ -+ if (res != MP_OKAY) -+ goto out; -+ -+ for (pa = DIGITS(a), pb = DIGITS(b), pc = DIGITS(c), ix = 0; -+ ix < extent; ix++) -+ { -+ pc[ix] = pa[ix] | pb[ix]; -+ } -+ -+ USED(c) = extent; -+ -+ if (ISNEG(a) || ISNEG(b)) { -+ mp_2comp(c, c, extent); -+ SIGN(c) = MP_NEG; -+ } -+ -+ s_mp_clamp(c); -+ -+out: -+ if (ISNEG(a)) -+ mp_clear(&tmp_a); -+ -+ if (ISNEG(b)) -+ mp_clear(&tmp_b); -+ -+ return res; -+} -+ -+mp_err mp_xor(mp_int *a, mp_int *b, mp_int *c) -+{ -+ mp_err res; -+ mp_size ix, extent = 0; -+ mp_digit *pa, *pb, *pc; -+ mp_int tmp_a, tmp_b; -+ -+ ARGCHK(a != NULL && b != NULL && c != NULL, MP_BADARG); -+ -+ if (a == b) { -+ mp_zero(c); -+ return MP_OKAY; -+ } -+ -+ extent = MAX(USED(a), USED(b)); -+ -+ if (ISNEG(a)) { -+ mp_init(&tmp_a); -+ if ((res = mp_2comp(a, &tmp_a, extent)) != MP_OKAY) -+ goto out; -+ a = &tmp_a; -+ } -+ -+ if (ISNEG(b)) { -+ mp_init(&tmp_b); -+ if ((res = mp_2comp(b, &tmp_b, extent)) != MP_OKAY) -+ goto out; -+ b = &tmp_b; -+ } -+ -+ -+ if (c != a && c != b) -+ res = mp_init_size(c, extent); -+ else -+ res = s_mp_pad(c, extent); -+ -+ if (res != MP_OKAY) -+ goto out; -+ -+ for (pa = DIGITS(a), pb = DIGITS(b), pc = DIGITS(c), ix = 0; -+ ix < extent; ix++) -+ { -+ pc[ix] = pa[ix] ^ pb[ix]; -+ } -+ -+ USED(c) = extent; -+ -+ if (ISNEG(a) ^ ISNEG(b)) { -+ mp_2comp(c, c, extent); -+ SIGN(c) = MP_NEG; -+ } -+ -+ s_mp_clamp(c); -+ -+out: -+ if (ISNEG(a)) -+ mp_clear(&tmp_a); -+ -+ if (ISNEG(b)) -+ mp_clear(&tmp_b); -+ -+ return res; -+} -+ -+mp_err mp_comp(mp_int *a, mp_int *b) -+{ -+ mp_err res; -+ mp_size ix, dig = USED(a); -+ mp_digit *pa, *pb; -+ mp_int tmp; -+ -+ ARGCHK(a != NULL && b != NULL, MP_BADARG); -+ -+ if (a != b) -+ res = mp_init_size(b, dig); -+ else -+ res = s_mp_pad(b, dig); -+ -+ if (res != MP_OKAY) -+ return res; -+ -+ if (ISNEG(a)) { -+ mp_init(&tmp); -+ if ((res = mp_2comp(a, &tmp, dig)) != MP_OKAY) -+ return res; -+ a = &tmp; -+ } -+ -+ for (pa = DIGITS(a), pb = DIGITS(b), ix = 0; ix < dig; ix++) -+ pb[ix] = ~pa[ix]; -+ -+ USED(b) = dig; -+ -+ if (ISNEG(a)) { -+ mp_clear(&tmp); -+ } else { -+ if ((res = mp_2comp(b, b, dig)) != MP_OKAY) -+ return res; -+ SIGN(b) = MP_NEG; -+ } -+ -+ s_mp_clamp(b); -+ return MP_OKAY; -+} -+ -+mp_err mp_trunc_comp(mp_int *a, mp_int *b, mp_digit bits) -+{ -+ mp_err res; -+ mp_size ix, dig = bits / DIGIT_BIT, rembits = bits % DIGIT_BIT; -+ mp_size adig = USED(a); -+ mp_digit padding = ISNEG(a) ? MP_DIGIT_MAX : 0; -+ int extra = (rembits != 0); -+ mp_digit *pa, *pb; -+ mp_int tmp; -+ -+ ARGCHK(a != NULL && b != NULL, MP_BADARG); -+ -+ if (a != b) -+ res = mp_init_size(b, dig + extra); -+ else -+ res = s_mp_pad(b, dig + extra); -+ -+ if (res != MP_OKAY) -+ return res; -+ -+ if (ISNEG(a)) { -+ mp_init(&tmp); -+ if ((res = mp_2comp(a, &tmp, dig + extra)) != MP_OKAY) -+ return res; -+ a = &tmp; -+ } -+ -+ for (pa = DIGITS(a), pb = DIGITS(b), ix = 0; ix < dig; ix++) -+ pb[ix] = (ix < adig) ? ~pa[ix] : ~padding; -+ -+ if (rembits) { -+ mp_digit mask = (MP_DIGIT_MAX >> (DIGIT_BIT - rembits)); -+ pb[ix] = (((ix < adig) ? pa[ix] : padding) & mask) ^ mask; -+ } -+ -+ USED(b) = dig + extra; -+ -+ if (ISNEG(a)) -+ mp_clear(&tmp); -+ -+ s_mp_clamp(b); -+ return MP_OKAY; -+} -+ -+mp_err mp_trunc(mp_int *a, mp_int *b, mp_digit bits) -+{ -+ mp_err res; -+ mp_size ix, dig = bits / DIGIT_BIT, rembits = bits % DIGIT_BIT; -+ mp_size adig = USED(a); -+ mp_digit padding = ISNEG(a) ? MP_DIGIT_MAX : 0; -+ int extra = (rembits != 0); -+ mp_digit *pa, *pb; -+ mp_int tmp; -+ -+ ARGCHK(a != NULL && b != NULL, MP_BADARG); -+ -+ if (a != b) -+ res = mp_init_size(b, dig + extra); -+ else -+ res = s_mp_pad(b, dig + extra); -+ -+ if (res != MP_OKAY) -+ return res; -+ -+ if (ISNEG(a)) { -+ mp_init(&tmp); -+ if ((res = mp_2comp(a, &tmp, dig + extra)) != MP_OKAY) -+ return res; -+ a = &tmp; -+ } -+ -+ for (pa = DIGITS(a), pb = DIGITS(b), ix = 0; ix < dig; ix++) -+ pb[ix] = (ix < adig) ? pa[ix] : padding; -+ -+ if (rembits) { -+ mp_digit mask = (MP_DIGIT_MAX >> (DIGIT_BIT - rembits)); -+ pb[ix] = ((ix < adig) ? pa[ix] : padding) & mask; -+ } -+ -+ USED(b) = dig + extra; -+ -+ if (ISNEG(a)) -+ mp_clear(&tmp); -+ -+ s_mp_clamp(b); -+ return MP_OKAY; -+} -+ -+mp_err mp_shift(mp_int *a, mp_int *b, int bits) -+{ -+ mp_int tmp; -+ mp_err res; -+ int a_neg = ISNEG(a); -+ -+ if (bits == 0) -+ return mp_copy(a, b); -+ -+ if (a_neg) { -+ mp_size ua = USED(a); -+ mp_init(&tmp); -+ if ((res = mp_2comp(a, &tmp, ua)) != MP_OKAY) -+ return res; -+ SIGN(&tmp) = MP_ZPOS; -+ a = &tmp; -+ } -+ -+ if (bits > 0) -+ res = mp_mul_2d(a, bits, b); -+ else -+ res = mp_div_2d(a, -bits, b, NULL); -+ -+ if (res != MP_OKAY) { -+ if (a_neg) -+ mp_clear(&tmp); -+ return res; -+ } -+ -+ if (a_neg) { -+ int hb, msd; -+ mp_digit *db; -+ -+ mp_clear(&tmp); -+ -+ msd = USED(b)-1; -+ db = DIGITS(b); -+ hb = s_highest_bit(db[msd]); -+ -+ if (hb < DIGIT_BIT) -+ db[msd] |= MP_DIGIT_MAX << hb; -+ -+ if ((res = mp_2comp(b, b, USED(b))) != MP_OKAY) -+ return res; -+ -+ SIGN(b) = MP_NEG; -+ s_mp_clamp(b); -+ } -+ -+ return MP_OKAY; -+} -+ -+mp_err mp_bit(mp_int *a, mp_digit bit) -+{ -+ mp_int tmp; -+ mp_err res; -+ int a_neg = ISNEG(a); -+ int digit = bit / MP_DIGIT_BIT; -+ mp_digit mask = ((mp_digit) 1 << (bit % MP_DIGIT_BIT)); -+ -+ if (a_neg) { -+ mp_init(&tmp); -+ if ((res = mp_2comp(a, &tmp, bit + 1)) != MP_OKAY) -+ return res; -+ SIGN(&tmp) = MP_ZPOS; -+ a = &tmp; -+ } -+ -+ return (DIGITS(a)[digit] & mask) != 0 ? MP_YES : MP_NO; -+} -+ - mp_err mp_to_double(mp_int *mp, double *d) - { - int ix; -Index: mpi-1.8.6/mpi.h -=================================================================== ---- mpi-1.8.6.orig/mpi.h 2015-02-07 19:33:14.612233293 -0800 -+++ mpi-1.8.6/mpi.h 2015-02-07 19:33:19.412149446 -0800 -@@ -54,6 +54,7 @@ - - /* Macros for accessing the mp_int internals */ - #define SIGN(MP) ((MP)->sign) -+#define ISNEG(MP) ((MP)->sign == MP_NEG) - #define USED(MP) ((MP)->used) - #define ALLOC(MP) ((MP)->alloc) - #define DIGITS(MP) ((MP)->dp) -@@ -187,6 +188,18 @@ - #endif /* end MP_NUMTH */ - - /*------------------------------------------------------------------------*/ -+/* Bit ops */ -+mp_err mp_2comp(mp_int *a, mp_int *b, mp_size dig); /* peculiar semantics */ -+mp_err mp_and(mp_int *a, mp_int *b, mp_int *c); -+mp_err mp_or(mp_int *a, mp_int *b, mp_int *c); -+mp_err mp_xor(mp_int *a, mp_int *b, mp_int *c); -+mp_err mp_comp(mp_int *a, mp_int *b); -+mp_err mp_trunc_comp(mp_int *a, mp_int *b, mp_digit bits); -+mp_err mp_trunc(mp_int *a, mp_int *b, mp_digit bits); -+mp_err mp_shift(mp_int *a, mp_int *b, int bits); /* + left, - right */ -+mp_err mp_bit(mp_int *a, mp_digit bit); -+ -+/*------------------------------------------------------------------------*/ - /* Conversions */ - - mp_err mp_to_double(mp_int *mp, double *d); diff --git a/mpi-patches/add-mp-hash b/mpi-patches/add-mp-hash deleted file mode 100644 index 71123678..00000000 --- a/mpi-patches/add-mp-hash +++ /dev/null @@ -1,52 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-02-07 19:32:43.876775527 -0800 -+++ mpi-1.8.6/mpi.c 2015-02-07 19:32:46.612726878 -0800 -@@ -1958,6 +1958,34 @@ - - /* }}} */ - -+unsigned long mp_hash(mp_int *a) -+{ -+#if SIZEOF_LONG > MP_DIGIT_SIZE -+ unsigned long hash; -+ int ix; -+ -+ if (USED(a) >= 2 * SIZEOF_LONG / MP_DIGIT_SIZE) { -+ unsigned long omega = 0; -+ unsigned long alpha = 0; -+ for (ix = 0; ix < SIZEOF_LONG / MP_DIGIT_SIZE; ix++) -+ omega = (omega << MP_DIGIT_BIT) | DIGIT(a, ix); -+ for (ix = USED(a) - SIZEOF_LONG / MP_DIGIT_SIZE; ix < USED(a); ix++) -+ alpha = (alpha << MP_DIGIT_BIT) | DIGIT(a, ix); -+ hash = alpha + omega; -+ } else { -+ hash = 0; -+ -+ for (ix = 0; ix < USED(a); ix++) -+ hash = (hash << MP_DIGIT_BIT) | DIGIT(a, ix); -+ } -+#else -+ mp_digit omega = DIGIT(a, 0); -+ mp_digit alpha = DIGIT(a, USED(a) - 1); -+ unsigned long hash = alpha + omega; -+#endif -+ return SIGN(a) == MP_NEG ? ~hash : hash; -+} -+ - /*------------------------------------------------------------------------*/ - /* {{{ Number theoretic functions */ - -Index: mpi-1.8.6/mpi.h -=================================================================== ---- mpi-1.8.6.orig/mpi.h 2015-02-07 19:32:43.876775527 -0800 -+++ mpi-1.8.6/mpi.h 2015-02-07 19:32:46.612726878 -0800 -@@ -165,6 +165,8 @@ - int mp_isodd(mp_int *a); - int mp_iseven(mp_int *a); - -+unsigned long mp_hash(mp_int *a); -+ - /*------------------------------------------------------------------------*/ - /* Number theoretic */ - diff --git a/mpi-patches/add-mp-set-intptr b/mpi-patches/add-mp-set-intptr deleted file mode 100644 index cbaa9bf4..00000000 --- a/mpi-patches/add-mp-set-intptr +++ /dev/null @@ -1,77 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-02-07 19:32:35.248929450 -0800 -+++ mpi-1.8.6/mpi.c 2015-02-07 19:32:37.136895701 -0800 -@@ -526,6 +526,59 @@ - - /* }}} */ - -+mp_err mp_set_intptr(mp_int *mp, int_ptr_t z) -+{ -+ int_ptr_t v = z > 0 ? z : -z; -+ -+ if (sizeof z > sizeof (mp_digit)) { -+ int ix, shift; -+ const int nd = (sizeof v + sizeof (mp_digit) - 1) / sizeof (mp_digit); -+ -+ ARGCHK(mp != NULL, MP_BADARG); -+ -+ mp_zero(mp); -+ -+ if(z == 0) -+ return MP_OKAY; /* shortcut for zero */ -+ -+ s_mp_grow(mp, nd); -+ -+ USED(mp) = nd; -+ -+ for (ix = 0, shift = 0; ix < nd; ix++, shift += MP_DIGIT_BIT) -+ { -+ DIGIT(mp, ix) = (v >> shift) & MP_DIGIT_MAX; -+ } -+ } else { -+ mp_set(mp, v); -+ } -+ -+ if(z < 0) -+ SIGN(mp) = MP_NEG; -+ -+ return MP_OKAY; -+} -+ -+/* -+ * No checks here: assumes that the mp is in range! -+ */ -+mp_err mp_get_intptr(mp_int *mp, int_ptr_t *z) -+{ -+ int_ptr_t out = 0; -+ -+#if MP_DIGIT_SIZE < SIZEOF_PTR -+ int ix; -+ int nd = USED(mp); -+ for (ix = 0; ix < nd; ix++, out <<= MP_DIGIT_BIT) -+ out = DIGIT(mp, ix); -+#else -+ out = DIGIT(mp, 0); -+#endif -+ -+ *z = (SIGN(mp) == MP_NEG) ? -out : out; -+ return MP_OKAY; -+} -+ - /*------------------------------------------------------------------------*/ - /* {{{ Digit arithmetic */ - -Index: mpi-1.8.6/mpi.h -=================================================================== ---- mpi-1.8.6.orig/mpi.h 2015-02-07 19:32:35.236929664 -0800 -+++ mpi-1.8.6/mpi.h 2015-02-07 19:32:37.136895701 -0800 -@@ -94,6 +94,8 @@ - void mp_zero(mp_int *mp); - void mp_set(mp_int *mp, mp_digit d); - mp_err mp_set_int(mp_int *mp, long z); -+mp_err mp_set_intptr(mp_int *mp, int_ptr_t z); -+mp_err mp_get_intptr(mp_int *mp, int_ptr_t *z); - - /*------------------------------------------------------------------------*/ - /* Single digit arithmetic */ diff --git a/mpi-patches/add-mpi-toradix-with-case b/mpi-patches/add-mpi-toradix-with-case deleted file mode 100644 index e9983bf6..00000000 --- a/mpi-patches/add-mpi-toradix-with-case +++ /dev/null @@ -1,54 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-02-07 19:32:46.612726878 -0800 -+++ mpi-1.8.6/mpi.c 2015-02-07 19:32:48.892686392 -0800 -@@ -2626,9 +2626,9 @@ - - /* }}} */ - --/* {{{ mp_toradix(mp, str, radix) */ -+/* {{{ mp_toradix_case(mp, str, radix, low) */ - --mp_err mp_toradix(mp_int *mp, unsigned char *str, int radix) -+mp_err mp_toradix_case(mp_int *mp, unsigned char *str, int radix, int low) - { - int ix, pos = 0; - -@@ -2659,7 +2659,7 @@ - } - - /* Generate digits, use capital letters */ -- ch = s_mp_todigit(rem, radix, 0); -+ ch = s_mp_todigit(rem, radix, low); - - str[pos++] = ch; - } -@@ -2687,10 +2687,15 @@ - - return MP_OKAY; - --} /* end mp_toradix() */ -+} /* end mp_toradix_case() */ - - /* }}} */ - -+mp_err mp_toradix(mp_int *mp, unsigned char *str, int radix) -+{ -+ return mp_toradix_case(mp, str, radix, 0); -+} -+ - /* {{{ mp_char2value(ch, r) */ - - int mp_char2value(char ch, int r) -Index: mpi-1.8.6/mpi.h -=================================================================== ---- mpi-1.8.6.orig/mpi.h 2015-02-07 19:32:46.612726878 -0800 -+++ mpi-1.8.6/mpi.h 2015-02-07 19:32:48.892686392 -0800 -@@ -213,6 +213,7 @@ - int mp_radix_size(mp_int *mp, int radix); - int mp_value_radix_size(int num, int qty, int radix); - mp_err mp_toradix(mp_int *mp, unsigned char *str, int radix); -+mp_err mp_toradix_case(mp_int *mp, unsigned char *str, int radix, int low); - - int mp_char2value(char ch, int r); - diff --git a/mpi-patches/bit-search-optimizations b/mpi-patches/bit-search-optimizations deleted file mode 100644 index 305d6728..00000000 --- a/mpi-patches/bit-search-optimizations +++ /dev/null @@ -1,300 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-02-07 19:33:01.740459238 -0800 -+++ mpi-1.8.6/mpi.c 2015-02-07 19:33:04.528410164 -0800 -@@ -2919,6 +2919,218 @@ - - /* }}} */ - -+static int s_highest_bit(mp_digit n) -+{ -+#if MP_DIGIT_SIZE == 8 -+ if (n & 0xFFFFFFFF00000000) { -+ if (n & 0xFFFF000000000000) { -+ if (n & 0xFF00000000000000) { -+ if (n & 0xF000000000000000) { -+ if (n & 0xC000000000000000) -+ return (n & 0x8000000000000000) ? 64 : 63; -+ else -+ return (n & 0x2000000000000000) ? 62 : 61; -+ } else { -+ if (n & 0x0C00000000000000) -+ return (n & 0x0800000000000000) ? 60 : 59; -+ else -+ return (n & 0x0200000000000000) ? 58 : 57; -+ } -+ } else { -+ if (n & 0x00F0000000000000) { -+ if (n & 0x00C0000000000000) -+ return (n & 0x0080000000000000) ? 56 : 55; -+ else -+ return (n & 0x0020000000000000) ? 54 : 53; -+ } else { -+ if (n & 0x000C000000000000) -+ return (n & 0x0008000000000000) ? 52 : 51; -+ else -+ return (n & 0x0002000000000000) ? 50 : 49; -+ } -+ } -+ } else { -+ if (n & 0x0000FF0000000000) { -+ if (n & 0x0000F00000000000) { -+ if (n & 0x0000C00000000000) -+ return (n & 0x0000800000000000) ? 48 : 47; -+ else -+ return (n & 0x0000200000000000) ? 46 : 45; -+ } else { -+ if (n & 0x00000C0000000000) -+ return (n & 0x0000080000000000) ? 44 : 43; -+ else -+ return (n & 0x0000020000000000) ? 42 : 41; -+ } -+ } else { -+ if (n & 0x000000F000000000) { -+ if (n & 0x000000C000000000) -+ return (n & 0x0000008000000000) ? 40 : 39; -+ else -+ return (n & 0x0000002000000000) ? 38 : 37; -+ } else { -+ if (n & 0x0000000C00000000) -+ return (n & 0x0000000800000000) ? 36 : 35; -+ else -+ return (n & 0x0000000200000000) ? 34 : 33; -+ } -+ } -+ } -+ } else { -+ if (n & 0x00000000FFFF0000) { -+ if (n & 0x00000000FF000000) { -+ if (n & 0x00000000F0000000) { -+ if (n & 0x00000000C0000000) -+ return (n & 0x0000000080000000) ? 32 : 31; -+ else -+ return (n & 0x0000000020000000) ? 30 : 29; -+ } else { -+ if (n & 0x000000000C000000) -+ return (n & 0x0000000008000000) ? 28 : 27; -+ else -+ return (n & 0x0000000002000000) ? 26 : 25; -+ } -+ } else { -+ if (n & 0x0000000000F00000) { -+ if (n & 0x0000000000C00000) -+ return (n & 0x0000000000800000) ? 24 : 23; -+ else -+ return (n & 0x0000000000200000) ? 22 : 21; -+ } else { -+ if (n & 0x00000000000C0000) -+ return (n & 0x0000000000080000) ? 20 : 19; -+ else -+ return (n & 0x0000000000020000) ? 18 : 17; -+ } -+ } -+ } else { -+ if (n & 0x000000000000FF00) { -+ if (n & 0x000000000000F000) { -+ if (n & 0x000000000000C000) -+ return (n & 0x0000000000008000) ? 16 : 15; -+ else -+ return (n & 0x0000000000002000) ? 14 : 13; -+ } else { -+ if (n & 0x0000000000000C00) -+ return (n & 0x0000000000000800) ? 12 : 11; -+ else -+ return (n & 0x0000000000000200) ? 10 : 9; -+ } -+ } else { -+ if (n & 0x00000000000000F0) { -+ if (n & 0x00000000000000C0) -+ return (n & 0x0000000000000080) ? 8 : 7; -+ else -+ return (n & 0x0000000000000020) ? 6 : 5; -+ } else { -+ if (n & 0x000000000000000C) -+ return (n & 0x0000000000000008) ? 4 : 3; -+ else -+ return (n & 0x0000000000000002) ? 2 : (n ? 1 : 0); -+ } -+ } -+ } -+ } -+#elif MP_DIGIT_SIZE == 4 -+ if (n & 0xFFFF0000) { -+ if (n & 0xFF000000) { -+ if (n & 0xF0000000) { -+ if (n & 0xC0000000) -+ return (n & 0x80000000) ? 32 : 31; -+ else -+ return (n & 0x20000000) ? 30 : 29; -+ } else { -+ if (n & 0x0C000000) -+ return (n & 0x08000000) ? 28 : 27; -+ else -+ return (n & 0x02000000) ? 26 : 25; -+ } -+ } else { -+ if (n & 0x00F00000) { -+ if (n & 0x00C00000) -+ return (n & 0x00800000) ? 24 : 23; -+ else -+ return (n & 0x00200000) ? 22 : 21; -+ } else { -+ if (n & 0x000C0000) -+ return (n & 0x00080000) ? 20 : 19; -+ else -+ return (n & 0x00020000) ? 18 : 17; -+ } -+ } -+ } else { -+ if (n & 0x0000FF00) { -+ if (n & 0x0000F000) { -+ if (n & 0x0000C000) -+ return (n & 0x00008000) ? 16 : 15; -+ else -+ return (n & 0x00002000) ? 14 : 13; -+ } else { -+ if (n & 0x00000C00) -+ return (n & 0x00000800) ? 12 : 11; -+ else -+ return (n & 0x00000200) ? 10 : 9; -+ } -+ } else { -+ if (n & 0x000000F0) { -+ if (n & 0x000000C0) -+ return (n & 0x00000080) ? 8 : 7; -+ else -+ return (n & 0x00000020) ? 6 : 5; -+ } else { -+ if (n & 0x0000000C) -+ return (n & 0x00000008) ? 4 : 3; -+ else -+ return (n & 0x00000002) ? 2 : (n ? 1 : 0); -+ } -+ } -+ } -+#elif MP_DIGIT_SIZE == 2 -+ if (n & 0xFF00) { -+ if (n & 0xF000) { -+ if (n & 0xC000) -+ return (n & 0x8000) ? 16 : 15; -+ else -+ return (n & 0x2000) ? 14 : 13; -+ } else { -+ if (n & 0x0C00) -+ return (n & 0x0800) ? 12 : 11; -+ else -+ return (n & 0x0200) ? 10 : 9; -+ } -+ } else { -+ if (n & 0x00F0) { -+ if (n & 0x00C0) -+ return (n & 0x0080) ? 8 : 7; -+ else -+ return (n & 0x0020) ? 6 : 5; -+ } else { -+ if (n & 0x000C) -+ return (n & 0x0008) ? 4 : 3; -+ else -+ return (n & 0x0002) ? 2 : (n ? 1 : 0); -+ } -+ } -+#elif MP_DIGIT_SIZE == 1 -+ if (n & 0xF0) { -+ if (n & 0xC0) -+ return (n & 0x80) ? 8 : 7; -+ else -+ return (n & 0x20) ? 6 : 5; -+ } else { -+ if (n & 0x0C) -+ return (n & 0x08) ? 4 : 3; -+ else -+ return (n & 0x02) ? 2 : (n ? 1 : 0); -+ } -+#else -+#error fixme: unsupported MP_DIGIT_SIZE -+#endif -+ /* notreached */ -+ abort(); -+} -+ -+ - /* {{{ s_mp_exch(a, b) */ - - /* Exchange the data for a and b; (b, a) = (a, b) */ -@@ -3196,10 +3408,9 @@ - mp_digit t, d = 0; - - t = DIGIT(b, USED(b) - 1); -- while(t < (RADIX / 2)) { -- t <<= 1; -- ++d; -- } -+ -+ d = MP_DIGIT_BIT - s_highest_bit(t); -+ t <<= d; - - if(d != 0) { - s_mp_mul_2d(a, d); -@@ -3982,27 +4193,23 @@ - - d = DIGIT(v, uv - 1); /* most significant digit of v */ - -- while(d && ((d & 1) == 0)) { -- d >>= 1; -- ++extra; -- } -- -- if(d == 1) { -- ix = uv - 2; -- dp = DIGITS(v) + ix; -+ /* quick test */ -+ if ((d & (d - 1)) != 0) -+ return -1; /* not a power of two */ - -- while(ix >= 0) { -- if(*dp) -- return -1; /* not a power of two */ -+ extra = s_highest_bit(d) - 1; - -- --dp; --ix; -- } -+ ix = uv - 2; -+ dp = DIGITS(v) + ix; - -- return ((uv - 1) * DIGIT_BIT) + extra; -- } -+ while(ix >= 0) { -+ if(*dp) -+ return -1; /* not a power of two */ - -- return -1; -+ --dp; --ix; -+ } - -+ return ((uv - 1) * DIGIT_BIT) + extra; - } /* end s_mp_ispow2() */ - - /* }}} */ -@@ -4011,17 +4218,12 @@ - - int s_mp_ispow2d(mp_digit d) - { -- int pow = 0; -- -- while((d & 1) == 0) { -- ++pow; d >>= 1; -- } -- -- if(d == 1) -- return pow; -- -- return -1; -+ /* quick test */ -+ if ((d & (d - 1)) != 0) -+ return -1; /* not a power of two */ - -+ /* If d == 0, s_highest_bit returns 0, thus we return -1. */ -+ return s_highest_bit(d) - 1; - } /* end s_mp_ispow2d() */ - - /* }}} */ diff --git a/mpi-patches/config-types b/mpi-patches/config-types deleted file mode 100644 index a2cb137b..00000000 --- a/mpi-patches/config-types +++ /dev/null @@ -1,122 +0,0 @@ -Index: mpi-1.8.6/mpi-types.h -=================================================================== ---- mpi-1.8.6.orig/mpi-types.h -+++ mpi-1.8.6/mpi-types.h -@@ -1,17 +1,56 @@ --/* Type definitions generated by 'types.pl' */ -+/* -+ * Universal. We can further tweak these by making them -+ * bitfields inside the mp_int struct. -+ */ -+typedef int mp_sign; -+typedef int mp_size; - --typedef char mp_sign; --typedef unsigned short mp_digit; /* 2 byte type */ --typedef unsigned int mp_word; /* 4 byte type */ --typedef unsigned int mp_size; --typedef int mp_err; -+/* -+ * Universal. Does not need platform configuration. -+ */ -+typedef int mp_err; - --#define MP_DIGIT_BIT (CHAR_BIT*sizeof(mp_digit)) --#define MP_DIGIT_MAX USHRT_MAX --#define MP_WORD_BIT (CHAR_BIT*sizeof(mp_word)) --#define MP_WORD_MAX UINT_MAX -+#if HAVE_USUPERLONG_T && HAVE_ULONGLONG_T && \ -+ SIZEOF_SUPERLONG_T / 2 == SIZEOF_LONGLONG_T && \ -+ SIZEOF_PTR >= SIZEOF_LONGLONG_T -+ typedef ulonglong_t mp_digit; -+ typedef usuperlong_t mp_word; -+ #define MP_DIGIT_SIZE SIZEOF_LONGLONG_T -+ #define DIGIT_FMT "%" #SIZEOF_SUPERLONG_T "llx" -+#elif HAVE_ULONGLONG_T && SIZEOF_LONGLONG_T / 2 == SIZEOF_LONG && \ -+ SIZEOF_PTR >= SIZEOF_LONG -+ typedef unsigned long mp_digit; -+ typedef ulonglong_t mp_word; -+ #define MP_DIGIT_SIZE SIZEOF_LONG -+ #define DIGIT_FMT "%" #SIZEOF_LONGLONG_T "lx" -+#elif HAVE_ULONGLONG_T && SIZEOF_LONGLONG_T / 2 == SIZEOF_INT && \ -+ SIZEOF_PTR >= SIZEOF_INT -+ typedef unsigned int mp_digit; -+ typedef ulonglong_t mp_word; -+ #define MP_DIGIT_SIZE SIZEOF_INT -+ #define DIGIT_FMT "%" #SIZEOF_LONGLONG_T "lx" -+#elif SIZEOF_LONG / 2 == SIZEOF_INT && SIZEOF_PTR >= SIZEOF_INT -+ typedef unsigned int mp_digit; -+ typedef unsigned long mp_word; -+ #define MP_DIGIT_SIZE SIZEOF_INT -+ #define DIGIT_FMT "%" #SIZEOF_LONG "x" -+#elif SIZEOF_INT / 2 == SIZEOF_SHORT -+ typedef unsigned short mp_digit; -+ typedef unsigned int mp_word; -+ #define MP_DIGIT_SIZE SIZEOF_SHORT -+ #define DIGIT_FMT "%" #SIZEOF_INT "x" -+#elif SIZEOF_SHORT == 2 -+ typedef unsigned char mp_digit; -+ typedef unsigned short mp_word; -+ #define MP_DIGIT_SIZE 1 -+ #define DIGIT_FMT "%" #SIZEOF_SHORT "x" -+#else -+ #error Failure to configure MPI types on this target platform -+#endif - --#define RADIX (MP_DIGIT_MAX+1) -+#define MP_DIGIT_BIT ((int) (CHAR_BIT*sizeof(mp_digit))) -+#define MP_DIGIT_MAX ((mp_digit) -1) -+#define MP_WORD_BIT ((int) (CHAR_BIT*sizeof(mp_word))) -+#define MP_WORD_MAX ((mp_word) -1) - --#define MP_DIGIT_SIZE 2 --#define DIGIT_FMT "%04X" -+#define RADIX (((mp_word) MP_DIGIT_MAX) + 1) -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c -+++ mpi-1.8.6/mpi.c -@@ -9,6 +9,7 @@ - $Id: mpi.c,v 1.1 2004/02/08 04:29:29 sting Exp $ - */ - -+#include "config.h" - #include "mpi.h" - #include <stdlib.h> - #include <string.h> -Index: mpi-1.8.6/mplogic.c -=================================================================== ---- mpi-1.8.6.orig/mplogic.c -+++ mpi-1.8.6/mplogic.c -@@ -9,6 +9,7 @@ - $Id: mplogic.c,v 1.1 2004/02/08 04:29:29 sting Exp $ - */ - -+#include "config.h" - #include "mplogic.h" - #include <stdlib.h> - -Index: mpi-1.8.6/mpprime.c -=================================================================== ---- mpi-1.8.6.orig/mpprime.c -+++ mpi-1.8.6/mpprime.c -@@ -10,6 +10,7 @@ - $Id: mpprime.c,v 1.1 2004/02/08 04:29:29 sting Exp $ - */ - -+#include "config.h" - #include "mpprime.h" - #include <stdlib.h> - -Index: mpi-1.8.6/mprsa.c -=================================================================== ---- mpi-1.8.6.orig/mprsa.c -+++ mpi-1.8.6/mprsa.c -@@ -11,6 +11,7 @@ - $Id: mprsa.c,v 1.1 2004/02/08 04:29:29 sting Exp $ - */ - -+#include "config.h" - #include "mprsa.h" - #include <stdlib.h> - #include <string.h> diff --git a/mpi-patches/disable-make b/mpi-patches/disable-make deleted file mode 100644 index 04e53d3d..00000000 --- a/mpi-patches/disable-make +++ /dev/null @@ -1,18 +0,0 @@ -Index: mpi-1.8.6/Makefile -=================================================================== ---- mpi-1.8.6.orig/Makefile 2012-04-10 20:41:06.333743757 -0700 -+++ mpi-1.8.6/Makefile 2012-04-10 20:43:28.337576007 -0700 -@@ -14,6 +14,13 @@ - ## 'mpi-config.h', which you should set as appropriate. - ## - -+.PHONY: all -+all: -+ @echo "Do not use this Makefile! TXR pulls in the MPI sources into" -+ @echo "its own build environment. If something isn't working" -+ @echo "it has to be debugged properly." -+ exit 1 -+ - include Makefile.base - - ###---------------------------------------------------------------------- diff --git a/mpi-patches/eliminate-locale-dependencies b/mpi-patches/eliminate-locale-dependencies deleted file mode 100644 index 6ab1b63a..00000000 --- a/mpi-patches/eliminate-locale-dependencies +++ /dev/null @@ -1,45 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-03-29 22:04:45.548237064 -0700 -+++ mpi-1.8.6/mpi.c 2015-03-30 08:17:35.252749065 -0700 -@@ -4693,17 +4693,22 @@ - int s_mp_tovalue(int ch, int r) - { - int val, xch; -- -- if(r > 36) -- xch = ch; -+ -+ /* For bases up to 36, the letters of the alphabet are -+ case-insensitive and denote digits valued 10 through 36. -+ For bases greater than 36, the lower case letters have -+ their own meaning and denote values past 36. */ -+ -+ if (r <= 36 && ch >= 'a' && ch <= 'z') -+ xch = ch - 'a' + 'A'; - else -- xch = toupper(ch); -+ xch = ch; - -- if(isdigit(xch)) -+ if(xch >= '0' && xch <= '9') - val = xch - '0'; -- else if(isupper(xch)) -+ else if(xch >= 'A' && xch <= 'Z') - val = xch - 'A' + 10; -- else if(islower(xch)) -+ else if(xch >= 'a' && xch <= 'z') - val = xch - 'a' + 36; - else if(xch == '+') - val = 62; -@@ -4741,8 +4746,8 @@ - - ch = s_dmap_1[val]; - -- if(r <= 36 && low) -- ch = tolower(ch); -+ if(low && val > 9 && r <= 36) -+ ch = ch - 'A' + 'a'; - - return ch; - diff --git a/mpi-patches/export-mp-eq b/mpi-patches/export-mp-eq deleted file mode 100644 index 121aa9c7..00000000 --- a/mpi-patches/export-mp-eq +++ /dev/null @@ -1,34 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-02-07 19:32:37.136895701 -0800 -+++ mpi-1.8.6/mpi.c 2015-02-07 19:32:43.876775527 -0800 -@@ -84,14 +84,6 @@ - - /* }}} */ - --/* {{{ Comparison constants */ -- --#define MP_LT -1 --#define MP_EQ 0 --#define MP_GT 1 -- --/* }}} */ -- - /* {{{ Constant strings */ - - /* Constant strings returned by mp_strerror() */ -Index: mpi-1.8.6/mpi.h -=================================================================== ---- mpi-1.8.6.orig/mpi.h 2015-02-07 19:32:37.136895701 -0800 -+++ mpi-1.8.6/mpi.h 2015-02-07 19:32:43.876775527 -0800 -@@ -42,6 +42,10 @@ - #define MP_UNDEF -5 /* answer is undefined */ - #define MP_LAST_CODE MP_UNDEF - -+#define MP_LT -1 -+#define MP_EQ 0 -+#define MP_GT 1 -+ - #include "mpi-types.h" - - /* Included for compatibility... */ diff --git a/mpi-patches/faster-square-root b/mpi-patches/faster-square-root deleted file mode 100644 index c8663314..00000000 --- a/mpi-patches/faster-square-root +++ /dev/null @@ -1,189 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-02-07 19:33:04.528410164 -0800 -+++ mpi-1.8.6/mpi.c 2015-02-07 19:33:11.780282866 -0800 -@@ -156,6 +156,9 @@ - mp_err s_mp_grow(mp_int *mp, mp_size min); /* increase allocated size */ - mp_err s_mp_pad(mp_int *mp, mp_size min); /* left pad with zeroes */ - -+int s_highest_bit_mp(mp_int *a); -+mp_err s_mp_set_bit(mp_int *a, int bit); -+ - void s_mp_clamp(mp_int *mp); /* clip leading zeroes */ - - void s_mp_exch(mp_int *a, mp_int *b); /* swap a and b in place */ -@@ -1533,77 +1536,61 @@ - - /* {{{ mp_sqrt(a, b) */ - --/* -- mp_sqrt(a, b) -- -- Compute the integer square root of a, and store the result in b. -- Uses an integer-arithmetic version of Newton's iterative linear -- approximation technique to determine this value; the result has the -- following two properties: -- -- b^2 <= a -- (b+1)^2 >= a -- -- It is a range error to pass a negative value. -- */ - mp_err mp_sqrt(mp_int *a, mp_int *b) - { -- mp_int x, t; -- mp_err res; -+ int mask_shift; -+ mp_int root, guess, *proot = &root, *pguess = &guess; -+ mp_int guess_sqr; -+ mp_err err = MP_MEM; - - ARGCHK(a != NULL && b != NULL, MP_BADARG); - -- /* Cannot take square root of a negative value */ -- if(SIGN(a) == MP_NEG) -+ if (mp_cmp_z(b) == MP_LT) - return MP_RANGE; - -- /* Special cases for zero and one, trivial */ -- if(mp_cmp_d(a, 0) == MP_EQ || mp_cmp_d(a, 1) == MP_EQ) -- return mp_copy(a, b); -- -- /* Initialize the temporaries we'll use below */ -- if((res = mp_init_size(&t, USED(a))) != MP_OKAY) -- return res; -- -- /* Compute an initial guess for the iteration as a itself */ -- if((res = mp_init_copy(&x, a)) != MP_OKAY) -- goto X; -- -- for(;;) { -- /* t = (x * x) - a */ -- mp_copy(&x, &t); /* can't fail, t is big enough for original x */ -- if((res = mp_sqr(&t, &t)) != MP_OKAY || -- (res = mp_sub(&t, a, &t)) != MP_OKAY) -- goto CLEANUP; -- -- /* t = t / 2x */ -- s_mp_mul_2(&x); -- if((res = mp_div(&t, &x, &t, NULL)) != MP_OKAY) -- goto CLEANUP; -- s_mp_div_2(&x); -- -- /* Terminate the loop, if the quotient is zero */ -- if(mp_cmp_z(&t) == MP_EQ) -- break; -- -- /* x = x - t */ -- if((res = mp_sub(&x, &t, &x)) != MP_OKAY) -- goto CLEANUP; -- -+ if ((err = mp_init(&root))) -+ goto out; -+ if ((err = mp_init(&guess))) -+ goto cleanup_root; -+ if ((err = mp_init(&guess_sqr))) -+ goto cleanup_guess; -+ -+ for (mask_shift = s_highest_bit_mp(a) / 2; mask_shift >= 0; mask_shift--) { -+ mp_int *temp; -+ int cmp; -+ -+ if ((err = mp_copy(proot, pguess))) -+ goto cleanup; -+ if ((err = s_mp_set_bit(pguess, mask_shift))) -+ goto cleanup; -+ if ((err = mp_copy(pguess, &guess_sqr))) -+ goto cleanup; -+ if ((err = s_mp_sqr(&guess_sqr))) -+ goto cleanup; -+ -+ cmp = s_mp_cmp(&guess_sqr, a); -+ -+ if (cmp < 0) { -+ temp = proot; -+ proot = pguess; -+ pguess = temp; -+ } else if (cmp == 0) { -+ proot = pguess; -+ break; -+ } - } - -- /* Copy result to output parameter */ -- mp_sub_d(&x, 1, &x); -- s_mp_exch(&x, b); -- -- CLEANUP: -- mp_clear(&x); -- X: -- mp_clear(&t); -- -- return res; -- --} /* end mp_sqrt() */ -+ err = mp_copy(proot, b); -+ -+cleanup: -+ mp_clear(&guess_sqr); -+cleanup_guess: -+ mp_clear(&guess); -+cleanup_root: -+ mp_clear(&root); -+out: -+ return err; -+} - - /* }}} */ - -@@ -2552,21 +2539,9 @@ - - int mp_count_bits(mp_int *mp) - { -- int len; -- mp_digit d; -- - ARGCHK(mp != NULL, MP_BADARG); - -- len = DIGIT_BIT * (USED(mp) - 1); -- d = DIGIT(mp, USED(mp) - 1); -- -- while(d != 0) { -- ++len; -- d >>= 1; -- } -- -- return len; -- -+ return s_highest_bit_mp(mp); - } /* end mp_count_bits() */ - - /* }}} */ -@@ -3130,6 +3105,27 @@ - abort(); - } - -+int s_highest_bit_mp(mp_int *a) -+{ -+ int nd1 = USED(a) - 1; -+ return s_highest_bit(DIGIT(a, nd1)) + nd1 * MP_DIGIT_BIT; -+} -+ -+mp_err s_mp_set_bit(mp_int *a, int bit) -+{ -+ int nd = (bit + MP_DIGIT_BIT) / MP_DIGIT_BIT; -+ int nbit = bit - (nd - 1) * MP_DIGIT_BIT; -+ mp_err res; -+ -+ if (nd == 0) -+ return MP_OKAY; -+ -+ if ((res = s_mp_pad(a, nd)) != MP_OKAY) -+ return res; -+ -+ DIGIT(a, nd - 1) |= ((mp_digit) 1 << nbit); -+ return MP_OKAY; -+} - - /* {{{ s_mp_exch(a, b) */ - diff --git a/mpi-patches/fix-bad-shifts b/mpi-patches/fix-bad-shifts deleted file mode 100644 index acd77f51..00000000 --- a/mpi-patches/fix-bad-shifts +++ /dev/null @@ -1,49 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-02-07 19:32:58.456517144 -0800 -+++ mpi-1.8.6/mpi.c 2015-02-07 19:33:01.740459238 -0800 -@@ -762,7 +762,7 @@ - if((pow = s_mp_ispow2d(d)) >= 0) { - mp_digit mask; - -- mask = (1 << pow) - 1; -+ mask = ((mp_digit) 1 << pow) - 1; - rem = DIGIT(a, 0) & mask; - - if(q) { -@@ -3079,7 +3079,7 @@ - return; - - /* Flush all the bits above 2^d in its digit */ -- dmask = (1 << nbit) - 1; -+ dmask = ((mp_digit) 1 << nbit) - 1; - dp[ndig] &= dmask; - - /* Flush all digits above the one with 2^d in it */ -@@ -3112,7 +3112,7 @@ - dp = DIGITS(mp); used = USED(mp); - d %= DIGIT_BIT; - -- mask = (1 << d) - 1; -+ mask = ((mp_digit) 1 << d) - 1; - - /* If the shift requires another digit, make sure we've got one to - work with */ -@@ -3160,7 +3160,7 @@ - s_mp_rshd(mp, d / DIGIT_BIT); - d %= DIGIT_BIT; - -- mask = (1 << d) - 1; -+ mask = ((mp_digit) 1 << d) - 1; - - save = 0; - for(ix = USED(mp) - 1; ix >= 0; ix--) { -@@ -3840,7 +3840,7 @@ - if((res = s_mp_pad(a, dig + 1)) != MP_OKAY) - return res; - -- DIGIT(a, dig) |= (1 << bit); -+ DIGIT(a, dig) |= ((mp_digit) 1 << bit); - - return MP_OKAY; - diff --git a/mpi-patches/fix-ctype-warnings b/mpi-patches/fix-ctype-warnings deleted file mode 100644 index 5ec95101..00000000 --- a/mpi-patches/fix-ctype-warnings +++ /dev/null @@ -1,31 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-02-07 19:33:14.608233363 -0800 -+++ mpi-1.8.6/mpi.c 2015-02-07 19:33:17.280186661 -0800 -@@ -198,7 +198,7 @@ - int s_mp_ispow2(mp_int *v); /* is v a power of 2? */ - int s_mp_ispow2d(mp_digit d); /* is d a power of 2? */ - --int s_mp_tovalue(char ch, int r); /* convert ch to value */ -+int s_mp_tovalue(int ch, int r); /* convert ch to value */ - char s_mp_todigit(int val, int r, int low); /* convert val to digit */ - int s_mp_outlen(int bits, int r); /* output length in bytes */ - -@@ -4262,7 +4262,7 @@ - The results will be odd if you use a radix < 2 or > 62, you are - expected to know what you're up to. - */ --int s_mp_tovalue(char ch, int r) -+int s_mp_tovalue(int ch, int r) - { - int val, xch; - -@@ -4306,7 +4306,7 @@ - - char s_mp_todigit(int val, int r, int low) - { -- char ch; -+ int ch; - - if(val < 0 || val >= r) - return 0; diff --git a/mpi-patches/fix-mult-bug b/mpi-patches/fix-mult-bug deleted file mode 100644 index 5ddb3094..00000000 --- a/mpi-patches/fix-mult-bug +++ /dev/null @@ -1,58 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-02-07 19:32:48.892686392 -0800 -+++ mpi-1.8.6/mpi.c 2015-02-07 19:32:53.524604501 -0800 -@@ -3266,7 +3266,7 @@ - unless absolutely necessary. - */ - max = USED(a); -- w = dp[max - 1] * d; -+ w = dp[max - 1] * (mp_word) d; - if(CARRYOUT(w) != 0) { - if((res = s_mp_pad(a, max + 1)) != MP_OKAY) - return res; -@@ -3274,7 +3274,7 @@ - } - - for(ix = 0; ix < max; ix++) { -- w = (dp[ix] * d) + k; -+ w = (dp[ix] * (mp_word) d) + k; - dp[ix] = ACCUM(w); - k = CARRYOUT(w); - } -@@ -3491,7 +3491,7 @@ - pa = DIGITS(a); - for(jx = 0; jx < ua; ++jx, ++pa) { - pt = pbt + ix + jx; -- w = *pb * *pa + k + *pt; -+ w = *pb * (mp_word) *pa + k + *pt; - *pt = ACCUM(w); - k = CARRYOUT(w); - } -@@ -3573,7 +3573,7 @@ - if(*pa1 == 0) - continue; - -- w = DIGIT(&tmp, ix + ix) + (*pa1 * *pa1); -+ w = DIGIT(&tmp, ix + ix) + (*pa1 * (mp_word) *pa1); - - pbt[ix + ix] = ACCUM(w); - k = CARRYOUT(w); -@@ -3595,7 +3595,7 @@ - pt = pbt + ix + jx; - - /* Compute the multiplicative step */ -- w = *pa1 * *pa2; -+ w = *pa1 * (mp_word) *pa2; - - /* If w is more than half MP_WORD_MAX, the doubling will - overflow, and we need to record a carry out into the next -@@ -3639,7 +3639,7 @@ - */ - kx = 1; - while(k) { -- k = pbt[ix + jx + kx] + 1; -+ k = (mp_word) pbt[ix + jx + kx] + 1; - pbt[ix + jx + kx] = ACCUM(k); - k = CARRYOUT(k); - ++kx; diff --git a/mpi-patches/fix-warnings b/mpi-patches/fix-warnings deleted file mode 100644 index c35e4ead..00000000 --- a/mpi-patches/fix-warnings +++ /dev/null @@ -1,61 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2011-12-08 21:03:20.000000000 -0800 -+++ mpi-1.8.6/mpi.c 2011-12-08 21:05:04.000000000 -0800 -@@ -2401,7 +2401,7 @@ - int ix; - - d = *dp; -- for(ix = 0; ix < sizeof(mp_digit); ++ix) { -+ for(ix = 0; ix < (int) sizeof(mp_digit); ++ix) { - *spos = d & UCHAR_MAX; - d >>= CHAR_BIT; - ++spos; -@@ -2598,10 +2598,10 @@ - /* Reverse the digits and sign indicator */ - ix = 0; - while(ix < pos) { -- char tmp = str[ix]; -+ char tmp2 = str[ix]; - - str[ix] = str[pos]; -- str[pos] = tmp; -+ str[pos] = tmp2; - ++ix; - --pos; - } -@@ -2952,10 +2952,10 @@ - void s_mp_mod_2d(mp_int *mp, mp_digit d) - { - unsigned int ndig = (d / DIGIT_BIT), nbit = (d % DIGIT_BIT); -- unsigned int ix; -+ int ix; - mp_digit dmask, *dp = DIGITS(mp); - -- if(ndig >= USED(mp)) -+ if((int) ndig >= USED(mp)) - return; - - /* Flush all the bits above 2^d in its digit */ -Index: mpi-1.8.6/mplogic.c -=================================================================== ---- mpi-1.8.6.orig/mplogic.c 2011-12-08 21:03:20.000000000 -0800 -+++ mpi-1.8.6/mplogic.c 2011-12-08 21:05:16.000000000 -0800 -@@ -290,7 +290,7 @@ - for(ix = 0; ix < USED(a); ix++) { - cur = DIGIT(a, ix); - -- for(db = 0; db < sizeof(mp_digit); db++) { -+ for(db = 0; db < (int) sizeof(mp_digit); db++) { - reg = (cur >> (CHAR_BIT * db)) & UCHAR_MAX; - - nset += bitc[reg]; -@@ -319,7 +319,7 @@ - for(ix = 0; ix < USED(a); ix++) { - cur = DIGIT(a, ix); - -- for(db = 0; db < sizeof(mp_digit); db++) { -+ for(db = 0; db < (int) sizeof(mp_digit); db++) { - reg = (cur >> (CHAR_BIT * db)) & UCHAR_MAX; - - nset += bitc[UCHAR_MAX - reg]; diff --git a/mpi-patches/mpi-set-double-intptr b/mpi-patches/mpi-set-double-intptr deleted file mode 100644 index 4cd89766..00000000 --- a/mpi-patches/mpi-set-double-intptr +++ /dev/null @@ -1,55 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-02-07 19:32:56.016560235 -0800 -+++ mpi-1.8.6/mpi.c 2015-02-07 19:32:58.456517144 -0800 -@@ -571,6 +571,36 @@ - return MP_OKAY; - } - -+#ifdef HAVE_DOUBLE_INTPTR_T -+mp_err mp_set_double_intptr(mp_int *mp, double_intptr_t z) -+{ -+ int ix, shift; -+ double_intptr_t v = z > 0 ? z : -z; -+ const int nd = (sizeof v + sizeof (mp_digit) - 1) / sizeof (mp_digit); -+ -+ ARGCHK(mp != NULL, MP_BADARG); -+ -+ mp_zero(mp); -+ -+ if(z == 0) -+ return MP_OKAY; /* shortcut for zero */ -+ -+ s_mp_grow(mp, nd); -+ -+ USED(mp) = nd; -+ -+ for (ix = 0, shift = 0; ix < nd; ix++, shift += MP_DIGIT_BIT) -+ { -+ DIGIT(mp, ix) = (v >> shift) & MP_DIGIT_MAX; -+ } -+ -+ if(z < 0) -+ SIGN(mp) = MP_NEG; -+ -+ return MP_OKAY; -+} -+#endif -+ - mp_err mp_set_word(mp_int *mp, mp_word w, int sign) - { - USED(mp) = 2; -Index: mpi-1.8.6/mpi.h -=================================================================== ---- mpi-1.8.6.orig/mpi.h 2015-02-07 19:32:56.016560235 -0800 -+++ mpi-1.8.6/mpi.h 2015-02-07 19:32:58.456517144 -0800 -@@ -100,6 +100,9 @@ - mp_err mp_set_int(mp_int *mp, long z); - mp_err mp_set_intptr(mp_int *mp, int_ptr_t z); - mp_err mp_get_intptr(mp_int *mp, int_ptr_t *z); -+#ifdef HAVE_DOUBLE_INTPTR_T -+mp_err mp_set_double_intptr(mp_int *mp, double_intptr_t z); -+#endif - mp_err mp_set_word(mp_int *mp, mp_word w, int sign); - - /*------------------------------------------------------------------------*/ diff --git a/mpi-patches/mpi-set-mpi-word b/mpi-patches/mpi-set-mpi-word deleted file mode 100644 index b696037e..00000000 --- a/mpi-patches/mpi-set-mpi-word +++ /dev/null @@ -1,32 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-02-07 19:32:53.524604501 -0800 -+++ mpi-1.8.6/mpi.c 2015-02-07 19:32:56.016560235 -0800 -@@ -571,6 +571,15 @@ - return MP_OKAY; - } - -+mp_err mp_set_word(mp_int *mp, mp_word w, int sign) -+{ -+ USED(mp) = 2; -+ DIGIT(mp, 0) = w & MP_DIGIT_MAX; -+ DIGIT(mp, 1) = w >> MP_DIGIT_BIT; -+ SIGN(mp) = sign; -+ return MP_OKAY; -+} -+ - /*------------------------------------------------------------------------*/ - /* {{{ Digit arithmetic */ - -Index: mpi-1.8.6/mpi.h -=================================================================== ---- mpi-1.8.6.orig/mpi.h 2015-02-07 19:32:48.892686392 -0800 -+++ mpi-1.8.6/mpi.h 2015-02-07 19:32:56.016560235 -0800 -@@ -100,6 +100,7 @@ - mp_err mp_set_int(mp_int *mp, long z); - mp_err mp_set_intptr(mp_int *mp, int_ptr_t z); - mp_err mp_get_intptr(mp_int *mp, int_ptr_t *z); -+mp_err mp_set_word(mp_int *mp, mp_word w, int sign); - - /*------------------------------------------------------------------------*/ - /* Single digit arithmetic */ diff --git a/mpi-patches/mpi-to-double b/mpi-patches/mpi-to-double deleted file mode 100644 index 3facb923..00000000 --- a/mpi-patches/mpi-to-double +++ /dev/null @@ -1,58 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-02-07 19:33:11.780282866 -0800 -+++ mpi-1.8.6/mpi.c 2015-02-07 19:33:14.608233363 -0800 -@@ -14,6 +14,7 @@ - #include <stdlib.h> - #include <string.h> - #include <ctype.h> -+#include <math.h> - - typedef unsigned char mem_t; - extern mem_t *chk_calloc(size_t n, size_t size); -@@ -2333,6 +2334,29 @@ - - /* }}} */ - -+mp_err mp_to_double(mp_int *mp, double *d) -+{ -+ int ix; -+ mp_size used = USED(mp); -+ mp_digit *dp = DIGITS(mp); -+ static double mult; -+ double out = dp[used - 1]; -+ -+ if (!mult) -+ mult = pow(2.0, MP_DIGIT_BIT); -+ -+ for (ix = (int) used - 2; ix >= 0; ix--) { -+ out = out * mult; -+ out += (double) dp[ix]; -+ } -+ -+ if (SIGN(mp) == MP_NEG) -+ out = -out; -+ -+ *d = out; -+ return MP_OKAY; -+} -+ - /*------------------------------------------------------------------------*/ - /* {{{ mp_print(mp, ofp) */ - -Index: mpi-1.8.6/mpi.h -=================================================================== ---- mpi-1.8.6.orig/mpi.h 2015-02-07 19:33:08.688337078 -0800 -+++ mpi-1.8.6/mpi.h 2015-02-07 19:33:14.612233293 -0800 -@@ -187,6 +187,11 @@ - #endif /* end MP_NUMTH */ - - /*------------------------------------------------------------------------*/ -+/* Conversions */ -+ -+mp_err mp_to_double(mp_int *mp, double *d); -+ -+/*------------------------------------------------------------------------*/ - /* Input and output */ - - #if MP_IOFUNC diff --git a/mpi-patches/series b/mpi-patches/series deleted file mode 100644 index 84d76abd..00000000 --- a/mpi-patches/series +++ /dev/null @@ -1,19 +0,0 @@ -disable-make -config-types -fix-warnings -use-txr-allocator -add-mp-set-intptr -export-mp-eq -add-mp-hash -add-mpi-toradix-with-case -fix-mult-bug -mpi-set-mpi-word -mpi-set-double-intptr -fix-bad-shifts -bit-search-optimizations -shrink-mpi-int -faster-square-root -mpi-to-double -fix-ctype-warnings -add-bitops -eliminate-locale-dependencies diff --git a/mpi-patches/shrink-mpi-int b/mpi-patches/shrink-mpi-int deleted file mode 100644 index bac2aafb..00000000 --- a/mpi-patches/shrink-mpi-int +++ /dev/null @@ -1,18 +0,0 @@ -Index: mpi-1.8.6/mpi.h -=================================================================== ---- mpi-1.8.6.orig/mpi.h 2011-12-27 14:01:24.628295000 -0800 -+++ mpi-1.8.6/mpi.h 2011-12-27 14:46:02.227842000 -0800 -@@ -72,8 +72,13 @@ - #define MAX_RADIX 64 - - typedef struct { -+#if SIZEOF_INT >= SIZEOF_PTR -+ unsigned int sign : 1; -+ unsigned int alloc : sizeof(int)*CHAR_BIT - 1; -+#else - mp_sign sign; /* sign of this quantity */ - mp_size alloc; /* how many digits allocated */ -+#endif - mp_size used; /* how many digits used */ - mp_digit *dp; /* the digits themselves */ - } mp_int; diff --git a/mpi-patches/use-txr-allocator b/mpi-patches/use-txr-allocator deleted file mode 100644 index dcc51a62..00000000 --- a/mpi-patches/use-txr-allocator +++ /dev/null @@ -1,68 +0,0 @@ -Index: mpi-1.8.6/mpi.c -=================================================================== ---- mpi-1.8.6.orig/mpi.c 2015-02-03 08:18:36.625505588 -0800 -+++ mpi-1.8.6/mpi.c 2015-02-07 19:32:14.481303143 -0800 -@@ -15,6 +15,9 @@ - #include <string.h> - #include <ctype.h> - -+typedef unsigned char mem_t; -+extern mem_t *chk_calloc(size_t n, size_t size); -+ - #if MP_DEBUG - #include <stdio.h> - -@@ -154,7 +157,7 @@ - #define s_mp_copy(sp, dp, count) memcpy(dp, sp, (count) * sizeof(mp_digit)) - #endif /* MP_MEMCPY */ - -- #define s_mp_alloc(nb, ni) calloc(nb, ni) -+ #define s_mp_alloc(nb, ni) chk_calloc(nb, ni) - #define s_mp_free(ptr) {if(ptr) free(ptr);} - #endif /* MP_MACRO */ - -@@ -282,7 +285,7 @@ - { - ARGCHK(mp != NULL && prec > 0, MP_BADARG); - -- if((DIGITS(mp) = s_mp_alloc(prec, sizeof(mp_digit))) == NULL) -+ if((DIGITS(mp) = (mp_digit *) s_mp_alloc(prec, sizeof(mp_digit))) == NULL) - return MP_MEM; - - SIGN(mp) = MP_ZPOS; -@@ -312,7 +315,7 @@ - if(mp == from) - return MP_OKAY; - -- if((DIGITS(mp) = s_mp_alloc(USED(from), sizeof(mp_digit))) == NULL) -+ if((DIGITS(mp) = (mp_digit *) s_mp_alloc(USED(from), sizeof(mp_digit))) == NULL) - return MP_MEM; - - s_mp_copy(DIGITS(from), DIGITS(mp), USED(from)); -@@ -358,7 +361,7 @@ - s_mp_copy(DIGITS(from), DIGITS(to), USED(from)); - - } else { -- if((tmp = s_mp_alloc(USED(from), sizeof(mp_digit))) == NULL) -+ if((tmp = (mp_digit *) s_mp_alloc(USED(from), sizeof(mp_digit))) == NULL) - return MP_MEM; - - s_mp_copy(DIGITS(from), tmp, USED(from)); -@@ -2670,7 +2673,7 @@ - /* Set min to next nearest default precision block size */ - min = ((min + (s_mp_defprec - 1)) / s_mp_defprec) * s_mp_defprec; - -- if((tmp = s_mp_alloc(min, sizeof(mp_digit))) == NULL) -+ if((tmp = (mp_digit *) s_mp_alloc(min, sizeof(mp_digit))) == NULL) - return MP_MEM; - - s_mp_copy(DIGITS(mp), tmp, USED(mp)); -@@ -2757,7 +2760,7 @@ - /* Allocate ni records of nb bytes each, and return a pointer to that */ - void *s_mp_alloc(size_t nb, size_t ni) - { -- return calloc(nb, ni); -+ return chk_calloc(nb, ni); - - } /* end s_mp_alloc() */ - #endif |