summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-11-07 08:03:10 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-11-07 08:03:10 (GMT)
commitc7943be5f2af9c61fd59c86c6d96840896fdc1da (patch)
treece8aaef67aa0fe96f08821954b71216a91a10eea
parent3bbffed01d2dbaa523b752cf39da3868869ab30a (diff)
downloadtcl-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.n11
-rw-r--r--generic/tcl.h8
-rw-r--r--generic/tclLoad.c4
-rw-r--r--tests/load.test3
-rw-r--r--unix/tclLoadDl.c4
-rw-r--r--unix/tclLoadDyld.c4
6 files changed, 26 insertions, 8 deletions
diff --git a/doc/load.n b/doc/load.n
index 7f7c624..7c2687e 100644
--- a/doc/load.n
+++ b/doc/load.n
@@ -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;