summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--unix/Makefile.in5
-rwxr-xr-xunix/configure3
-rw-r--r--unix/configure.in5
-rw-r--r--unix/tclLoadDyld.c45
5 files changed, 56 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 8e129a7..8181b6e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2002-07-24 Daniel Steffen <das@users.sourceforge.net>
+
+ * unix/Makefile.in:
+ * unix/configure.in: corrected fix for [Bug 529801]: ranlib
+ only needed for static builds on Mac OS X.
+ * unix/configure: Regen.
+ * unix/tclLoadDyld.c: fixed small bugs introduced by Vince,
+ implemented library unloading correctly (needs OS X 10.2).
+
2002-07-23 Joe English <jenglish@users.sourceforge.net>
* doc/OpenFileChnl.3: (Updates from Larry Virden)
diff --git a/unix/Makefile.in b/unix/Makefile.in
index fbca974..fe2013c 100644
--- a/unix/Makefile.in
+++ b/unix/Makefile.in
@@ -5,7 +5,7 @@
# "autoconf" program (constructs like "@foo@" will get replaced in the
# actual Makefile.
#
-# RCS: @(#) $Id: Makefile.in,v 1.109 2002/07/23 17:30:06 mdejong Exp $
+# RCS: @(#) $Id: Makefile.in,v 1.110 2002/07/24 13:51:18 das Exp $
VERSION = @TCL_VERSION@
@@ -433,8 +433,7 @@ doc:
${TCL_LIB_FILE}: ${OBJS} ${STUB_LIB_FILE}
rm -f ${TCL_LIB_FILE}
@MAKE_LIB@
- @if test "x@DL_OBJS@" = "xtclLoadAout.o" || \
- test "x@DL_OBJS@" = "xtclLoadDyld.o" ; then \
+ @if test "x@DL_OBJS@" = "xtclLoadAout.o" ; then \
echo "$(RANLIB) ${TCL_LIB_FILE}"; \
$(RANLIB) ${TCL_LIB_FILE}; \
fi
diff --git a/unix/configure b/unix/configure
index 84309ba..f3041eb 100755
--- a/unix/configure
+++ b/unix/configure
@@ -6812,6 +6812,9 @@ else
TCL_SHLIB_CFLAGS=""
eval "TCL_LIB_FILE=libtcl${TCL_UNSHARED_LIB_SUFFIX}"
MAKE_LIB="\${STLIB_LD} \$@ \${OBJS}"
+ if test "x$DL_OBJS" = "xtclLoadDyld.o"; then
+ MAKE_LIB="${MAKE_LIB} ; \${RANLIB} \$@"
+ fi
fi
# tclConfig.sh needs a version of the _LIB_SUFFIX that has been eval'ed
diff --git a/unix/configure.in b/unix/configure.in
index 682e5e1..1d90e39 100644
--- a/unix/configure.in
+++ b/unix/configure.in
@@ -3,7 +3,7 @@ dnl This file is an input file used by the GNU "autoconf" program to
dnl generate the file "configure", which is run during Tcl installation
dnl to configure the system for the local environment.
#
-# RCS: @(#) $Id: configure.in,v 1.92 2002/07/19 20:29:47 mdejong Exp $
+# RCS: @(#) $Id: configure.in,v 1.93 2002/07/24 13:51:18 das Exp $
AC_INIT(../generic/tcl.h)
AC_PREREQ(2.13)
@@ -428,6 +428,9 @@ else
TCL_SHLIB_CFLAGS=""
eval "TCL_LIB_FILE=libtcl${TCL_UNSHARED_LIB_SUFFIX}"
MAKE_LIB="\${STLIB_LD} \[$]@ \${OBJS}"
+ if test "x$DL_OBJS" = "xtclLoadDyld.o"; then
+ MAKE_LIB="${MAKE_LIB} ; \${RANLIB} \$@"
+ fi
fi
# tclConfig.sh needs a version of the _LIB_SUFFIX that has been eval'ed
diff --git a/unix/tclLoadDyld.c b/unix/tclLoadDyld.c
index 600bbb3..f203564 100644
--- a/unix/tclLoadDyld.c
+++ b/unix/tclLoadDyld.c
@@ -11,13 +11,23 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclLoadDyld.c,v 1.11 2002/07/18 16:26:04 vincentdarley Exp $
+ * RCS: @(#) $Id: tclLoadDyld.c,v 1.12 2002/07/24 13:51:18 das Exp $
*/
#include "tclInt.h"
#include "tclPort.h"
#include <mach-o/dyld.h>
+typedef struct Tcl_DyldModuleHandle {
+ struct Tcl_DyldModuleHandle *nextModuleHandle;
+ NSModule module;
+} Tcl_DyldModuleHandle;
+
+typedef struct Tcl_DyldLoadHandle {
+ const struct mach_header *dyld_lib;
+ Tcl_DyldModuleHandle *firstModuleHandle;
+} Tcl_DyldLoadHandle;
+
/*
*----------------------------------------------------------------------
*
@@ -49,8 +59,9 @@ TclpDlopen(interp, pathPtr, loadHandle, unloadProcPtr)
* function which should be used for
* this file. */
{
+ Tcl_DyldLoadHandle *dyldLoadHandle;
const struct mach_header *dyld_lib;
- char *native;
+ CONST char *native;
native = Tcl_FSGetNativePath(pathPtr);
dyld_lib = NSAddImage(native,
@@ -64,7 +75,11 @@ TclpDlopen(interp, pathPtr, loadHandle, unloadProcPtr)
Tcl_AppendResult(interp, msg, (char *) NULL);
return TCL_ERROR;
}
- *loadHandle = (Tcl_LoadHandle)dyld_lib;
+ dyldLoadHandle = (Tcl_DyldLoadHandle *) ckalloc(sizeof(Tcl_DyldLoadHandle));
+ if (!dyldLoadHandle) return TCL_ERROR;
+ dyldLoadHandle->dyld_lib = dyld_lib;
+ dyldLoadHandle->firstModuleHandle = NULL;
+ *loadHandle = (Tcl_LoadHandle) dyldLoadHandle;
*unloadProcPtr = &TclpUnloadFile;
return TCL_OK;
}
@@ -94,7 +109,7 @@ TclpFindSymbol(interp, loadHandle, symbol)
CONST char *native;
Tcl_DString newName, ds;
Tcl_PackageInitProc* proc = NULL;
- const struct mach_header *dyld_lib = (mach_header *)loadHandle;
+ Tcl_DyldLoadHandle *dyldLoadHandle = (Tcl_DyldLoadHandle *) loadHandle;
/*
* dyld adds an underscore to the beginning of symbol names.
*/
@@ -103,12 +118,18 @@ TclpFindSymbol(interp, loadHandle, symbol)
Tcl_DStringInit(&newName);
Tcl_DStringAppend(&newName, "_", 1);
native = Tcl_DStringAppend(&newName, native, -1);
- nsSymbol = NSLookupSymbolInImage(dyld_lib, native,
+ nsSymbol = NSLookupSymbolInImage(dyldLoadHandle->dyld_lib, native,
NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW |
NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
if(nsSymbol) {
+ Tcl_DyldModuleHandle *dyldModuleHandle;
proc = NSAddressOfSymbol(nsSymbol);
- /* *clientDataPtr = NSModuleForSymbol(nsSymbol); */
+ dyldModuleHandle = (Tcl_DyldModuleHandle *) ckalloc(sizeof(Tcl_DyldModuleHandle));
+ if (dyldModuleHandle) {
+ dyldModuleHandle->module = NSModuleForSymbol(nsSymbol);
+ dyldModuleHandle->nextModuleHandle = dyldLoadHandle->firstModuleHandle;
+ dyldLoadHandle->firstModuleHandle = dyldModuleHandle;
+ }
}
Tcl_DStringFree(&newName);
Tcl_DStringFree(&ds);
@@ -142,7 +163,17 @@ TclpUnloadFile(loadHandle)
* a token that represents the loaded
* file. */
{
- NSUnLinkModule(loadHandle, FALSE);
+ Tcl_DyldLoadHandle *dyldLoadHandle = (Tcl_DyldLoadHandle *) loadHandle;
+ Tcl_DyldModuleHandle *dyldModuleHandle = dyldLoadHandle->firstModuleHandle;
+ void *ptr;
+
+ while (dyldModuleHandle) {
+ NSUnLinkModule(dyldModuleHandle->module, NSUNLINKMODULE_OPTION_NONE);
+ ptr = dyldModuleHandle;
+ dyldModuleHandle = dyldModuleHandle->nextModuleHandle;
+ ckfree(ptr);
+ }
+ ckfree(dyldLoadHandle);
}
/*