|
2007-12-04
| ||
| 23:36 | • Ticket [1841549fff] Compatibility issues about 32-bit integers and wide integers... artifact: e77c5392ef user: dkf | |
| 23:27 | • Ticket [1841549fff]: 5 changes artifact: a8d5c55108 user: dgp | |
| 16:46 | • Ticket [1841549fff]: 4 changes artifact: 9a1262c3c6 user: nobody | |
| 00:34 | • Closed ticket [1841549fff]. artifact: 22c107e458 user: dgp | |
|
2007-12-02
| ||
| 20:16 | • Ticket [1841549fff]: 2 changes artifact: 5ed8b4687f user: dkf | |
|
2007-11-30
| ||
| 09:19 | • New ticket [1841549fff]. artifact: 9d4b289210 user: nobody | |
Compatibility issues about 32-bit integers and wide integers
Closed / Invalid1841549fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2007-11-30 09:19:47
Tcl8.4.12 is not compatible with Tcl8.3.2 in the following example, so I
have to find a way to make the result equal.
The example:
set var1 "-2147483647"
if { $var1 == 0x80000001 } {
set res "ok";
} else {
set res "nok";
}
I checked the tcl8.4.12's configure file and modified the line 4637 to let
the configure process always enters the "if condition",so
TCL_WIDE_INT_IS_LONG is defined to 1. And then make and make install to
build the tcl lib.
4637 #if test "${tcl_cv_type_64bit}" = none ; then
4638 if test "test" = "test" ; then
4639 cat >> confdefs.h <<\EOF
4640 #define TCL_WIDE_INT_IS_LONG 1
4641 EOF
4642
4643 echo "$ac_t""using long" 1>&6
4644 else
4645 cat >> confdefs.h <<EOF
4646 #define TCL_WIDE_INT_TYPE ${tcl_cv_type_64bit}
4647 EOF
I tested in linux and HP unix, it runs as I wish.But in solaris 8, after I
build the tcl lib successfully, I run my app and got a TCL_ERROR in the
function call to Tcl_GetIntFromObj, and the line from 1767~1774 in file
generic/tclObj.c is the following:
if ((LLONG_MAX > UINT_MAX)
&& ((w > UINT_MAX) || (w < -(Tcl_WideInt)UINT_MAX))) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"integer value too large to represent as non-long integer",
-1));
}
return TCL_ERROR;
The configure command I use in solaris 8 is :
env CC=cc ./configure --enable-threads --disable-64bit --disable-64bit-vis
-prefix=/home/test/tcl8412
Anyone provide a solution for the above? The requirement is very simple:
just to make tcl8.4.12 act as the same as tcl8.3.2 in the above tcl
script.
Thanks and Regards
Jun
dkf Ticket [1841549fff]: 2 changes
[History diff]2007-12-02 20:16:33
dgpplain2007-12-04 00:34:37
Logged In: YES
user_id=80530
Originator: NO
This is not a bug, but an intentional change
in the 8.3 -> 8.4 migration to provide
limited support for 64-bit integers.
Tcl 8.4 was first released in 2002. It's
well past time to adapt your scripts.
This modification to your script will run
the same in all Tcl releases; 8.3, 8.4, and
8.5:
set var1 "-2147483647"
if { $var1 == int(0x80000001) } {
set res "ok";
} else {
set res "nok";
}
[email protected]plain2007-12-04 16:46:06
Logged In: NO Hi dgp Thanks a lot for ur reponse. Because my tcl scripts has been released for many years and many place for others, so it is very difficult for the former person to modify the scripts one by one. In their environment, no 64bit requirement needed.The only reason that I suggest them to update tcl lib for 8.3 to 8.4 is that 8.4 relased version has fixed many defects or bugs compared with 8.3. I don't want this update cause the old scripts executed error. So can u suggest a way to modify the macro configure file or tclPort.h file to make it back-compatible? Yeah, I know tcl8.4 support 64bit is a great progress and I'd like it to support in 64bit environment. But for the old ones, what I want is to make the same condition to act in same result. Regards Jun
dgpplain2007-12-04 23:27:11
Logged In: YES user_id=80530 Originator: NO dkf, can you offer any additional help or advice on this report? If not, maybe the crowd in the comp.lang.tcl newsgroup can remember how they handled this migration. I really think your scripts need to be revised. Besides the 8.3->8.4 portability problem you've already discovered, your scripts also have a 32-bit -> 64-bit platform portability issue. I don't really see the difficulty for your users either. You're already telling them, "Hey upgrade from Tcl 8.3 to Tcl 8.4" so at the same time just tell them "Hey upgrade from myScripts 1.0 to myScripts 2.0. Here they are". Your alternative solution of "Don't upgrade from Tcl 8.3 to Tcl 8.4. Instead upgrade to my customized fork of Tcl 8.4" sounds like the wrong idea to me. Looking forward, Tcl 8.5 goes even further in doing away with integer overflow magic, and integers have unlimited range. If you want overflow, you'll need to code your scripts to have it explicitly.
dkfplain2007-12-04 23:36:59
Logged In: YES user_id=79902 Originator: NO I suppose you could hack the Makefile after configure but before build to define TCL_WIDE_INT_IS_LONG, which will turn off a lot of 64-bit-ness on 32-bit systems. If it will build that way (it might cause problems with the I/O system). It's horribly hacky though. Adding calls to the int() function in suitable spots in [expr] is probably easier (and will work with 8.5 too!)
Log in (anonymous is fine) to add a comment.