From cb09c58ac476c67cd1208b8cdc82cd5351f74f14 Mon Sep 17 00:00:00 2001 From: dkf Date: Sun, 2 Dec 2001 22:06:23 +0000 Subject: Added field to tcl_platform to describe the machine-word size. --- ChangeLog | 12 ++++++++++++ doc/tclvars.n | 12 +++++++----- generic/tclBasic.c | 5 ++++- tests/platform.test | 13 +------------ tests/safe.test | 16 ++-------------- 5 files changed, 26 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 24e6c2d..b3b1b45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2001-12-02 Donal K. Fellows + + * tests/platform.test (platform-1.1): + * tests/safe.test (safe-6.3): These two tests are trivially + affected. + * doc/tclvars.n: Doc'd change. + * generic/tclBasic.c (Tcl_CreateInterp): Added an entry "wordSize" + to the tcl_platform array to describe the size of the machine word + (in units of whatever size_t returns.) Suggested by Arjen Markus, + and this may be useful in all sorts of scripts where the word size + is not guaranteed. + 2001-11-27 Donal K. Fellows * generic/tclTest.c (PretendTclpStat): Fixed so that it will diff --git a/doc/tclvars.n b/doc/tclvars.n index 2c51750..cf70445 100644 --- a/doc/tclvars.n +++ b/doc/tclvars.n @@ -5,7 +5,7 @@ '\" See the file "license.terms" for information on usage and redistribution '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES. '\" -'\" RCS: @(#) $Id: tclvars.n,v 1.9 2001/09/17 11:51:58 msofer Exp $ +'\" RCS: @(#) $Id: tclvars.n,v 1.9.2.1 2001/12/02 22:06:23 dkf Exp $ '\" .so man.macros .TH tclvars n 8.0 Tcl "Tcl Built-In Commands" @@ -245,10 +245,6 @@ retrieve any relevant information. In addition, extensions and applications may add additional values to the array. The predefined elements are: - - - - .RS .VS .TP @@ -295,6 +291,12 @@ This identifies the current user based on the login information available on the platform. This comes from the USER or LOGNAME environment variable on Unix, and the value from GetUserName on Windows and Macintosh. +.TP +\fBwordSize\fR +.VS 8.4 +This gives the size of the native-machine word in bytes (strictly, it +is same as the result of evaluating \fIsizeof(long)\fR in C.) +.VE 8.4 .RE .TP \fBtcl_precision\fR diff --git a/generic/tclBasic.c b/generic/tclBasic.c index f73f214..1aa9e73 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -12,7 +12,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.35.6.3 2001/09/27 13:38:33 dkf Exp $ + * RCS: @(#) $Id: tclBasic.c,v 1.35.6.4 2001/12/02 22:06:23 dkf Exp $ */ #include "tclInt.h" @@ -523,6 +523,9 @@ Tcl_CreateInterp() ((order.c[0] == 1) ? "littleEndian" : "bigEndian"), TCL_GLOBAL_ONLY); + Tcl_SetVar2Ex(interp, "tcl_platform", "wordSize", + Tcl_NewLongObj((long) sizeof(long)), TCL_GLOBAL_ONLY); + /* * Set up other variables such as tcl_version and tcl_library */ diff --git a/tests/platform.test b/tests/platform.test index 9c7dec5..288cc72 100644 --- a/tests/platform.test +++ b/tests/platform.test @@ -23,19 +23,8 @@ test platform-1.1 {TclpSetVariables: tcl_platform} { set result [i eval {lsort [array names tcl_platform]}] interp delete i set result -} {byteOrder machine os osVersion platform user} +} {byteOrder machine os osVersion platform user wordSize} # cleanup ::tcltest::cleanupTests return - - - - - - - - - - - diff --git a/tests/safe.test b/tests/safe.test index 2eb6788..115207c 100644 --- a/tests/safe.test +++ b/tests/safe.test @@ -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: safe.test,v 1.10 2000/11/17 11:06:54 dkf Exp $ +# RCS: @(#) $Id: safe.test,v 1.10.12.1 2001/12/02 22:06:23 dkf Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -185,7 +185,7 @@ test safe-6.3 {test safe interpreters knowledge of the world} { set r [lreplace $r $threaded $threaded] } set r -} {byteOrder platform} +} {byteOrder platform wordSize} # more test should be added to check that hostname, nameofexecutable, # aren't leaking infos, but they still do... @@ -518,15 +518,3 @@ test safe-11.8 {testing safe encoding} { # cleanup ::tcltest::cleanupTests return - - - - - - - - - - - - -- cgit v0.12