]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* libltdl/ltdl.h (lt_dlinfo): Move private module field to here...
authorGary V. Vaughan <gary@gnu.org>
Thu, 8 Jul 2004 09:35:51 +0000 (09:35 +0000)
committerGary V. Vaughan <gary@gnu.org>
Thu, 8 Jul 2004 09:35:51 +0000 (09:35 +0000)
* libltdl/ltdl.c (lt_dlhandle_struct): ...from here.  Changed all
callers.
* libltdl/loader-loadlibrary.c (sys_wll_open): Use new inteface to
scan loaded handle->info.module fields for previously loaded
modules.
* doc/libtool.texi (User defined module data): Document changes to
the interface.
* NEWS: Updated.
Reported by Chuck Wilson <cwilson@ece.gatech.edu>

ChangeLog
NEWS
doc/libtool.texi
libltdl/loader-loadlibrary.c
libltdl/ltdl.c
libltdl/ltdl.h

index 10fb8d91d258df2332f49b19a0779d3766d70e5d..b96dd09ac05a748ae342e08ab5167e1f19a6f43a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2004-07-08  Gary V. Vaughan  <gary@gnu.org>
+
+       * libltdl/ltdl.h (lt_dlinfo): Move private module field to here...
+       * libltdl/ltdl.c (lt_dlhandle_struct): ...from here.  Changed all
+       callers.
+       * libltdl/loader-loadlibrary.c (sys_wll_open): Use new inteface to
+       scan loaded handle->info.module fields for previously loaded
+       modules.
+       * doc/libtool.texi (User defined module data): Document changes to
+       the interface.
+       * NEWS: Updated.
+       Reported by Chuck Wilson <cwilson@ece.gatech.edu>
+
 2004-07-07  Brad <brad@comstyle.com>
 
        * m4/libtool.m4: Fixes for the OpenBSD support
diff --git a/NEWS b/NEWS
index bf4ab10c92bb8f0045ee273b561fe5f6f7d70758..d18a33958d2d79e759764f3f6111df3420a86150 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -46,6 +46,7 @@ New in 1.5b: 2004-??-??; CVS version 1.5a, Libtool team:
   The symbols are deprecated but exported for backwards compatibility.
 * libltdl no longer uses lt_dlmalloc, lt_dlrealloc and lt_dlfree.  The symbols
   are still exported for backwards compatibility.
+* The lt_dlinfo struct has a new module field that can be used by dlloaders.
 * libltdl no longer supports pre-c89 compilers.  Some of the pre89 portability
   functions had compile time bugs in them anyway, so you guys can't have been
   using it :-)
index b3c4cd4180d7fe3d047fae9d8aa7d25b4a4285c2..9afdd3aa6117bef075a1f53d01935718787b405b 100644 (file)
@@ -3329,14 +3329,17 @@ Some of the internal information about each loaded module that is
 maintained by libltdl is available to the user, in the form of this
 structure:
 
-@deftypefn {Type} {struct} lt_dlinfo @{ @w{char *@var{filename};} @w{char *@var{name};} @w{int @var{ref_count};} @}
+@deftypefn {Type} {struct} lt_dlinfo @{ @w{char *@var{filename};} @w{char *@var{name};} @w{int @var{ref_count};} @w{lt_module @var{module};}@}
 @code{lt_dlinfo} is used to store information about a module.
 The @var{filename} attribute is a null-terminated character string of
 the real module file name.  If the module is a libtool module then
 @var{name} is its module name (e.g. @code{"libfoo"} for
 @code{"dir/libfoo.la"}), otherwise it is set to @code{NULL}.  The
 @var{ref_count} attribute is a reference counter that describes how
-often the same module is currently loaded.
+often the same module is currently loaded. @var{module} is the
+dlloader's internal handle for the native module, and can be used, for
+example, by a loader to check whether @var{module} has already been
+loaded to save loading it again.
 @end deftypefn
 
 The following function will return a pointer to libltdl's internal copy
index 8e56e40d32ef99f4afad74e92842649ab0c9c638..535ebc1a7e928918cb27d4ba701101dbf0e0b583 100644 (file)
@@ -38,7 +38,7 @@ static lt_dlhandle handles;
 static lt_module
 sys_wll_open (lt_user_data loader_data, const char *filename)
 {
-  lt_dlhandle  cur;
+  lt_dlhandle  cur        = 0;
   lt_module    module     = 0;
   const char   *errormsg   = 0;
   char        *searchname = 0;
@@ -92,21 +92,19 @@ sys_wll_open (lt_user_data loader_data, const char *filename)
      We check whether LoadLibrary is returning a handle to
      an already loaded module, and simulate failure if we
      find one. */
-  cur = handles;
-  while (cur)
+  while (cur = lt_dlhandle_next (cur))
     {
-      if (!cur->module)
+      const lt_dlinfo *info = lt_dlgetinfo (cur);
+      if (!info->module)
        {
          cur = 0;
          break;
        }
 
-      if (cur->module == module)
+      if (info->module == module)
        {
          break;
        }
-
-      cur = cur->next;
   }
 
   if (cur || !module)
index 3ab2719d0d2db2f2d19c14d6f5e65c81e97171a1..81c801bdb1fe0515da9e8704394694be698b0c12 100644 (file)
@@ -91,7 +91,6 @@ struct lt_dlhandle_struct {
   lt_dlinfo            info;
   int                  depcount;       /* number of dependencies */
   lt_dlhandle         *deplibs;        /* dependencies */
-  lt_module            module;         /* system module handle */
   void *               system;         /* system specific data */
   lt_caller_data       *caller_data;   /* per caller associated data */
   int                  flags;          /* various boolean stats */
@@ -404,9 +403,9 @@ tryall_dlopen (lt_dlhandle *handle, const char *filename)
     {
       lt_user_data data = loader->dlloader_data;
 
-      cur->module = loader->module_open (data, filename);
+      cur->info.module = loader->module_open (data, filename);
 
-      if (cur->module != 0)
+      if (cur->info.module != 0)
        {
          break;
        }
@@ -1712,7 +1711,7 @@ lt_dlclose (lt_dlhandle handle)
          handles = handle->next;
        }
 
-      errors += handle->loader->module_close (data, handle->module);
+      errors += handle->loader->module_close (data, handle->info.module);
       errors += unload_deplibs(handle);
 
       /* It is up to the callers to free the data itself.  */
@@ -1795,7 +1794,7 @@ lt_dlsym (lt_dlhandle handle, const char *symbol)
       strcat(sym, symbol);
 
       /* try "modulename_LTX_symbol" */
-      address = handle->loader->find_sym (data, handle->module, sym);
+      address = handle->loader->find_sym (data, handle->info.module, sym);
       if (address)
        {
          if (sym != lsym)
@@ -1818,7 +1817,7 @@ lt_dlsym (lt_dlhandle handle, const char *symbol)
       strcpy(sym, symbol);
     }
 
-  address = handle->loader->find_sym (data, handle->module, sym);
+  address = handle->loader->find_sym (data, handle->info.module, sym);
   if (sym != lsym)
     {
       FREE (sym);
index fcf076b520ba07c746624cdcde15cc0407f67c11..bf907f4dbc6209e5bbe37bc2b0634e8dd9848803 100644 (file)
@@ -1,5 +1,5 @@
 /* ltdl.h -- generic dlopen functions
-   Copyright (C) 1998-2000 Free Software Foundation, Inc.
+   Copyright (C) 1998-2000, 2004 Free Software Foundation, Inc.
    Originally by Thomas Tanner <tanner@ffii.org>
 
    NOTE: The canonical source of this file is maintained with the
@@ -32,6 +32,7 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 
 #include <libltdl/lt_system.h>
 #include <libltdl/lt_error.h>
+#include <libltdl/lt_dlloader.h>
 
 LT_BEGIN_C_DECLS
 
@@ -101,10 +102,11 @@ LT_SCOPE int      lt_dlpreload_default (const lt_dlsymlist *preloaded);
 
 /* Read only information pertaining to a loaded module. */
 typedef        struct {
-  char *filename;              /* file name */
-  char *name;                  /* module name */
-  int  ref_count;              /* number of times lt_dlopened minus
+  char *       filename;       /* file name */
+  char *       name;           /* module name */
+  int          ref_count;      /* number of times lt_dlopened minus
                                   number of times lt_dlclosed. */
+  lt_module    module;         /* system module handle */
 } lt_dlinfo;
 
 LT_SCOPE const lt_dlinfo *lt_dlgetinfo     (lt_dlhandle handle);