summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin B Kenny <kennykb@acm.org>2005-12-27 17:39:01 (GMT)
committerKevin B Kenny <kennykb@acm.org>2005-12-27 17:39:01 (GMT)
commit988dfef7f36424cf6008cd90ce865e7b62735f10 (patch)
tree136dd1f29ae13555c993c434fd909c75e4ef6393
parent18d6765361d9e2703b6f02c23d4edb0c79dffbf6 (diff)
downloadtcl-988dfef7f36424cf6008cd90ce865e7b62735f10.zip
tcl-988dfef7f36424cf6008cd90ce865e7b62735f10.tar.gz
tcl-988dfef7f36424cf6008cd90ce865e7b62735f10.tar.bz2
Corrected bugs in tommath installation, improved tommath square root performance, patched around a [clock scan] issue with time zones
-rw-r--r--ChangeLog22
-rw-r--r--generic/tcl.decls8
-rw-r--r--generic/tcl.h9
-rw-r--r--generic/tclDecls.h14
-rw-r--r--generic/tclStubInit.c3
-rw-r--r--generic/tclStubLib.c7
-rw-r--r--library/clock.tcl4
-rw-r--r--libtommath/bn_mp_sqrt.c58
-rw-r--r--win/Makefile.in6
9 files changed, 91 insertions, 40 deletions
diff --git a/ChangeLog b/ChangeLog
index 8b66c5d..aed035e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2005-12-27 Kevin B. Kenny <kennykb@acm.org>
+
+ * generic/tcl.decls: Destubbed TclTomMathInitializeStubs - it is in
+ * generic/tcl.h: the stub library, notthe main shared
+ library.
+ * generic/tclDecls.h:
+ * generic/tclStubLib.c:
+ * generic/tclStubInit.c: Regenerated.
+ * generic/clock.tcl: Reverted to using the time zone abbreviation
+ and not its name to "stop the bleeding" on
+ Bug 1386377. This is *not* a good long-term
+ solution, but there may not be one.
+ * libtommath/bn_mp_sqrt.c: Improved the initial approximation to
+ the square root, roughly doubling the
+ speed of the routine. (This is a local
+ change that needs to be communicated to
+ Tom.)
+ * win/Makefile.in: Corrected a bug where tommath_class.h and
+ tommath_superclass.h were not installed, making
+ it impossible for client code to compile
+ against the tommath stubs.
+
2005-12-20 Donal K. Fellows <donal.k.fellows@manchester.ac.uk>
* generic/tclThreadAlloc.c (Tcl_GetMemoryInfo): Format values as longs
diff --git a/generic/tcl.decls b/generic/tcl.decls
index e5a51cd..3549ccc 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -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: tcl.decls,v 1.116 2005/12/13 22:43:16 kennykb Exp $
+# RCS: @(#) $Id: tcl.decls,v 1.117 2005/12/27 17:39:01 kennykb Exp $
library tcl
@@ -2030,12 +2030,6 @@ declare 564 generic {
declare 565 generic {
void Tcl_GetChannelError (Tcl_Channel chan, Tcl_Obj** msg)
}
-
-declare 566 generic {
- const char* TclTomMathInitializeStubs(Tcl_Interp* interp,
- CONST char* version, int epoch, int revision)
-}
-
##############################################################################
diff --git a/generic/tcl.h b/generic/tcl.h
index b446591..fb20564 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -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: tcl.h,v 1.209 2005/12/08 20:20:11 hobbs Exp $
+ * RCS: @(#) $Id: tcl.h,v 1.210 2005/12/27 17:39:01 kennykb Exp $
*/
#ifndef _TCL
@@ -2385,6 +2385,8 @@ typedef unsigned long mp_digit;
EXTERN CONST char * Tcl_InitStubs _ANSI_ARGS_((Tcl_Interp *interp,
CONST char *version, int exact));
+EXTERN CONST char* TclTomMathInitializeStubs(Tcl_Interp* interp,
+ CONST char* version, int epoch, int revision);
#ifndef USE_TCL_STUBS
@@ -2397,6 +2399,11 @@ EXTERN CONST char * Tcl_InitStubs _ANSI_ARGS_((Tcl_Interp *interp,
#endif
+ /*
+ * TODO - tommath stubs export goes here!
+ */
+
+
/*
* Public functions that are not accessible via the stubs table.
*/
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index 6851457..a4a8ec6 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclDecls.h,v 1.118 2005/12/13 22:43:17 kennykb Exp $
+ * RCS: @(#) $Id: tclDecls.h,v 1.119 2005/12/27 17:39:01 kennykb Exp $
*/
#ifndef _TCLDECLS
@@ -3527,13 +3527,6 @@ EXTERN void Tcl_SetChannelError _ANSI_ARGS_((Tcl_Channel chan,
EXTERN void Tcl_GetChannelError _ANSI_ARGS_((Tcl_Channel chan,
Tcl_Obj** msg));
#endif
-#ifndef TclTomMathInitializeStubs_TCL_DECLARED
-#define TclTomMathInitializeStubs_TCL_DECLARED
-/* 566 */
-EXTERN const char* TclTomMathInitializeStubs _ANSI_ARGS_((
- Tcl_Interp* interp, CONST char* version,
- int epoch, int revision));
-#endif
typedef struct TclStubHooks {
struct TclPlatStubs *tclPlatStubs;
@@ -4141,7 +4134,6 @@ typedef struct TclStubs {
void (*tcl_GetChannelErrorInterp) _ANSI_ARGS_((Tcl_Interp* interp, Tcl_Obj** msg)); /* 563 */
void (*tcl_SetChannelError) _ANSI_ARGS_((Tcl_Channel chan, Tcl_Obj* msg)); /* 564 */
void (*tcl_GetChannelError) _ANSI_ARGS_((Tcl_Channel chan, Tcl_Obj** msg)); /* 565 */
- const char* (*tclTomMathInitializeStubs) _ANSI_ARGS_((Tcl_Interp* interp, CONST char* version, int epoch, int revision)); /* 566 */
} TclStubs;
#ifdef __cplusplus
@@ -6446,10 +6438,6 @@ extern TclStubs *tclStubsPtr;
#define Tcl_GetChannelError \
(tclStubsPtr->tcl_GetChannelError) /* 565 */
#endif
-#ifndef TclTomMathInitializeStubs
-#define TclTomMathInitializeStubs \
- (tclStubsPtr->tclTomMathInitializeStubs) /* 566 */
-#endif
#endif /* defined(USE_TCL_STUBS) && !defined(USE_TCL_STUB_PROCS) */
diff --git a/generic/tclStubInit.c b/generic/tclStubInit.c
index 3d7ecef..8274d1a 100644
--- a/generic/tclStubInit.c
+++ b/generic/tclStubInit.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclStubInit.c,v 1.125 2005/12/13 22:43:18 kennykb Exp $
+ * RCS: @(#) $Id: tclStubInit.c,v 1.126 2005/12/27 17:39:02 kennykb Exp $
*/
#include "tclInt.h"
@@ -1062,7 +1062,6 @@ TclStubs tclStubs = {
Tcl_GetChannelErrorInterp, /* 563 */
Tcl_SetChannelError, /* 564 */
Tcl_GetChannelError, /* 565 */
- TclTomMathInitializeStubs, /* 566 */
};
/* !END!: Do not edit above this line. */
diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c
index 133de97..75cd0c2 100644
--- a/generic/tclStubLib.c
+++ b/generic/tclStubLib.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclStubLib.c,v 1.12 2005/12/13 22:43:18 kennykb Exp $
+ * RCS: @(#) $Id: tclStubLib.c,v 1.13 2005/12/27 17:39:02 kennykb Exp $
*/
/*
@@ -135,9 +135,6 @@ Tcl_InitStubs(
* the TclTomMath_InitStubs macro, to insure that the Stubs table
* matches the header files used in compilation.
*
- * This procedure assumes that Tcl_InitStubs has been called first.
- * Hence, it appears in Tcl's internal Stubs table.
- *
*----------------------------------------------------------------------
*/
@@ -145,7 +142,7 @@ Tcl_InitStubs(
#undef TclTomMathInitializeStubs
#endif
-const char*
+MODULE_SCOPE CONST char*
TclTomMathInitializeStubs(
Tcl_Interp* interp, /* Tcl interpreter */
CONST char* version, /* Tcl version needed */
diff --git a/library/clock.tcl b/library/clock.tcl
index 4c64c27..1d75b7d 100644
--- a/library/clock.tcl
+++ b/library/clock.tcl
@@ -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: clock.tcl,v 1.28 2005/12/02 22:13:41 kennykb Exp $
+# RCS: @(#) $Id: clock.tcl,v 1.29 2005/12/27 17:39:02 kennykb Exp $
#
#----------------------------------------------------------------------
@@ -669,7 +669,7 @@ proc ::tcl::clock::format { args } {
# Set defaults
set clockval [lindex $args 0]
- set format {%a %b %d %H:%M:%S %z %Y}
+ set format {%a %b %d %H:%M:%S %Z %Y}
set gmt 0
set locale C
set timezone {}
diff --git a/libtommath/bn_mp_sqrt.c b/libtommath/bn_mp_sqrt.c
index ac8c2b8..72a9ff5 100644
--- a/libtommath/bn_mp_sqrt.c
+++ b/libtommath/bn_mp_sqrt.c
@@ -1,4 +1,5 @@
#include <tommath.h>
+
#ifdef BN_MP_SQRT_C
/* LibTomMath, multiple-precision integer library -- Tom St Denis
*
@@ -15,11 +16,20 @@
* Tom St Denis, tomstdenis@iahu.ca, http://math.libtomcrypt.org
*/
+#ifndef NO_FLOATING_POINT
+#include <math.h>
+#endif
+
/* this function is less generic than mp_n_root, simpler and faster */
int mp_sqrt(mp_int *arg, mp_int *ret)
{
int res;
mp_int t1,t2;
+ int i, j, k;
+#ifndef NO_FLOATING_POINT
+ double d;
+ mp_digit dig;
+#endif
/* must be positive */
if (arg->sign == MP_NEG) {
@@ -31,17 +41,49 @@ int mp_sqrt(mp_int *arg, mp_int *ret)
mp_zero(ret);
return MP_OKAY;
}
-
- if ((res = mp_init_copy(&t1, arg)) != MP_OKAY) {
- return res;
+
+ i = (arg->used / 2) - 1;
+ j = 2 * i;
+ if ((res = mp_init_size(&t1, i+2)) != MP_OKAY) {
+ return res;
}
-
+
if ((res = mp_init(&t2)) != MP_OKAY) {
goto E2;
}
- /* First approx. (not very bad for large arg) */
- mp_rshd (&t1,t1.used/2);
+ for (k = 0; k < i; ++k) {
+ t1.dp[k] = (mp_digit) 0;
+ }
+
+#ifndef NO_FLOATING_POINT
+
+ /* Estimate the square root using the hardware floating point unit. */
+
+ d = 0.0;
+ for (k = arg->used-1; k >= j; --k) {
+ d = ldexp(d, DIGIT_BIT) + (double) (arg->dp[k]);
+ }
+ d = sqrt(d);
+ dig = (mp_digit) ldexp(d, -DIGIT_BIT);
+ if (dig) {
+ t1.used = i+2;
+ t1.dp[i+1] = dig;
+ d -= ldexp((double) dig, DIGIT_BIT);
+ } else {
+ t1.used = i+1;
+ }
+ t1.dp[i] = (mp_digit) d;
+
+#else
+
+ /* Estimate the square root as having 1 in the most significant place. */
+
+ t1.used = i + 2;
+ t1.dp[i+1] = (mp_digit) 1;
+ t1.dp[i] = (mp_digit) 0;
+
+#endif
/* t1 > 0 */
if ((res = mp_div(arg,&t1,&t2,NULL)) != MP_OKAY) {
@@ -77,5 +119,5 @@ E2: mp_clear(&t1);
#endif
/* $Source: /root/tcl/repos-to-convert/tcl/libtommath/bn_mp_sqrt.c,v $ */
-/* $Revision: 1.1.1.2 $ */
-/* $Date: 2005/09/26 16:31:56 $ */
+/* $Revision: 1.2 $ */
+/* $Date: 2005/12/27 17:39:02 $ */
diff --git a/win/Makefile.in b/win/Makefile.in
index 5967b9f..20c5ac9 100644
--- a/win/Makefile.in
+++ b/win/Makefile.in
@@ -5,7 +5,7 @@
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
-# RCS: @(#) $Id: Makefile.in,v 1.95 2005/12/13 22:43:18 kennykb Exp $
+# RCS: @(#) $Id: Makefile.in,v 1.96 2005/12/27 17:39:02 kennykb Exp $
VERSION = @TCL_VERSION@
@@ -628,7 +628,9 @@ install-libraries: libraries install-tzdata install-msgs
@for i in "$(GENERIC_DIR)/tcl.h" "$(GENERIC_DIR)/tclDecls.h" \
"$(GENERIC_DIR)/tclPlatDecls.h" \
"$(GENERIC_DIR)/tclTomMath.h" \
- "$(GENERIC_DIR)/tclTomMathDecls.h" ; \
+ "$(GENERIC_DIR)/tclTomMathDecls.h" \
+ "$(TOMMATH_DIR)/tommath_class.h" \
+ "$(TOMMATH_DIR)/tommath_superclass.h" ; \
do \
$(COPY) "$$i" "$(INCLUDE_INSTALL_DIR)"; \
done;