diff options
author | Kevin B Kenny <kennykb@acm.org> | 2010-04-02 21:21:04 (GMT) |
---|---|---|
committer | Kevin B Kenny <kennykb@acm.org> | 2010-04-02 21:21:04 (GMT) |
commit | bd2c56d7039122dcb51ef36f39766e245c84d821 (patch) | |
tree | fe391271cb3355eb790c38ed7e17ab484df92009 /unix/tclLoadShl.c | |
parent | 859e9838d18c82b7c6fbcc1c9af736f6be73aecb (diff) | |
download | tcl-bd2c56d7039122dcb51ef36f39766e245c84d821.zip tcl-bd2c56d7039122dcb51ef36f39766e245c84d821.tar.gz tcl-bd2c56d7039122dcb51ef36f39766e245c84d821.tar.bz2 |
* generic/tcl.decls: [TIP #357]: First round of changes
* generic/tclDecls.h: to export Tcl_LoadFile, Tcl_FindSymbol,
* generic/tclIOUtil.c: and Tcl_FSUnloadFile to the public API.
* generic/tclInt.h:
* generic/tclLoad.c:
* generic/tclLoadNone.c:
* generic/tclStubInit.c:
* tests/fileSystem.test:
* tests/load.test:
* tests/unload.test:
* unix/tclLoadDl.c:
* unix/tclLoadDyld.c:
* unix/tclLoadNext.c:
* unix/tclLoadOSF.c:
* unix/tclLoadShl.c:
* unix/tclUnixPipe.c:
* win/Makefile.in:
* win/tclWinLoad.c:
Diffstat (limited to 'unix/tclLoadShl.c')
-rw-r--r-- | unix/tclLoadShl.c | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/unix/tclLoadShl.c b/unix/tclLoadShl.c index bf46cf5..a690dac 100644 --- a/unix/tclLoadShl.c +++ b/unix/tclLoadShl.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclLoadShl.c,v 1.19 2010/03/11 15:02:33 nijtmans Exp $ + * RCS: @(#) $Id: tclLoadShl.c,v 1.20 2010/04/02 21:21:06 kennykb Exp $ */ #include <dl.h> @@ -25,6 +25,14 @@ #include "tclInt.h" +/* Static functions defined within this file */ + +static void* FindSymbol(Tcl_Interp* interp, Tcl_LoadHandle loadHandle, + const char* symbol); +static void +UnloadFile(Tcl_LoadHandle handle); + + /* *---------------------------------------------------------------------- * @@ -57,6 +65,7 @@ TclpDlopen( * file. */ { shl_t handle; + Tcl_LoadHandle newHandle; const char *native; char *fileName = Tcl_GetString(pathPtr); @@ -97,15 +106,18 @@ TclpDlopen( Tcl_PosixError(interp), (char *) NULL); return TCL_ERROR; } - *loadHandle = (Tcl_LoadHandle) handle; - *unloadProcPtr = &TclpUnloadFile; + newHandle = (Tcl_LoadHandle) ckalloc(sizeof(*newHandle)); + newHandle->clientData = handle; + newHandle->findSymbolProcPtr = &FindSymbol; + newHandle->unloadFileProcPtr = *unloadProcPtr = &UnloadFile; + *loadHandle = newHandle; return TCL_OK; } /* *---------------------------------------------------------------------- * - * TclpFindSymbol -- + * Tcl_FindSymbol -- * * Looks up a symbol, by name, through a handle associated with a * previously loaded piece of code (shared library). @@ -118,15 +130,15 @@ TclpDlopen( *---------------------------------------------------------------------- */ -Tcl_PackageInitProc * -TclpFindSymbol( +static void* +FindSymbol( Tcl_Interp *interp, Tcl_LoadHandle loadHandle, const char *symbol) { Tcl_DString newName; Tcl_PackageInitProc *proc = NULL; - shl_t handle = (shl_t)loadHandle; + shl_t handle = (shl_t)(loadHandle->clientData); /* * Some versions of the HP system software still use "_" at the beginning @@ -144,13 +156,18 @@ TclpFindSymbol( } Tcl_DStringFree(&newName); } + if (proc == NULL && interp != NULL) { + Tcl_ResetResult(interp); + Tcl_AppendResult(interp, "cannot find symbol\"", symbol, + "\": ", Tcl_PosixError(interp), NULL); + } return proc; } /* *---------------------------------------------------------------------- * - * TclpUnloadFile -- + * UnloadFile -- * * Unloads a dynamically loaded binary code file from memory. Code * pointers in the formerly loaded file are no longer valid after calling @@ -165,16 +182,17 @@ TclpFindSymbol( *---------------------------------------------------------------------- */ -void -TclpUnloadFile( +static void +UnloadFile( Tcl_LoadHandle loadHandle) /* loadHandle returned by a previous call to * TclpDlopen(). The loadHandle is a token * that represents the loaded file. */ { shl_t handle; - handle = (shl_t) loadHandle; + handle = (shl_t) (loadHandle -> clientData); shl_unload(handle); + ckfree((char*) loadHandle); } /* |