summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2011-12-10 18:27:18 -0800
committerKaz Kylheku <kaz@kylheku.com>2011-12-10 18:27:18 -0800
commitc940739b8f863f3331f00b36c23ad1526ab1147e (patch)
treef68e2bb544a478b7c5537af0b5f9d9aee4aea813
parent009266215ff514a005c766d7d6fcfe8bb31dddd5 (diff)
downloadtxr-c940739b8f863f3331f00b36c23ad1526ab1147e.tar.gz
txr-c940739b8f863f3331f00b36c23ad1526ab1147e.tar.bz2
txr-c940739b8f863f3331f00b36c23ad1526ab1147e.zip
* mpi-patches/mpi-set-mpi-word: Bugfix and refresh.
* mpi-patches/mpi-set-double-intptr: New file. * mpi-patches/series (mpi-set-double-intptr): Patch added.
-rw-r--r--ChangeLog8
-rw-r--r--mpi-patches/mpi-set-double-intptr55
-rw-r--r--mpi-patches/mpi-set-mpi-word8
-rw-r--r--mpi-patches/series1
4 files changed, 68 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index ef62f3a7..699c14eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2011-12-10 Kaz Kylheku <kaz@kylheku.com>
+ * mpi-patches/mpi-set-mpi-word: Bugfix and refresh.
+
+ * mpi-patches/mpi-set-double-intptr: New file.
+
+ * mpi-patches/series (mpi-set-double-intptr): Patch added.
+
+2011-12-10 Kaz Kylheku <kaz@kylheku.com>
+
* configure: add to config.h the type double_intptr_t, which
is twice the size of intptr_t. It may not be available, so
there is a HAVE_ macro to detect it.
diff --git a/mpi-patches/mpi-set-double-intptr b/mpi-patches/mpi-set-double-intptr
new file mode 100644
index 00000000..1c834966
--- /dev/null
+++ b/mpi-patches/mpi-set-double-intptr
@@ -0,0 +1,55 @@
+Index: mpi-1.8.6/mpi.c
+===================================================================
+--- mpi-1.8.6.orig/mpi.c 2011-12-10 18:21:53.000000000 -0800
++++ mpi-1.8.6/mpi.c 2011-12-10 18:24:07.000000000 -0800
+@@ -573,6 +573,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;
++ unsigned long 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 2011-12-10 18:21:53.000000000 -0800
++++ mpi-1.8.6/mpi.h 2011-12-10 18:22:56.000000000 -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
index acd37285..a7ea7a55 100644
--- a/mpi-patches/mpi-set-mpi-word
+++ b/mpi-patches/mpi-set-mpi-word
@@ -1,7 +1,7 @@
Index: mpi-1.8.6/mpi.c
===================================================================
--- mpi-1.8.6.orig/mpi.c 2011-12-10 17:41:38.000000000 -0800
-+++ mpi-1.8.6/mpi.c 2011-12-10 17:44:35.000000000 -0800
++++ mpi-1.8.6/mpi.c 2011-12-10 18:19:29.000000000 -0800
@@ -573,6 +573,15 @@
return MP_OKAY;
}
@@ -10,9 +10,9 @@ Index: mpi-1.8.6/mpi.c
+{
+ USED(mp) = 2;
+ DIGIT(mp, 0) = w & MP_DIGIT_MAX;
-+ DIGIT(mp, 1) = w & MP_DIGIT_MAX;
++ DIGIT(mp, 1) = w >> MP_DIGIT_BIT;
+ SIGN(mp) = sign;
-+ return MP_OK;
++ return MP_OKAY;
+}
+
/*------------------------------------------------------------------------*/
@@ -21,7 +21,7 @@ Index: mpi-1.8.6/mpi.c
Index: mpi-1.8.6/mpi.h
===================================================================
--- mpi-1.8.6.orig/mpi.h 2011-12-10 17:41:38.000000000 -0800
-+++ mpi-1.8.6/mpi.h 2011-12-10 17:43:56.000000000 -0800
++++ mpi-1.8.6/mpi.h 2011-12-10 18:19:29.000000000 -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);
diff --git a/mpi-patches/series b/mpi-patches/series
index 66a58288..65556a57 100644
--- a/mpi-patches/series
+++ b/mpi-patches/series
@@ -7,3 +7,4 @@ add-mp-hash
add-mpi-toradix-with-case
fix-mult-bug
mpi-set-mpi-word
+mpi-set-double-intptr