summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2019-10-30 20:33:45 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2019-10-30 20:33:45 (GMT)
commite52ace05d39636e857f167ed51382cbfbbd22687 (patch)
tree211903eab3d92a4e261eac879dcf6c48d64ad5c7
parent047122995db63a48e068e04717d715acfea1c0a3 (diff)
downloadtcl-e52ace05d39636e857f167ed51382cbfbbd22687.zip
tcl-e52ace05d39636e857f167ed51382cbfbbd22687.tar.gz
tcl-e52ace05d39636e857f167ed51382cbfbbd22687.tar.bz2
Change mp_isodd() (back) from libtommath stub entry to macro. libtommath changed it back to macro too in its master branch, we better do the same.
Better usage of mp_isneg() macro, in stead of directly comparing sign with MP_NEG/MP_ZPOS.
-rw-r--r--generic/tclExecute.c2
-rw-r--r--generic/tclStrToD.c26
-rw-r--r--generic/tclStubInit.c2
-rw-r--r--generic/tclTomMath.decls3
-rw-r--r--generic/tclTomMath.h8
-rw-r--r--generic/tclTomMathDecls.h13
-rw-r--r--macosx/README2
-rw-r--r--unix/Makefile.in5
-rw-r--r--win/Makefile.in1
-rw-r--r--win/makefile.vc1
10 files changed, 22 insertions, 41 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 9b3fb9e..6394eea 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -8497,7 +8497,7 @@ ExecuteExtendedBinaryMathOp(
Tcl_TakeBignumFromObj(NULL, value2Ptr, &big2);
/* TODO: internals intrusion */
- if ((w1 > ((Tcl_WideInt) 0)) ^ (big2.sign == MP_ZPOS)) {
+ if ((w1 > ((Tcl_WideInt) 0)) ^ !mp_isneg(&big2)) {
/*
* Arguments are opposite sign; remainder is sum.
*/
diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c
index 9eeb89d..1862290 100644
--- a/generic/tclStrToD.c
+++ b/generic/tclStrToD.c
@@ -4599,10 +4599,10 @@ TclBignumToDouble(
bits = mp_count_bits(a);
if (bits > DBL_MAX_EXP*log2FLT_RADIX) {
errno = ERANGE;
- if (a->sign == MP_ZPOS) {
- return HUGE_VAL;
- } else {
+ if (mp_isneg(a)) {
return -HUGE_VAL;
+ } else {
+ return HUGE_VAL;
}
}
shift = mantBits - bits;
@@ -4632,10 +4632,10 @@ TclBignumToDouble(
mp_div_2d(a, -shift, &b, NULL);
if (mp_isodd(&b)) {
- if (b.sign == MP_ZPOS) {
- mp_add_d(&b, 1, &b);
- } else {
+ if (mp_isneg(&b)) {
mp_sub_d(&b, 1, &b);
+ } else {
+ mp_add_d(&b, 1, &b);
}
}
} else {
@@ -4645,10 +4645,10 @@ TclBignumToDouble(
*/
mp_div_2d(a, -1-shift, &b, NULL);
- if (b.sign == MP_ZPOS) {
- mp_add_d(&b, 1, &b);
- } else {
+ if (mp_isneg(&b)) {
mp_sub_d(&b, 1, &b);
+ } else {
+ mp_add_d(&b, 1, &b);
}
mp_div_2d(&b, 1, &b, NULL);
}
@@ -4674,10 +4674,10 @@ TclBignumToDouble(
* Return the result with the appropriate sign.
*/
- if (a->sign == MP_ZPOS) {
- return r;
- } else {
+ if (mp_isneg(a)) {
return -r;
+ } else {
+ return r;
}
}
@@ -4850,7 +4850,7 @@ BignumToBiasedFrExp(
*/
*machexp = bits - mantBits + 2;
- return ((a->sign == MP_ZPOS) ? r : -r);
+ return (mp_isneg(a) ? -r : r);
}
/*
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index 50c14bf..0618f00 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -920,7 +920,7 @@ const TclTomMathStubs tclTomMathStubs = {
0, /* 69 */
0, /* 70 */
0, /* 71 */
- TclBN_mp_isodd, /* 72 */
+ 0, /* 72 */
TclBN_mp_tc_and, /* 73 */
TclBN_mp_tc_or, /* 74 */
TclBN_mp_tc_xor, /* 75 */
diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls
index c8092aa..8325922 100644
--- a/generic/tclTomMath.decls
+++ b/generic/tclTomMath.decls
@@ -237,9 +237,6 @@ declare 66 {
declare 67 {
mp_err TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b, mp_int *c, int fast)
}
-declare 72 {
- mp_bool TclBN_mp_isodd(const mp_int *a)
-}
# Added in libtommath 1.1.0
declare 73 {
diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h
index 7b720e9..85b0b4b 100644
--- a/generic/tclTomMath.h
+++ b/generic/tclTomMath.h
@@ -323,12 +323,8 @@ mp_err mp_init_size(mp_int *a, int size) MP_WUR;
/* ---> Basic Manipulations <--- */
#define mp_iszero(a) (((a)->used == 0) ? MP_YES : MP_NO)
-/*
-mp_bool mp_iseven(const mp_int *a) MP_WUR;
-*/
-/*
-mp_bool mp_isodd(const mp_int *a) MP_WUR;
-*/
+#define mp_isodd(a) (((a)->used != 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO)
+#define mp_iseven(a) (((a)->used == 0 || (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO)
#define mp_isneg(a) (((a)->sign != MP_ZPOS) ? MP_YES : MP_NO)
/* set to zero */
diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h
index 92bb512..9131041 100644
--- a/generic/tclTomMathDecls.h
+++ b/generic/tclTomMathDecls.h
@@ -80,7 +80,6 @@
#define mp_init_set TclBN_mp_init_set
#define mp_init_set_int TclBN_mp_init_set_int
#define mp_init_size TclBN_mp_init_size
-#define mp_isodd TclBN_mp_isodd
#define mp_lshd TclBN_mp_lshd
#define mp_mod TclBN_mp_mod
#define mp_mod_2d TclBN_mp_mod_2d
@@ -326,8 +325,7 @@ EXTERN mp_err TclBN_mp_expt_d_ex(const mp_int *a, mp_digit b,
/* Slot 69 is reserved */
/* Slot 70 is reserved */
/* Slot 71 is reserved */
-/* 72 */
-EXTERN mp_bool TclBN_mp_isodd(const mp_int *a);
+/* Slot 72 is reserved */
/* 73 */
EXTERN mp_err TclBN_mp_tc_and(const mp_int *a, const mp_int *b,
mp_int *c);
@@ -426,7 +424,7 @@ typedef struct TclTomMathStubs {
void (*reserved69)(void);
void (*reserved70)(void);
void (*reserved71)(void);
- mp_bool (*tclBN_mp_isodd) (const mp_int *a); /* 72 */
+ void (*reserved72)(void);
mp_err (*tclBN_mp_tc_and) (const mp_int *a, const mp_int *b, mp_int *c); /* 73 */
mp_err (*tclBN_mp_tc_or) (const mp_int *a, const mp_int *b, mp_int *c); /* 74 */
mp_err (*tclBN_mp_tc_xor) (const mp_int *a, const mp_int *b, mp_int *c); /* 75 */
@@ -589,8 +587,7 @@ extern const TclTomMathStubs *tclTomMathStubsPtr;
/* Slot 69 is reserved */
/* Slot 70 is reserved */
/* Slot 71 is reserved */
-#define TclBN_mp_isodd \
- (tclTomMathStubsPtr->tclBN_mp_isodd) /* 72 */
+/* Slot 72 is reserved */
#define TclBN_mp_tc_and \
(tclTomMathStubsPtr->tclBN_mp_tc_and) /* 73 */
#define TclBN_mp_tc_or \
@@ -611,10 +608,6 @@ extern const TclTomMathStubs *tclTomMathStubsPtr;
/* !END!: Do not edit above this line. */
-#undef mp_isodd
-#define mp_isodd(a) (((a)->used > 0 && (((a)->dp[0] & 1) == 1)) ? MP_YES : MP_NO)
-#define mp_iseven(a) (((a)->used == 0 || (((a)->dp[0] & 1) == 0)) ? MP_YES : MP_NO)
-
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT
diff --git a/macosx/README b/macosx/README
index 3662c22..43da77f 100644
--- a/macosx/README
+++ b/macosx/README
@@ -36,7 +36,7 @@ Weak-linking is available on OS X 10.2 or later, it additionally allows Tcl
built on 10.x to run on any 10.y with x > y >= z (for a chosen z >= 2).
- Tcl extensions can be installed in any of:
- $HOME/Library/Tcl /Library/Tcl
+ $HOME/Library/Tcl /Library/Tcl
$HOME/Library/Frameworks /Library/Frameworks
(searched in that order).
Given a potential package directory $pkg, Tcl on OSX checks for the file
diff --git a/unix/Makefile.in b/unix/Makefile.in
index 91a8e20..a4715a8 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -326,7 +326,7 @@ TOMMATH_OBJS = bn_s_mp_reverse.o bn_s_mp_mul_digs_fast.o \
bn_s_mp_get_bit.o bn_mp_grow.o bn_mp_init.o \
bn_mp_init_copy.o bn_mp_init_multi.o bn_mp_init_set.o \
bn_mp_init_size.o bn_s_mp_karatsuba_mul.o \
- bn_s_mp_karatsuba_sqr.o bn_s_mp_balance_mul.o bn_mp_isodd.o \
+ bn_s_mp_karatsuba_sqr.o bn_s_mp_balance_mul.o \
bn_mp_lshd.o bn_mp_mod.o bn_mp_mod_2d.o bn_mp_mul.o bn_mp_mul_2.o \
bn_mp_mul_2d.o bn_mp_mul_d.o bn_mp_neg.o bn_mp_or.o \
bn_mp_radix_size.o bn_mp_radix_smap.o \
@@ -1544,9 +1544,6 @@ bn_s_mp_karatsuba_sqr.o: $(TOMMATH_DIR)/bn_s_mp_karatsuba_sqr.c $(MATHHDRS)
bn_s_mp_balance_mul.o: $(TOMMATH_DIR)/bn_s_mp_balance_mul.c $(MATHHDRS)
$(CC) -c $(CC_SWITCHES) $(TOMMATH_DIR)/bn_s_mp_balance_mul.c
-bn_mp_isodd.o: $(TOMMATH_DIR)/bn_mp_isodd.c $(MATHHDRS)
- $(CC) -c $(CC_SWITCHES) $(TOMMATH_DIR)/bn_mp_isodd.c
-
bn_mp_lshd.o: $(TOMMATH_DIR)/bn_mp_lshd.c $(MATHHDRS)
$(CC) -c $(CC_SWITCHES) $(TOMMATH_DIR)/bn_mp_lshd.c
diff --git a/win/Makefile.in b/win/Makefile.in
index 105fd41..5e3252e 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -337,7 +337,6 @@ TOMMATH_OBJS = \
bn_mp_init_multi.${OBJEXT} \
bn_mp_init_set.${OBJEXT} \
bn_mp_init_size.${OBJEXT} \
- bn_mp_isodd.${OBJEXT} \
bn_mp_lshd.${OBJEXT} \
bn_mp_mod.${OBJEXT} \
bn_mp_mod_2d.${OBJEXT} \
diff --git a/win/makefile.vc b/win/makefile.vc
index 7eb1d63..01cdb1f 100644
--- a/win/makefile.vc
+++ b/win/makefile.vc
@@ -340,7 +340,6 @@ TOMMATHOBJS = \
$(TMP_DIR)\bn_mp_init_multi.obj \
$(TMP_DIR)\bn_mp_init_set.obj \
$(TMP_DIR)\bn_mp_init_size.obj \
- $(TMP_DIR)\bn_mp_isodd.obj \
$(TMP_DIR)\bn_mp_lshd.obj \
$(TMP_DIR)\bn_mp_mod.obj \
$(TMP_DIR)\bn_mp_mod_2d.obj \