From 20fbd4bb4bba957f3d3b611befff43c7fea5676d Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 24 Oct 2012 13:08:34 +0000 Subject: experimental implementation of FRQ-3579001 --- generic/tclLoad.c | 36 +++++++++++++++++++++++++++++++----- tests/load.test | 17 ++++++++++------- unix/tclLoadDl.c | 19 +++++++++++++++---- unix/tclLoadDyld.c | 36 ++++++++++++++++++++++++------------ 4 files changed, 80 insertions(+), 28 deletions(-) diff --git a/generic/tclLoad.c b/generic/tclLoad.c index 3fead6f..f8186d5 100644 --- a/generic/tclLoad.c +++ b/generic/tclLoad.c @@ -132,15 +132,41 @@ Tcl_LoadObjCmd( Tcl_LoadHandle loadHandle; Tcl_UniChar ch; unsigned len; + int index, flags = 0; + Tcl_Obj *const *savedobjv = objv; + static const char *const options[] = { + "-global", "-lazy", NULL + }; + enum options { + LOAD_GLOBAL, LOAD_LAZY + }; + while (objc > 2) { + if (TclGetString(objv[2])[0] != '-') { + break; + } + if (Tcl_GetIndexFromObj(interp, objv[2], options, "option", 0, + &index) != TCL_OK) { + return TCL_ERROR; + } + ++objv; --objc; + switch ((enum options) index) { + case LOAD_GLOBAL: + flags |= 1; + break; + case LOAD_LAZY: + flags |= 2; + break; + } + } if ((objc < 2) || (objc > 4)) { - Tcl_WrongNumArgs(interp, 1, objv, "fileName ?packageName? ?interp?"); + Tcl_WrongNumArgs(interp, 1, savedobjv, "fileName ?-global? ?-lazy? ?packageName? ?interp?"); return TCL_ERROR; } - if (Tcl_FSConvertToPathType(interp, objv[1]) != TCL_OK) { + if (Tcl_FSConvertToPathType(interp, savedobjv[1]) != TCL_OK) { return TCL_ERROR; } - fullFileName = Tcl_GetString(objv[1]); + fullFileName = Tcl_GetString(savedobjv[1]); Tcl_DStringInit(&pkgName); Tcl_DStringInit(&initName); @@ -297,7 +323,7 @@ Tcl_LoadObjCmd( * that. */ - splitPtr = Tcl_FSSplitPath(objv[1], &pElements); + splitPtr = Tcl_FSSplitPath(savedobjv[1], &pElements); Tcl_ListObjIndex(NULL, splitPtr, pElements -1, &pkgGuessPtr); pkgGuess = Tcl_GetString(pkgGuessPtr); if ((pkgGuess[0] == 'l') && (pkgGuess[1] == 'i') @@ -365,7 +391,7 @@ Tcl_LoadObjCmd( symbols[1] = NULL; Tcl_MutexLock(&packageMutex); - code = Tcl_LoadFile(interp, objv[1], symbols, 0, &initProc, + code = Tcl_LoadFile(interp, savedobjv[1], symbols, flags, &initProc, &loadHandle); Tcl_MutexUnlock(&packageMutex); if (code != TCL_OK) { diff --git a/tests/load.test b/tests/load.test index 78bf64c..8bd2291 100644 --- a/tests/load.test +++ b/tests/load.test @@ -47,32 +47,35 @@ testConstraint testsimplefilesystem \ test load-1.1 {basic errors} {} { list [catch {load} msg] $msg -} "1 {wrong \# args: should be \"load fileName ?packageName? ?interp?\"}" +} "1 {wrong \# args: should be \"load fileName ?-global? ?-lazy? ?packageName? ?interp?\"}" test load-1.2 {basic errors} {} { list [catch {load a b c d} msg] $msg -} "1 {wrong \# args: should be \"load fileName ?packageName? ?interp?\"}" +} "1 {wrong \# args: should be \"load fileName ?-global? ?-lazy? ?packageName? ?interp?\"}" test load-1.3 {basic errors} {} { list [catch {load a b foobar} msg] $msg } {1 {could not find interpreter "foobar"}} test load-1.4 {basic errors} {} { - list [catch {load {}} msg] $msg + list [catch {load {} -global} msg] $msg } {1 {must specify either file name or package name}} test load-1.5 {basic errors} {} { - list [catch {load {} {}} msg] $msg + list [catch {load {} -lazy {}} msg] $msg } {1 {must specify either file name or package name}} test load-1.6 {basic errors} {} { list [catch {load {} Unknown} msg] $msg } {1 {package "Unknown" isn't loaded statically}} +test load-1.7 {basic errors} {} { + list [catch {load foo -abc} msg] $msg +} "1 {bad option \"-abc\": must be -global or -lazy}" test load-2.1 {basic loading, with guess for package name} \ [list $dll $loaded] { - load [file join $testDir pkga$ext] + load [file join $testDir pkga$ext] -global list [pkga_eq abc def] [lsort [info commands pkga_*]] } {0 {pkga_eq pkga_quote}} interp create -safe child test load-2.2 {loading into a safe interpreter, with package name conversion} \ [list $dll $loaded] { - load [file join $testDir pkgb$ext] pKgB child + load [file join $testDir pkgb$ext] -lazy pKgB child list [child eval pkgb_sub 44 13] [catch {child eval pkgb_unsafe} msg] $msg \ [catch {pkgb_sub 12 10} msg2] $msg2 } {31 1 {invalid command name "pkgb_unsafe"} 1 {invalid command name "pkgb_sub"}} @@ -126,7 +129,7 @@ test load-5.1 {file name not specified and no static package: pick default} \ [list $dll $loaded] { catch {interp delete x} interp create x - load [file join $testDir pkga$ext] pkga + load [file join $testDir pkga$ext] -global pkga load {} pkga x set result [info loaded x] interp delete x diff --git a/unix/tclLoadDl.c b/unix/tclLoadDl.c index 9ff7657..9c021e1 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 & 1) { + dlopenflags |= RTLD_GLOBAL; + } else { + dlopenflags |= RTLD_LOCAL; + } + if (flags & 2) { + 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); } diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c index 4f39d1f..578ce10 100644 --- a/unix/tclLoadDyld.c +++ b/unix/tclLoadDyld.c @@ -170,6 +170,9 @@ TclpDlopen( int result; Tcl_DString ds; const char *nativePath, *nativeFileName = NULL; +#if TCL_DYLD_USE_DLFCN + int dlopenflags = 0; +#endif /* TCL_DYLD_USE_DLFCN */ /* * First try the full path the user gave us. This is particularly @@ -183,20 +186,27 @@ TclpDlopen( #if TCL_DYLD_USE_DLFCN /* - * Use (RTLD_NOW|RTLD_LOCAL) always, see [Bug #3216070] + * Use (RTLD_NOW|RTLD_LOCAL) as default, see [Bug #3216070] */ - dlHandle = dlopen(nativePath, RTLD_NOW | RTLD_LOCAL); + if (flags & 1) { + dlopenflags |= RTLD_GLOBAL; + } else { + dlopenflags |= RTLD_LOCAL; + } + if (flags & 2) { + dlopenflags |= RTLD_LAZY; + } else { + dlopenflags |= RTLD_NOW; + } + dlHandle = dlopen(nativePath, dlopenflags); if (!dlHandle) { /* * Let the OS loader examine the binary search path for whatever string * the user gave us which hopefully refers to a file on the binary * path. - * - * Use (RTLD_NOW|RTLD_LOCAL) always, see [Bug #3216070] - */ - dlHandle = dlopen(nativeFileName, RTLD_NOW | RTLD_LOCAL); + dlHandle = dlopen(nativeFileName, dlopenflags); if (!dlHandle) { errMsg = dlerror(); } @@ -238,9 +248,10 @@ TclpDlopen( err = NSCreateObjectFileImageFromFile(nativePath, &dyldObjFileImage); if (err == NSObjectFileImageSuccess && dyldObjFileImage) { - module = NSLinkModule(dyldObjFileImage, nativePath, - NSLINKMODULE_OPTION_BINDNOW | NSLINKMODULE_OPTION_PRIVATE - | NSLINKMODULE_OPTION_RETURN_ON_ERROR); + int nsflags = NSLINKMODULE_OPTION_RETURN_ON_ERROR; + if (!(flags & 1)) nsflags |= NSLINKMODULE_OPTION_PRIVATE; + if (!(flags & 2)) nsflags |= NSLINKMODULE_OPTION_BINDNOW; + module = NSLinkModule(dyldObjFileImage, nativePath, nsflags); NSDestroyObjectFileImage(dyldObjFileImage); if (module) { modulePtr = ckalloc(sizeof(Tcl_DyldModuleHandle)); @@ -565,6 +576,7 @@ TclpLoadMemory( Tcl_DyldModuleHandle *modulePtr; NSModule module; const char *objFileImageErrMsg = NULL; + int nsflags = NSLINKMODULE_OPTION_RETURN_ON_ERROR; /* * Try to create an object file image that we can load from. @@ -659,9 +671,9 @@ TclpLoadMemory( * Extract the module we want from the image of the object file. */ - module = NSLinkModule(dyldObjFileImage, "[Memory Based Bundle]", - NSLINKMODULE_OPTION_BINDNOW | NSLINKMODULE_OPTION_PRIVATE - | NSLINKMODULE_OPTION_RETURN_ON_ERROR); + if (!(flags & 1)) nsflags |= NSLINKMODULE_OPTION_PRIVATE; + if (!(flags & 2)) nsflags |= NSLINKMODULE_OPTION_BINDNOW; + module = NSLinkModule(dyldObjFileImage, "[Memory Based Bundle]", nsflags); NSDestroyObjectFileImage(dyldObjFileImage); if (!module) { NSLinkEditErrors editError; -- cgit v0.12 From 66cb991a8b6edb5c8f424d1aed10e35b8113bd13 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 24 Oct 2012 21:22:30 +0000 Subject: syntax improvement: expect options before the filename

start at documentation --- doc/Load.3 | 3 ++- doc/load.n | 15 ++++++++++++--- generic/tclLoad.c | 29 ++++++++++++++--------------- tests/load.test | 18 +++++++++--------- unix/tclLoadDl.c | 2 +- unix/tclLoadNext.c | 2 +- 6 files changed, 39 insertions(+), 30 deletions(-) diff --git a/doc/Load.3 b/doc/Load.3 index c088f32..9602b77 100644 --- a/doc/Load.3 +++ b/doc/Load.3 @@ -31,7 +31,8 @@ Array of names of symbols to be resolved during the load of the library, or NULL if no symbols are to be resolved. If an array is given, the last entry in the array must be NULL. .AP int flags in -Reserved for future expansion. Must be 0. +The value should normally be 0, but \fITCL_LOAD_GLOBALfR or \fITCL_LOAD_LAZYfR +or a combination of those two is allowed as well. .AP void *procPtrs out Points to an array that will hold the addresses of the functions described in the \fIsymbols\fR argument. Should be NULL if no symbols are to be resolved. diff --git a/doc/load.n b/doc/load.n index c32cb65..7f7c624 100644 --- a/doc/load.n +++ b/doc/load.n @@ -11,11 +11,11 @@ .SH NAME load \- Load machine code and initialize new commands .SH SYNOPSIS -\fBload \fIfileName\fR +\fBload\fR ?\fB\-global\fR? ?\fB\-lazy\fR? ?\fB\-\-\fR? \fIfileName\fR .br -\fBload \fIfileName packageName\fR +\fBload ?\fB\-global\fR? ?\fB\-lazy\fR? ?\fB\-\-\fR? \fIfileName packageName\fR .br -\fBload \fIfileName packageName interp\fR +\fBload ?\fB\-global\fR? ?\fB\-lazy\fR? ?\fB\-\-\fR? \fIfileName packageName interp\fR .BE .SH DESCRIPTION .PP @@ -104,6 +104,15 @@ Otherwise, the \fBload\fR command searches for a dynamically loaded package by that name, and uses it if it is found. If several different files have been \fBload\fRed with different versions of the package, Tcl picks the file that was loaded first. +.PP +If \fB\-global\fR is specified preceding the filename, all symbols +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. +On platforms which do not support the \fB\-global\fR or \fB\-lazy\fR +options, the options still exist but have no effect. .SH "PORTABILITY ISSUES" .TP \fBWindows\fR\0\0\0\0\0 diff --git a/generic/tclLoad.c b/generic/tclLoad.c index f8186d5..22cfc65 100644 --- a/generic/tclLoad.c +++ b/generic/tclLoad.c @@ -135,38 +135,37 @@ Tcl_LoadObjCmd( int index, flags = 0; Tcl_Obj *const *savedobjv = objv; static const char *const options[] = { - "-global", "-lazy", NULL + "-global", "-lazy", "--", NULL }; enum options { - LOAD_GLOBAL, LOAD_LAZY + LOAD_GLOBAL, LOAD_LAZY, LOAD_LAST }; while (objc > 2) { - if (TclGetString(objv[2])[0] != '-') { + if (TclGetString(objv[1])[0] != '-') { break; } - if (Tcl_GetIndexFromObj(interp, objv[2], options, "option", 0, + if (Tcl_GetIndexFromObj(interp, objv[1], options, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } ++objv; --objc; - switch ((enum options) index) { - case LOAD_GLOBAL: + if (LOAD_GLOBAL == (enum options) index) { flags |= 1; - break; - case LOAD_LAZY: + } else if (LOAD_LAZY == (enum options) index) { flags |= 2; - break; + } else { + break; } } if ((objc < 2) || (objc > 4)) { - Tcl_WrongNumArgs(interp, 1, savedobjv, "fileName ?-global? ?-lazy? ?packageName? ?interp?"); + Tcl_WrongNumArgs(interp, 1, savedobjv, "?-global? ?-lazy? ?--? fileName ?packageName? ?interp?"); return TCL_ERROR; } - if (Tcl_FSConvertToPathType(interp, savedobjv[1]) != TCL_OK) { + if (Tcl_FSConvertToPathType(interp, objv[1]) != TCL_OK) { return TCL_ERROR; } - fullFileName = Tcl_GetString(savedobjv[1]); + fullFileName = Tcl_GetString(objv[1]); Tcl_DStringInit(&pkgName); Tcl_DStringInit(&initName); @@ -323,7 +322,7 @@ Tcl_LoadObjCmd( * that. */ - splitPtr = Tcl_FSSplitPath(savedobjv[1], &pElements); + splitPtr = Tcl_FSSplitPath(objv[1], &pElements); Tcl_ListObjIndex(NULL, splitPtr, pElements -1, &pkgGuessPtr); pkgGuess = Tcl_GetString(pkgGuessPtr); if ((pkgGuess[0] == 'l') && (pkgGuess[1] == 'i') @@ -391,7 +390,7 @@ Tcl_LoadObjCmd( symbols[1] = NULL; Tcl_MutexLock(&packageMutex); - code = Tcl_LoadFile(interp, savedobjv[1], symbols, flags, &initProc, + code = Tcl_LoadFile(interp, objv[1], symbols, flags, &initProc, &loadHandle); Tcl_MutexUnlock(&packageMutex); if (code != TCL_OK) { @@ -417,7 +416,7 @@ Tcl_LoadObjCmd( pkgPtr->unloadProc = (Tcl_PackageUnloadProc *) Tcl_FindSymbol(interp, loadHandle, Tcl_DStringValue(&unloadName)); - pkgPtr->safeUnloadProc = (Tcl_PackageUnloadProc *) + pkgPtr->safeUnloadProc = (Tcl_PackageUnloadProc *) Tcl_FindSymbol(interp, loadHandle, Tcl_DStringValue(&safeUnloadName)); pkgPtr->interpRefCount = 0; diff --git a/tests/load.test b/tests/load.test index 8bd2291..19303ce 100644 --- a/tests/load.test +++ b/tests/load.test @@ -47,35 +47,35 @@ testConstraint testsimplefilesystem \ test load-1.1 {basic errors} {} { list [catch {load} msg] $msg -} "1 {wrong \# args: should be \"load fileName ?-global? ?-lazy? ?packageName? ?interp?\"}" +} "1 {wrong \# args: should be \"load ?-global? ?-lazy? ?--? fileName ?packageName? ?interp?\"}" test load-1.2 {basic errors} {} { list [catch {load a b c d} msg] $msg -} "1 {wrong \# args: should be \"load fileName ?-global? ?-lazy? ?packageName? ?interp?\"}" +} "1 {wrong \# args: should be \"load ?-global? ?-lazy? ?--? fileName ?packageName? ?interp?\"}" test load-1.3 {basic errors} {} { list [catch {load a b foobar} msg] $msg } {1 {could not find interpreter "foobar"}} test load-1.4 {basic errors} {} { - list [catch {load {} -global} msg] $msg + list [catch {load -global {}} msg] $msg } {1 {must specify either file name or package name}} test load-1.5 {basic errors} {} { - list [catch {load {} -lazy {}} msg] $msg + list [catch {load -lazy {} {}} msg] $msg } {1 {must specify either file name or package name}} test load-1.6 {basic errors} {} { list [catch {load {} Unknown} msg] $msg } {1 {package "Unknown" isn't loaded statically}} test load-1.7 {basic errors} {} { - list [catch {load foo -abc} msg] $msg -} "1 {bad option \"-abc\": must be -global or -lazy}" + list [catch {load -abc foo} msg] $msg +} "1 {bad option \"-abc\": must be -global, -lazy, or --}" test load-2.1 {basic loading, with guess for package name} \ [list $dll $loaded] { - load [file join $testDir pkga$ext] -global + load -global [file join $testDir pkga$ext] list [pkga_eq abc def] [lsort [info commands pkga_*]] } {0 {pkga_eq pkga_quote}} interp create -safe child test load-2.2 {loading into a safe interpreter, with package name conversion} \ [list $dll $loaded] { - load [file join $testDir pkgb$ext] -lazy pKgB child + load -lazy [file join $testDir pkgb$ext] pKgB child list [child eval pkgb_sub 44 13] [catch {child eval pkgb_unsafe} msg] $msg \ [catch {pkgb_sub 12 10} msg2] $msg2 } {31 1 {invalid command name "pkgb_unsafe"} 1 {invalid command name "pkgb_sub"}} @@ -129,7 +129,7 @@ test load-5.1 {file name not specified and no static package: pick default} \ [list $dll $loaded] { catch {interp delete x} interp create x - load [file join $testDir pkga$ext] -global pkga + load -global [file join $testDir pkga$ext] pkga load {} pkga x set result [info loaded x] interp delete x diff --git a/unix/tclLoadDl.c b/unix/tclLoadDl.c index 9c021e1..267067f 100644 --- a/unix/tclLoadDl.c +++ b/unix/tclLoadDl.c @@ -164,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 */ diff --git a/unix/tclLoadNext.c b/unix/tclLoadNext.c index f5911f8..484b1d6 100644 --- a/unix/tclLoadNext.c +++ b/unix/tclLoadNext.c @@ -134,7 +134,7 @@ FindSymbol( const char *symbol) { Tcl_PackageInitProc *proc = NULL; - + if (symbol) { char sym[strlen(symbol) + 2]; -- cgit v0.12 From c7943be5f2af9c61fd59c86c6d96840896fdc1da Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 7 Nov 2012 08:03:10 +0000 Subject: 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. --- doc/load.n | 11 +++++++++-- generic/tcl.h | 8 ++++++++ generic/tclLoad.c | 4 ++-- tests/load.test | 3 +++ unix/tclLoadDl.c | 4 ++-- unix/tclLoadDyld.c | 4 ++-- 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; -- cgit v0.12 From 9ae0d652824688e3ac54ef7d4df854cbedbefe72 Mon Sep 17 00:00:00 2001 From: dkf Date: Thu, 15 Nov 2012 01:44:12 +0000 Subject: unbreak trunk; fix some warnings --- unix/tclLoadDyld.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c index 5df022e..50c283d 100644 --- a/unix/tclLoadDyld.c +++ b/unix/tclLoadDyld.c @@ -205,6 +205,7 @@ TclpDlopen( * Let the OS loader examine the binary search path for whatever string * the user gave us which hopefully refers to a file on the binary * path. + */ dlHandle = dlopen(nativeFileName, dlopenflags); if (!dlHandle) { @@ -661,7 +662,7 @@ TclpLoadMemory( vm_deallocate(mach_task_self(), (vm_address_t) buffer, size); if (objFileImageErrMsg != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "NSCreateObjectFileImageFromMemory() error: ", + "NSCreateObjectFileImageFromMemory() error: %s", objFileImageErrMsg)); } return TCL_ERROR; -- cgit v0.12