diff options
| author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-11-15 00:20:57 (GMT) |
|---|---|---|
| committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2012-11-15 00:20:57 (GMT) |
| commit | 59c308ebf02648dbc908f7cf598e3a3c9d5ad03a (patch) | |
| tree | b6e3d97e6182fe7f70d8e6a47a385064b885baaf /unix/tclLoadDl.c | |
| parent | 04b42c6d4601e8b3be0ec772f5fe10b9627ab6aa (diff) | |
| parent | 73cbb5ef6f058c253ffefb4fac0cdfbee0210807 (diff) | |
| download | tcl-59c308ebf02648dbc908f7cf598e3a3c9d5ad03a.zip tcl-59c308ebf02648dbc908f7cf598e3a3c9d5ad03a.tar.gz tcl-59c308ebf02648dbc908f7cf598e3a3c9d5ad03a.tar.bz2 | |
IMPLEMENTATION OF TIP#416: New Options for 'load': -global and -lazy
Diffstat (limited to 'unix/tclLoadDl.c')
| -rw-r--r-- | unix/tclLoadDl.c | 21 |
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 */ |
