summaryrefslogtreecommitdiffstats
path: root/unix/tclLoadNext.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tclLoadNext.c')
-rw-r--r--unix/tclLoadNext.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/unix/tclLoadNext.c b/unix/tclLoadNext.c
index 0f82593..35aeba4 100644
--- a/unix/tclLoadNext.c
+++ b/unix/tclLoadNext.c
@@ -9,12 +9,19 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclLoadNext.c,v 1.16 2010/03/11 15:02:33 nijtmans Exp $
+ * RCS: @(#) $Id: tclLoadNext.c,v 1.17 2010/04/02 21:21:06 kennykb Exp $
*/
#include "tclInt.h"
#include <mach-o/rld.h>
#include <streams/streams.h>
+
+/* Static procedures defined within this file */
+
+static void* FindSymbol(Tcl_Interp* interp, Tcl_LoadHandle loadHandle,
+ const char* symbol);
+static void UnloadFile(Tcl_LoadHandle loadHandle);
+
/*
*----------------------------------------------------------------------
@@ -47,6 +54,7 @@ TclpDlopen(
* function which should be used for this
* file. */
{
+ Tcl_LoadHandle newHandle;
struct mach_header *header;
char *fileName;
char *files[2];
@@ -95,8 +103,12 @@ TclpDlopen(
}
NXCloseMemory(errorStream, NX_FREEBUFFER);
- *loadHandle = (Tcl_LoadHandle)1; /* A dummy non-NULL value */
- *unloadProcPtr = &TclpUnloadFile;
+ newHandle = (Tcl_LoadHandle) ckalloc(sizeof(*newHandle));
+ newHandle->clientData = (ClientData) 1;
+ newHandle->findSymbolProcPtr = &FindSymbol;
+ newHandle->unloadFileProcPtr = &UnloadFile;
+ *loadHandle = newHandle;
+ *unloadProcPtr = &UnloadFile;
return TCL_OK;
}
@@ -104,7 +116,7 @@ TclpDlopen(
/*
*----------------------------------------------------------------------
*
- * TclpFindSymbol --
+ * FindSymbol --
*
* Looks up a symbol, by name, through a handle associated with a
* previously loaded piece of code (shared library).
@@ -117,8 +129,8 @@ TclpDlopen(
*----------------------------------------------------------------------
*/
-Tcl_PackageInitProc *
-TclpFindSymbol(
+static void*
+FindSymbol(
Tcl_Interp *interp,
Tcl_LoadHandle loadHandle,
const char *symbol)
@@ -132,13 +144,19 @@ TclpFindSymbol(
strcat(sym, symbol);
rld_lookup(NULL, sym, (unsigned long *)&proc);
}
+ if (proc == NULL && interp != NULL) {
+ Tcl_ResetResult(interp);
+ Tcl_AppendResult(interp, "cannot find symbol \"", symbol,
+ "\"", NULL);
+ Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "LOAD_SYMBOL", symbol, 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
@@ -154,11 +172,12 @@ TclpFindSymbol(
*/
void
-TclpUnloadFile(
+UnloadFile(
Tcl_LoadHandle loadHandle) /* loadHandle returned by a previous call to
* TclpDlopen(). The loadHandle is a token
* that represents the loaded file. */
{
+ ckfree((char*) loadHandle);
}
/*