summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-06-10 14:49:08 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-06-10 14:49:08 (GMT)
commitd1e77398a88c782621e53c1697ab594399d0fa3b (patch)
tree36a8a93d38844f6e9b1a4ab0554b326044355a26
parentf271e62139957e6137efb528670436c4a9393818 (diff)
downloadtcl-d1e77398a88c782621e53c1697ab594399d0fa3b.zip
tcl-d1e77398a88c782621e53c1697ab594399d0fa3b.tar.gz
tcl-d1e77398a88c782621e53c1697ab594399d0fa3b.tar.bz2
Experiment: use dladdr() on Linux to locate the shared library. Won't work on other platforms! WIP
-rw-r--r--generic/tclZipfs.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c
index 35b6712..303ea03 100644
--- a/generic/tclZipfs.c
+++ b/generic/tclZipfs.c
@@ -16,6 +16,7 @@
* projects.
*/
+#define _GNU_SOURCE
#include "tclInt.h"
#include "tclFileSystem.h"
@@ -32,6 +33,10 @@
#define TBLS 1
#endif
+#if 1 /* HAVE_DLADDR */
+#include <dlfcn.h>
+#endif
+
#ifdef HAVE_ZLIB
#include "zlib.h"
#include "crypt.h"
@@ -3907,6 +3912,12 @@ TclZipfs_TclLibrary(void)
if (ZipfsAppHookFindTclInit(dllName) == TCL_OK) {
return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
}
+#elif 1
+ Dl_info dlinfo;
+ if (dladdr(TclZipfs_TclLibrary, &dlinfo) && (dlinfo.dli_fname != NULL)
+ && (ZipfsAppHookFindTclInit(dlinfo.dli_fname) == TCL_OK)) {
+ return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);
+ }
#else
if (ZipfsAppHookFindTclInit(CFG_RUNTIME_LIBDIR "/" CFG_RUNTIME_DLLFILE) == TCL_OK) {
return Tcl_NewStringObj(zipfs_literal_tcl_library, -1);