summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authornijtmans <nijtmans>2010-05-03 14:36:40 (GMT)
committernijtmans <nijtmans>2010-05-03 14:36:40 (GMT)
commit603632160ce039289adcabac2684febc649c535b (patch)
treee5adab677558dc22434d9ee6b375a48333aea345 /generic
parent091c9fee62375b69529473b975e37dc279f0bc83 (diff)
downloadtcl-603632160ce039289adcabac2684febc649c535b.zip
tcl-603632160ce039289adcabac2684febc649c535b.tar.gz
tcl-603632160ce039289adcabac2684febc649c535b.tar.bz2
CONSTify various useful internal functions
(TclBignumToDouble, TclCeil, TclFloor), and related tommath functions.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclBasic.c5
-rw-r--r--generic/tclInt.h8
-rwxr-xr-xgeneric/tclStrToD.c12
-rw-r--r--generic/tclTomMath.decls20
-rw-r--r--generic/tclTomMath.h22
-rw-r--r--generic/tclTomMathDecls.h38
6 files changed, 52 insertions, 53 deletions
diff --git a/generic/tclBasic.c b/generic/tclBasic.c
index 7ded8f7..a7dce89 100644
--- a/generic/tclBasic.c
+++ b/generic/tclBasic.c
@@ -16,7 +16,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclBasic.c,v 1.455 2010/04/30 12:38:46 dkf Exp $
+ * RCS: @(#) $Id: tclBasic.c,v 1.456 2010/05/03 14:36:41 nijtmans Exp $
*/
#include "tclInt.h"
@@ -7501,8 +7501,7 @@ ExprAbsFunc(
#endif
if (type == TCL_NUMBER_BIG) {
- /* TODO: const correctness ? */
- if (mp_cmp_d((mp_int *) ptr, 0) == MP_LT) {
+ if (mp_cmp_d((const mp_int *) ptr, 0) == MP_LT) {
Tcl_GetBignumFromObj(NULL, objv[1], &big);
tooLarge:
mp_neg(&big, &big);
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 5e37a56..fa503cc 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -15,7 +15,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclInt.h,v 1.475 2010/04/30 20:52:51 dgp Exp $
+ * RCS: @(#) $Id: tclInt.h,v 1.476 2010/05/03 14:36:40 nijtmans Exp $
*/
#ifndef _TCLINT
@@ -2823,11 +2823,11 @@ MODULE_SCOPE void TclArgumentGet(Tcl_Interp *interp, Tcl_Obj *obj,
CmdFrame **cfPtrPtr, int *wordPtr);
MODULE_SCOPE int TclArraySet(Tcl_Interp *interp,
Tcl_Obj *arrayNameObj, Tcl_Obj *arrayElemObj);
-MODULE_SCOPE double TclBignumToDouble(mp_int *bignum);
+MODULE_SCOPE double TclBignumToDouble(const mp_int *bignum);
MODULE_SCOPE int TclByteArrayMatch(const unsigned char *string,
int strLen, const unsigned char *pattern,
int ptnLen, int flags);
-MODULE_SCOPE double TclCeil(mp_int *a);
+MODULE_SCOPE double TclCeil(const mp_int *a);
MODULE_SCOPE int TclCheckBadOctal(Tcl_Interp *interp,
const char *value);
MODULE_SCOPE int TclChanCaughtErrorBypass(Tcl_Interp *interp,
@@ -2883,7 +2883,7 @@ MODULE_SCOPE void TclFinalizeSynchronization(void);
MODULE_SCOPE void TclFinalizeThreadAlloc(void);
MODULE_SCOPE void TclFinalizeThreadData(void);
MODULE_SCOPE void TclFinalizeThreadObjects(void);
-MODULE_SCOPE double TclFloor(mp_int *a);
+MODULE_SCOPE double TclFloor(const mp_int *a);
MODULE_SCOPE void TclFormatNaN(double value, char *buffer);
MODULE_SCOPE int TclFSFileAttrIndex(Tcl_Obj *pathPtr,
const char *attributeName, int *indexPtr);
diff --git a/generic/tclStrToD.c b/generic/tclStrToD.c
index fdfdb5e..8094e87 100755
--- a/generic/tclStrToD.c
+++ b/generic/tclStrToD.c
@@ -14,7 +14,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclStrToD.c,v 1.43 2010/04/27 12:36:22 nijtmans Exp $
+ * RCS: @(#) $Id: tclStrToD.c,v 1.44 2010/05/03 14:36:41 nijtmans Exp $
*
*----------------------------------------------------------------------
*/
@@ -137,7 +137,7 @@ static int n770_fp; /* Flag is 1 on Nokia N770 floating point.
static double AbsoluteValue(double v, int *signum);
static int AccumulateDecimalDigit(unsigned, int,
Tcl_WideUInt *, mp_int *, int);
-static double BignumToBiasedFrExp(mp_int *big, int *machexp);
+static double BignumToBiasedFrExp(const mp_int *big, int *machexp);
static int GetIntegerTimesPower(double v, mp_int *r, int *e);
static double MakeHighPrecisionDouble(int signum,
mp_int *significand, int nSigDigs, int exponent);
@@ -2369,7 +2369,7 @@ Tcl_InitBignumFromDouble(
double
TclBignumToDouble(
- mp_int *a) /* Integer to convert. */
+ const mp_int *a) /* Integer to convert. */
{
mp_int b;
int bits, shift, i;
@@ -2430,7 +2430,7 @@ TclBignumToDouble(
double
TclCeil(
- mp_int *a) /* Integer to convert. */
+ const mp_int *a) /* Integer to convert. */
{
double r = 0.0;
mp_int b;
@@ -2473,7 +2473,7 @@ TclCeil(
double
TclFloor(
- mp_int *a) /* Integer to convert. */
+ const mp_int *a) /* Integer to convert. */
{
double r = 0.0;
mp_int b;
@@ -2529,7 +2529,7 @@ TclFloor(
static double
BignumToBiasedFrExp(
- mp_int *a, /* Integer to convert */
+ const mp_int *a, /* Integer to convert */
int *machexp) /* Power of two */
{
mp_int b;
diff --git a/generic/tclTomMath.decls b/generic/tclTomMath.decls
index a170de8..2721c1d 100644
--- a/generic/tclTomMath.decls
+++ b/generic/tclTomMath.decls
@@ -13,7 +13,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: tclTomMath.decls,v 1.6 2010/01/29 16:17:20 nijtmans Exp $
+# RCS: @(#) $Id: tclTomMath.decls,v 1.7 2010/05/03 14:36:40 nijtmans Exp $
library tcl
@@ -50,19 +50,19 @@ declare 7 generic {
void TclBN_mp_clear_multi(mp_int *a, ...)
}
declare 8 generic {
- int TclBN_mp_cmp(mp_int *a, mp_int *b)
+ int TclBN_mp_cmp(const mp_int *a, const mp_int *b)
}
declare 9 generic {
- int TclBN_mp_cmp_d(mp_int *a, mp_digit b)
+ int TclBN_mp_cmp_d(const mp_int *a, mp_digit b)
}
declare 10 generic {
- int TclBN_mp_cmp_mag(mp_int *a, mp_int *b)
+ int TclBN_mp_cmp_mag(const mp_int *a, const mp_int *b)
}
declare 11 generic {
- int TclBN_mp_copy(mp_int *a, mp_int *b)
+ int TclBN_mp_copy(const mp_int *a, mp_int *b)
}
declare 12 generic {
- int TclBN_mp_count_bits(mp_int *a)
+ int TclBN_mp_count_bits(const mp_int *a)
}
declare 13 generic {
int TclBN_mp_div(mp_int *a, mp_int *b, mp_int *q, mp_int *r)
@@ -74,7 +74,7 @@ declare 15 generic {
int TclBN_mp_div_2(mp_int *a, mp_int *q)
}
declare 16 generic {
- int TclBN_mp_div_2d(mp_int *a, int b, mp_int *q, mp_int *r)
+ int TclBN_mp_div_2d(const mp_int *a, int b, mp_int *q, mp_int *r)
}
declare 17 generic {
int TclBN_mp_div_3(mp_int *a, mp_int *q, mp_digit *r)
@@ -110,7 +110,7 @@ declare 27 generic {
int TclBN_mp_mod(mp_int *a, mp_int *b, mp_int *r)
}
declare 28 generic {
- int TclBN_mp_mod_2d(mp_int *a, int b, mp_int *r)
+ int TclBN_mp_mod_2d(const mp_int *a, int b, mp_int *r)
}
declare 29 generic {
int TclBN_mp_mul(mp_int *a, mp_int *b, mp_int *p)
@@ -122,10 +122,10 @@ declare 31 generic {
int TclBN_mp_mul_2(mp_int *a, mp_int *p)
}
declare 32 generic {
- int TclBN_mp_mul_2d(mp_int *a, int d, mp_int *p)
+ int TclBN_mp_mul_2d(const mp_int *a, int d, mp_int *p)
}
declare 33 generic {
- int TclBN_mp_neg(mp_int *a, mp_int *b)
+ int TclBN_mp_neg(const mp_int *a, mp_int *b)
}
declare 34 generic {
int TclBN_mp_or(mp_int *a, mp_int *b, mp_int *c)
diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h
index 73fd7aa..0b2df47 100644
--- a/generic/tclTomMath.h
+++ b/generic/tclTomMath.h
@@ -290,7 +290,7 @@ int mp_init_set_int (mp_int * a, unsigned long b);
/* copy, b = a */
/*
-int mp_copy(mp_int *a, mp_int *b);
+int mp_copy(const mp_int *a, mp_int *b);
*/
/* inits and copies, a = b */
@@ -317,7 +317,7 @@ int mp_lshd(mp_int *a, int b);
/* c = a / 2**b */
/*
-int mp_div_2d(mp_int *a, int b, mp_int *c, mp_int *d);
+int mp_div_2d(const mp_int *a, int b, mp_int *c, mp_int *d);
*/
/* b = a/2 */
@@ -327,7 +327,7 @@ int mp_div_2(mp_int *a, mp_int *b);
/* c = a * 2**b */
/*
-int mp_mul_2d(mp_int *a, int b, mp_int *c);
+int mp_mul_2d(const mp_int *a, int b, mp_int *c);
*/
/* b = a*2 */
@@ -337,7 +337,7 @@ int mp_mul_2(mp_int *a, mp_int *b);
/* c = a mod 2**d */
/*
-int mp_mod_2d(mp_int *a, int b, mp_int *c);
+int mp_mod_2d(const mp_int *a, int b, mp_int *c);
*/
/* computes a = 2**b */
@@ -377,7 +377,7 @@ int mp_and(mp_int *a, mp_int *b, mp_int *c);
/* b = -a */
/*
-int mp_neg(mp_int *a, mp_int *b);
+int mp_neg(const mp_int *a, mp_int *b);
*/
/* b = |a| */
@@ -387,12 +387,12 @@ int mp_abs(mp_int *a, mp_int *b);
/* compare a to b */
/*
-int mp_cmp(mp_int *a, mp_int *b);
+int mp_cmp(const mp_int *a, const mp_int *b);
*/
/* compare |a| to |b| */
/*
-int mp_cmp_mag(mp_int *a, mp_int *b);
+int mp_cmp_mag(const mp_int *a, const mp_int *b);
*/
/* c = a + b */
@@ -429,7 +429,7 @@ int mp_mod(mp_int *a, mp_int *b, mp_int *c);
/* compare against a single digit */
/*
-int mp_cmp_d(mp_int *a, mp_digit b);
+int mp_cmp_d(const mp_int *a, mp_digit b);
*/
/* c = a + b */
@@ -704,7 +704,7 @@ int mp_prime_random_ex(mp_int *a, int t, int size, int flags, ltm_prime_callback
/* ---> radix conversion <--- */
/*
-int mp_count_bits(mp_int *a);
+int mp_count_bits(const mp_int *a);
*/
/*
@@ -835,6 +835,6 @@ MODULE_SCOPE const char *mp_s_rmap;
/* $Source: /root/tcl/repos-to-convert/tcl/generic/tclTomMath.h,v $ */
/* Based on Tom's version 1.8 */
-/* $Revision: 1.13 $ */
-/* $Date: 2010/05/03 11:38:18 $ */
+/* $Revision: 1.14 $ */
+/* $Date: 2010/05/03 14:36:41 $ */
diff --git a/generic/tclTomMathDecls.h b/generic/tclTomMathDecls.h
index ee57f96..11555e8 100644
--- a/generic/tclTomMathDecls.h
+++ b/generic/tclTomMathDecls.h
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclTomMathDecls.h,v 1.11 2010/02/05 10:03:23 nijtmans Exp $
+ * RCS: @(#) $Id: tclTomMathDecls.h,v 1.12 2010/05/03 14:36:41 nijtmans Exp $
*/
#ifndef _TCLTOMMATHDECLS
@@ -180,27 +180,27 @@ EXTERN void TclBN_mp_clear_multi(mp_int *a, ...);
#ifndef TclBN_mp_cmp_TCL_DECLARED
#define TclBN_mp_cmp_TCL_DECLARED
/* 8 */
-EXTERN int TclBN_mp_cmp(mp_int *a, mp_int *b);
+EXTERN int TclBN_mp_cmp(const mp_int *a, const mp_int *b);
#endif
#ifndef TclBN_mp_cmp_d_TCL_DECLARED
#define TclBN_mp_cmp_d_TCL_DECLARED
/* 9 */
-EXTERN int TclBN_mp_cmp_d(mp_int *a, mp_digit b);
+EXTERN int TclBN_mp_cmp_d(const mp_int *a, mp_digit b);
#endif
#ifndef TclBN_mp_cmp_mag_TCL_DECLARED
#define TclBN_mp_cmp_mag_TCL_DECLARED
/* 10 */
-EXTERN int TclBN_mp_cmp_mag(mp_int *a, mp_int *b);
+EXTERN int TclBN_mp_cmp_mag(const mp_int *a, const mp_int *b);
#endif
#ifndef TclBN_mp_copy_TCL_DECLARED
#define TclBN_mp_copy_TCL_DECLARED
/* 11 */
-EXTERN int TclBN_mp_copy(mp_int *a, mp_int *b);
+EXTERN int TclBN_mp_copy(const mp_int *a, mp_int *b);
#endif
#ifndef TclBN_mp_count_bits_TCL_DECLARED
#define TclBN_mp_count_bits_TCL_DECLARED
/* 12 */
-EXTERN int TclBN_mp_count_bits(mp_int *a);
+EXTERN int TclBN_mp_count_bits(const mp_int *a);
#endif
#ifndef TclBN_mp_div_TCL_DECLARED
#define TclBN_mp_div_TCL_DECLARED
@@ -222,7 +222,7 @@ EXTERN int TclBN_mp_div_2(mp_int *a, mp_int *q);
#ifndef TclBN_mp_div_2d_TCL_DECLARED
#define TclBN_mp_div_2d_TCL_DECLARED
/* 16 */
-EXTERN int TclBN_mp_div_2d(mp_int *a, int b, mp_int *q,
+EXTERN int TclBN_mp_div_2d(const mp_int *a, int b, mp_int *q,
mp_int *r);
#endif
#ifndef TclBN_mp_div_3_TCL_DECLARED
@@ -283,7 +283,7 @@ EXTERN int TclBN_mp_mod(mp_int *a, mp_int *b, mp_int *r);
#ifndef TclBN_mp_mod_2d_TCL_DECLARED
#define TclBN_mp_mod_2d_TCL_DECLARED
/* 28 */
-EXTERN int TclBN_mp_mod_2d(mp_int *a, int b, mp_int *r);
+EXTERN int TclBN_mp_mod_2d(const mp_int *a, int b, mp_int *r);
#endif
#ifndef TclBN_mp_mul_TCL_DECLARED
#define TclBN_mp_mul_TCL_DECLARED
@@ -303,12 +303,12 @@ EXTERN int TclBN_mp_mul_2(mp_int *a, mp_int *p);
#ifndef TclBN_mp_mul_2d_TCL_DECLARED
#define TclBN_mp_mul_2d_TCL_DECLARED
/* 32 */
-EXTERN int TclBN_mp_mul_2d(mp_int *a, int d, mp_int *p);
+EXTERN int TclBN_mp_mul_2d(const mp_int *a, int d, mp_int *p);
#endif
#ifndef TclBN_mp_neg_TCL_DECLARED
#define TclBN_mp_neg_TCL_DECLARED
/* 33 */
-EXTERN int TclBN_mp_neg(mp_int *a, mp_int *b);
+EXTERN int TclBN_mp_neg(const mp_int *a, mp_int *b);
#endif
#ifndef TclBN_mp_or_TCL_DECLARED
#define TclBN_mp_or_TCL_DECLARED
@@ -464,15 +464,15 @@ typedef struct TclTomMathStubs {
void (*tclBN_mp_clamp) (mp_int *a); /* 5 */
void (*tclBN_mp_clear) (mp_int *a); /* 6 */
void (*tclBN_mp_clear_multi) (mp_int *a, ...); /* 7 */
- int (*tclBN_mp_cmp) (mp_int *a, mp_int *b); /* 8 */
- int (*tclBN_mp_cmp_d) (mp_int *a, mp_digit b); /* 9 */
- int (*tclBN_mp_cmp_mag) (mp_int *a, mp_int *b); /* 10 */
- int (*tclBN_mp_copy) (mp_int *a, mp_int *b); /* 11 */
- int (*tclBN_mp_count_bits) (mp_int *a); /* 12 */
+ int (*tclBN_mp_cmp) (const mp_int *a, const mp_int *b); /* 8 */
+ int (*tclBN_mp_cmp_d) (const mp_int *a, mp_digit b); /* 9 */
+ int (*tclBN_mp_cmp_mag) (const mp_int *a, const mp_int *b); /* 10 */
+ int (*tclBN_mp_copy) (const mp_int *a, mp_int *b); /* 11 */
+ int (*tclBN_mp_count_bits) (const mp_int *a); /* 12 */
int (*tclBN_mp_div) (mp_int *a, mp_int *b, mp_int *q, mp_int *r); /* 13 */
int (*tclBN_mp_div_d) (mp_int *a, mp_digit b, mp_int *q, mp_digit *r); /* 14 */
int (*tclBN_mp_div_2) (mp_int *a, mp_int *q); /* 15 */
- int (*tclBN_mp_div_2d) (mp_int *a, int b, mp_int *q, mp_int *r); /* 16 */
+ int (*tclBN_mp_div_2d) (const mp_int *a, int b, mp_int *q, mp_int *r); /* 16 */
int (*tclBN_mp_div_3) (mp_int *a, mp_int *q, mp_digit *r); /* 17 */
void (*tclBN_mp_exch) (mp_int *a, mp_int *b); /* 18 */
int (*tclBN_mp_expt_d) (mp_int *a, mp_digit b, mp_int *c); /* 19 */
@@ -484,12 +484,12 @@ typedef struct TclTomMathStubs {
int (*tclBN_mp_init_size) (mp_int *a, int size); /* 25 */
int (*tclBN_mp_lshd) (mp_int *a, int shift); /* 26 */
int (*tclBN_mp_mod) (mp_int *a, mp_int *b, mp_int *r); /* 27 */
- int (*tclBN_mp_mod_2d) (mp_int *a, int b, mp_int *r); /* 28 */
+ int (*tclBN_mp_mod_2d) (const mp_int *a, int b, mp_int *r); /* 28 */
int (*tclBN_mp_mul) (mp_int *a, mp_int *b, mp_int *p); /* 29 */
int (*tclBN_mp_mul_d) (mp_int *a, mp_digit b, mp_int *p); /* 30 */
int (*tclBN_mp_mul_2) (mp_int *a, mp_int *p); /* 31 */
- int (*tclBN_mp_mul_2d) (mp_int *a, int d, mp_int *p); /* 32 */
- int (*tclBN_mp_neg) (mp_int *a, mp_int *b); /* 33 */
+ int (*tclBN_mp_mul_2d) (const mp_int *a, int d, mp_int *p); /* 32 */
+ int (*tclBN_mp_neg) (const mp_int *a, mp_int *b); /* 33 */
int (*tclBN_mp_or) (mp_int *a, mp_int *b, mp_int *c); /* 34 */
int (*tclBN_mp_radix_size) (mp_int *a, int radix, int *size); /* 35 */
int (*tclBN_mp_read_radix) (mp_int *a, const char *str, int radix); /* 36 */