summaryrefslogtreecommitdiffstats
path: root/unix/tclLoadDld.c
diff options
context:
space:
mode:
Diffstat (limited to 'unix/tclLoadDld.c')
-rw-r--r--unix/tclLoadDld.c47
1 files changed, 42 insertions, 5 deletions
diff --git a/unix/tclLoadDld.c b/unix/tclLoadDld.c
index 4b3ed36..1f9e702 100644
--- a/unix/tclLoadDld.c
+++ b/unix/tclLoadDld.c
@@ -7,12 +7,12 @@
* dld-3.2.7. This file probably isn't needed anymore, since it
* makes more sense to use "dl_open" etc.
*
- * Copyright (c) 1995 Sun Microsystems, Inc.
+ * Copyright (c) 1995-1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclLoadDld.c,v 1.2 1998/09/14 18:40:16 stanton Exp $
+ * RCS: @(#) $Id: tclLoadDld.c,v 1.3 1999/04/16 00:48:04 stanton Exp $
*/
#include "tclInt.h"
@@ -30,7 +30,7 @@
/*
*----------------------------------------------------------------------
*
- * TclLoadFile --
+ * TclpLoadFile --
*
* Dynamically loads a binary code file into memory and returns
* the addresses of two procedures within that file, if they
@@ -38,7 +38,7 @@
*
* Results:
* A standard Tcl completion code. If an error occurs, an error
- * message is left in interp->result. *proc1Ptr and *proc2Ptr
+ * message is left in the interp's result. *proc1Ptr and *proc2Ptr
* are filled in with the addresses of the symbols given by
* *sym1 and *sym2, or NULL if those symbols can't be found.
*
@@ -49,7 +49,7 @@
*/
int
-TclLoadFile(interp, fileName, sym1, sym2, proc1Ptr, proc2Ptr)
+TclpLoadFile(interp, fileName, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr)
Tcl_Interp *interp; /* Used for error reporting. */
char *fileName; /* Name of the file containing the desired
* code. */
@@ -58,6 +58,9 @@ TclLoadFile(interp, fileName, sym1, sym2, proc1Ptr, proc2Ptr)
Tcl_PackageInitProc **proc1Ptr, **proc2Ptr;
/* Where to return the addresses corresponding
* to sym1 and sym2. */
+ ClientData *clientDataPtr; /* Filled with token for dynamically loaded
+ * file which will be passed back to
+ * TclpUnloadFile() to unload the file. */
{
static int firstTime = 1;
int returnCode;
@@ -91,12 +94,46 @@ TclLoadFile(interp, fileName, sym1, sym2, proc1Ptr, proc2Ptr)
}
*proc1Ptr = (Tcl_PackageInitProc *) dld_get_func(sym1);
*proc2Ptr = (Tcl_PackageInitProc *) dld_get_func(sym2);
+ *clientDataPtr = strcpy(
+ (char *) ckalloc((unsigned) (strlen(fileName) + 1)), fileName);
return TCL_OK;
}
/*
*----------------------------------------------------------------------
*
+ * TclpUnloadFile --
+ *
+ * Unloads a dynamically loaded binary code file from memory.
+ * Code pointers in the formerly loaded file are no longer valid
+ * after calling this function.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Code removed from memory.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TclpUnloadFile(clientData)
+ ClientData clientData; /* ClientData returned by a previous call
+ * to TclpLoadFile(). The clientData is
+ * a token that represents the loaded
+ * file. */
+{
+ char *fileName;
+
+ handle = (char *) clientData;
+ dld_unlink_by_file(handle, 0);
+ ckfree(handle);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TclGuessPackageName --
*
* If the "load" command is invoked without providing a package