+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
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 :-)
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
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;
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)
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 */
{
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;
}
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. */
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)
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);
/* 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
#include <libltdl/lt_system.h>
#include <libltdl/lt_error.h>
+#include <libltdl/lt_dlloader.h>
LT_BEGIN_C_DECLS
/* 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);