summaryrefslogtreecommitdiffstats
path: root/unix/tclLoadDl.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2012-11-15 00:20:57 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2012-11-15 00:20:57 (GMT)
commit0cf9c26b08c885caa146634eadddc5fb3dbcd5e7 (patch)
treeb6e3d97e6182fe7f70d8e6a47a385064b885baaf /unix/tclLoadDl.c
parent284b205a9a4c6d334b4f752ea17018f610a960bb (diff)
parent37e6c3852b68f12e24e223e1a1a5d30b1bafb13f (diff)
downloadtcl-0cf9c26b08c885caa146634eadddc5fb3dbcd5e7.zip
tcl-0cf9c26b08c885caa146634eadddc5fb3dbcd5e7.tar.gz
tcl-0cf9c26b08c885caa146634eadddc5fb3dbcd5e7.tar.bz2
IMPLEMENTATION OF TIP#416: New Options for 'load': -global and -lazy
Diffstat (limited to 'unix/tclLoadDl.c')
-rw-r--r--unix/tclLoadDl.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/unix/tclLoadDl.c b/unix/tclLoadDl.c
index 9ff7657..dc711f8 100644
--- a/unix/tclLoadDl.c
+++ b/unix/tclLoadDl.c
@@ -75,6 +75,7 @@ TclpDlopen(
void *handle;
Tcl_LoadHandle newHandle;
const char *native;
+ int dlopenflags = 0;
/*
* First try the full path the user gave us. This is particularly
@@ -84,9 +85,19 @@ TclpDlopen(
native = Tcl_FSGetNativePath(pathPtr);
/*
- * Use (RTLD_NOW|RTLD_LOCAL) always, see [Bug #3216070]
+ * Use (RTLD_NOW|RTLD_LOCAL) as default, see [Bug #3216070]
*/
- handle = dlopen(native, RTLD_NOW | RTLD_LOCAL);
+ if (flags & TCL_LOAD_GLOBAL) {
+ dlopenflags |= RTLD_GLOBAL;
+ } else {
+ dlopenflags |= RTLD_LOCAL;
+ }
+ if (flags & TCL_LOAD_LAZY) {
+ dlopenflags |= RTLD_LAZY;
+ } else {
+ dlopenflags |= RTLD_NOW;
+ }
+ handle = dlopen(native, dlopenflags);
if (handle == NULL) {
/*
* Let the OS loader examine the binary search path for whatever
@@ -99,9 +110,9 @@ TclpDlopen(
native = Tcl_UtfToExternalDString(NULL, fileName, -1, &ds);
/*
- * Use (RTLD_NOW|RTLD_LOCAL) always, see [Bug #3216070]
+ * Use (RTLD_NOW|RTLD_LOCAL) as default, see [Bug #3216070]
*/
- handle = dlopen(native, RTLD_NOW | RTLD_LOCAL);
+ handle = dlopen(native, dlopenflags);
Tcl_DStringFree(&ds);
}
@@ -153,7 +164,7 @@ FindSymbol(
const char *native; /* Name of the library to be loaded, in
* system encoding */
Tcl_DString newName, ds; /* Buffers for converting the name to
- * system encoding and prepending an
+ * system encoding and prepending an
* underscore*/
void *handle = (void *) loadHandle->clientData;
/* Native handle to the loaded library */