diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-11-07 08:03:10 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-11-07 08:03:10 (GMT) |
commit | c7943be5f2af9c61fd59c86c6d96840896fdc1da (patch) | |
tree | ce8aaef67aa0fe96f08821954b71216a91a10eea | |
parent | 3bbffed01d2dbaa523b752cf39da3868869ab30a (diff) | |
download | tcl-c7943be5f2af9c61fd59c86c6d96840896fdc1da.zip tcl-c7943be5f2af9c61fd59c86c6d96840896fdc1da.tar.gz tcl-c7943be5f2af9c61fd59c86c6d96840896fdc1da.tar.bz2 |
Finish the TIP #416 implementation as specified (#define's were still missing). Added warning to "load" documentation. Added test case for using -global without specifying filename.
-rw-r--r-- | doc/load.n | 11 | ||||
-rw-r--r-- | generic/tcl.h | 8 | ||||
-rw-r--r-- | generic/tclLoad.c | 4 | ||||
-rw-r--r-- | tests/load.test | 3 | ||||
-rw-r--r-- | unix/tclLoadDl.c | 4 | ||||
-rw-r--r-- | unix/tclLoadDyld.c | 4 |
6 files changed, 26 insertions, 8 deletions
@@ -110,9 +110,16 @@ found in the shared library are exported for global use by other libraries. The option \fB\-lazy\fR delays the actual loading of symbols until their first actual use. The options may be abbreviated. The option \fB\-\-\fR indicates the end of the options, and should -be used if you wish to use a filename which starts with \fB\-\fR. +be used if you wish to use a filename which starts with \fB\-\fR +and you provide a packageName to the \fBload\fR command. +.PP On platforms which do not support the \fB\-global\fR or \fB\-lazy\fR -options, the options still exist but have no effect. +options, the options still exist but have no effect. Note that use +of the \fB\-global\fR or \fB\-lazy\fR option may lead to crashes +in your application later (in case of symbol conflicts resp. missing +symbols), which cannot be detected during the \fBload\fR. So, only +use this when you know what you are doing, you will not get a nice +error message when something is wrong with the loaded library. .SH "PORTABILITY ISSUES" .TP \fBWindows\fR\0\0\0\0\0 diff --git a/generic/tcl.h b/generic/tcl.h index 3f9f06a..c2159f7 100644 --- a/generic/tcl.h +++ b/generic/tcl.h @@ -2364,6 +2364,14 @@ typedef int (Tcl_ArgvGenFuncProc)(ClientData clientData, Tcl_Interp *interp, /* *---------------------------------------------------------------------------- + * Definitions needed for the Tcl_LoadFile function. [TIP #416] + */ + +#define TCL_LOAD_GLOBAL 1 +#define TCL_LOAD_LAZY 2 + +/* + *---------------------------------------------------------------------------- * Single public declaration for NRE. */ diff --git a/generic/tclLoad.c b/generic/tclLoad.c index 22cfc65..5cacab1 100644 --- a/generic/tclLoad.c +++ b/generic/tclLoad.c @@ -151,9 +151,9 @@ Tcl_LoadObjCmd( } ++objv; --objc; if (LOAD_GLOBAL == (enum options) index) { - flags |= 1; + flags |= TCL_LOAD_GLOBAL; } else if (LOAD_LAZY == (enum options) index) { - flags |= 2; + flags |= TCL_LOAD_LAZY; } else { break; } diff --git a/tests/load.test b/tests/load.test index 19303ce..eef677f 100644 --- a/tests/load.test +++ b/tests/load.test @@ -66,6 +66,9 @@ test load-1.6 {basic errors} {} { test load-1.7 {basic errors} {} { list [catch {load -abc foo} msg] $msg } "1 {bad option \"-abc\": must be -global, -lazy, or --}" +test load-1.8 {basic errors} {} { + list [catch {load -global} msg] $msg +} "1 {couldn't figure out package name for -global}" test load-2.1 {basic loading, with guess for package name} \ [list $dll $loaded] { diff --git a/unix/tclLoadDl.c b/unix/tclLoadDl.c index 267067f..dc711f8 100644 --- a/unix/tclLoadDl.c +++ b/unix/tclLoadDl.c @@ -87,12 +87,12 @@ TclpDlopen( /* * Use (RTLD_NOW|RTLD_LOCAL) as default, see [Bug #3216070] */ - if (flags & 1) { + if (flags & TCL_LOAD_GLOBAL) { dlopenflags |= RTLD_GLOBAL; } else { dlopenflags |= RTLD_LOCAL; } - if (flags & 2) { + if (flags & TCL_LOAD_LAZY) { dlopenflags |= RTLD_LAZY; } else { dlopenflags |= RTLD_NOW; diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c index 578ce10..5df022e 100644 --- a/unix/tclLoadDyld.c +++ b/unix/tclLoadDyld.c @@ -189,12 +189,12 @@ TclpDlopen( * Use (RTLD_NOW|RTLD_LOCAL) as default, see [Bug #3216070] */ - if (flags & 1) { + if (flags & TCL_LOAD_GLOBAL) { dlopenflags |= RTLD_GLOBAL; } else { dlopenflags |= RTLD_LOCAL; } - if (flags & 2) { + if (flags & TCL_LOAD_LAZY) { dlopenflags |= RTLD_LAZY; } else { dlopenflags |= RTLD_NOW; |