summaryrefslogtreecommitdiffstats
path: root/mpi-patches/add-mp-set-intptr
diff options
context:
space:
mode:
Diffstat (limited to 'mpi-patches/add-mp-set-intptr')
-rw-r--r--mpi-patches/add-mp-set-intptr22
1 files changed, 11 insertions, 11 deletions
diff --git a/mpi-patches/add-mp-set-intptr b/mpi-patches/add-mp-set-intptr
index a5d50a33..87e4ebb4 100644
--- a/mpi-patches/add-mp-set-intptr
+++ b/mpi-patches/add-mp-set-intptr
@@ -1,16 +1,17 @@
Index: mpi-1.8.6/mpi.c
===================================================================
---- mpi-1.8.6.orig/mpi.c 2011-12-09 13:52:26.000000000 -0800
-+++ mpi-1.8.6/mpi.c 2011-12-09 13:56:19.000000000 -0800
+--- mpi-1.8.6.orig/mpi.c 2011-12-10 18:20:55.000000000 -0800
++++ mpi-1.8.6/mpi.c 2011-12-10 19:40:53.000000000 -0800
@@ -528,6 +528,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;
-+ unsigned long v = z > 0 ? z : -z;
+ const int nd = (sizeof v + sizeof (mp_digit) - 1) / sizeof (mp_digit);
+
+ ARGCHK(mp != NULL, MP_BADARG);
@@ -28,14 +29,13 @@ Index: mpi-1.8.6/mpi.c
+ {
+ DIGIT(mp, ix) = (v >> shift) & MP_DIGIT_MAX;
+ }
-+
-+ if(z < 0)
-+ SIGN(mp) = MP_NEG;
-+
-+ return MP_OKAY;
++ } else {
++ mp_set(mp, v);
+ }
+
-+ mp_set(mp, z);
++ if(z < 0)
++ SIGN(mp) = MP_NEG;
++
+ return MP_OKAY;
+}
+
@@ -64,8 +64,8 @@ Index: mpi-1.8.6/mpi.c
Index: mpi-1.8.6/mpi.h
===================================================================
---- mpi-1.8.6.orig/mpi.h 2011-12-09 13:49:20.000000000 -0800
-+++ mpi-1.8.6/mpi.h 2011-12-09 13:56:19.000000000 -0800
+--- mpi-1.8.6.orig/mpi.h 2011-12-10 18:19:39.000000000 -0800
++++ mpi-1.8.6/mpi.h 2011-12-10 19:39:58.000000000 -0800
@@ -94,6 +94,8 @@
void mp_zero(mp_int *mp);
void mp_set(mp_int *mp, mp_digit d);