/* ltdl.c -- system independent dlopen wrapper
Copyright (C) 1998, 1999, 2000, 2004, 2005, 2006,
- 2007 Free Software Foundation, Inc.
+ 2007, 2008 Free Software Foundation, Inc.
Written by Thomas Tanner, 1998
NOTE: The canonical source of this file is maintained with the
/* Various boolean flags can be stored in the flags field of an
lt_dlhandle... */
-#define LT_DLIS_RESIDENT(handle) (((lt__handle*)handle)->info.is_resident)
-#define LT_DLIS_SYMGLOBAL(handle) (((lt__handle*)handle)->info.is_symglobal)
-#define LT_DLIS_SYMLOCAL(handle) (((lt__handle*)handle)->info.is_symlocal)
+#define LT_DLIS_RESIDENT(handle) ((handle)->info.is_resident)
+#define LT_DLIS_SYMGLOBAL(handle) ((handle)->info.is_symglobal)
+#define LT_DLIS_SYMLOCAL(handle) ((handle)->info.is_symlocal)
static const char objdir[] = LT_OBJDIR;
{
/* shut down libltdl */
lt_dlloader *loader = 0;
- lt__handle *handle = (lt__handle *) handles;
+ lt_dlhandle handle = handles;
int errors = 0;
if (!initialized)
while (handles && LT_DLIS_RESIDENT (handles))
{
- handles = ((lt__handle *) handles)->next;
+ handles = handles->next;
}
/* close all modules */
for (level = 1; handle; ++level)
{
- lt__handle *cur = (lt__handle *) handles;
+ lt_dlhandle cur = handles;
int saw_nonresident = 0;
while (cur)
{
- lt__handle *tmp = cur;
+ lt_dlhandle tmp = cur;
cur = cur->next;
if (!LT_DLIS_RESIDENT (tmp))
{
pointed to by 'cur'. */
if (cur)
{
- for (tmp = (lt__handle *) handles; tmp; tmp = tmp->next)
+ for (tmp = handles; tmp; tmp = tmp->next)
if (tmp == cur)
break;
if (! tmp)
- cur = (lt__handle *) handles;
+ cur = handles;
}
}
}
the dlhandle is stored at the address given in PHANDLE. */
static int
tryall_dlopen (lt_dlhandle *phandle, const char *filename,
- lt_dladvise padvise, const lt_dlvtable *vtable)
+ lt_dladvise advise, const lt_dlvtable *vtable)
{
- lt__handle * handle = (lt__handle *) handles;
+ lt_dlhandle handle = handles;
const char * saved_error = 0;
int errors = 0;
- lt__advise * advise = (lt__advise *) padvise;
#ifdef LT_DEBUG_LOADERS
fprintf (stderr, "tryall_dlopen (%s, %s)\n",
goto done;
}
- handle = (lt__handle *) *phandle;
+ handle = *phandle;
if (filename)
{
/* Comment out the check of file permissions using access.
static int
find_handle_callback (char *filename, void *data, void *data2)
{
- lt_dlhandle *handle = (lt_dlhandle *) data;
+ lt_dlhandle *phandle = (lt_dlhandle *) data;
int notfound = access (filename, R_OK);
lt_dladvise advise = (lt_dladvise) data2;
/* Try to dlopen the file, but do not continue searching in any
case. */
- if (tryall_dlopen (handle, filename, advise, 0) != 0)
- *handle = 0;
+ if (tryall_dlopen (phandle, filename, advise, 0) != 0)
+ *phandle = 0;
return 1;
}
found but could not be opened, *HANDLE will be set to 0. */
static lt_dlhandle *
find_handle (const char *search_path, const char *base_name,
- lt_dlhandle *handle, lt_dladvise advise)
+ lt_dlhandle *phandle, lt_dladvise advise)
{
if (!search_path)
return 0;
if (!foreach_dirinpath (search_path, base_name, find_handle_callback,
- handle, advise))
+ phandle, advise))
return 0;
- return handle;
+ return phandle;
}
#if !defined(LTDL_DLOPEN_DEPLIBS)
static int
load_deplibs (lt_dlhandle handle, char * LT__UNUSED deplibs)
{
- ((lt__handle *) handle)->depcount = 0;
+ handle->depcount = 0;
return 0;
}
char **names = 0;
int errors = 0;
- ((lt__handle *) handle)->depcount = 0;
+ handle->depcount = 0;
if (!deplibs)
{
later on if the loaded module cannot resolve all of its symbols. */
if (depcount)
{
- lt__handle *cur = (lt__handle *) handle;
+ lt_dlhandle cur = handle;
int j = 0;
- cur->deplibs = (lt_dlhandle *) MALLOC (lt__handle, depcount);
+ cur->deplibs = (lt_dlhandle) MALLOC (struct lt__handle, depcount);
if (!cur->deplibs)
goto cleanup_names;
{
int i;
int errors = 0;
- lt__handle *cur = (lt__handle *) handle;
+ lt_dlhandle cur = handle;
if (cur->depcount)
{
/* dlopen self? */
if (!filename)
{
- *phandle = (lt_dlhandle) lt__zalloc (sizeof (lt__handle));
+ *phandle = (lt_dlhandle) lt__zalloc (sizeof (struct lt__handle));
if (*phandle == 0)
return 1;
newhandle = *phandle;
/* lt_dlclose()ing yourself is very bad! Disallow it. */
- ((lt__handle *) newhandle)->info.is_resident = 1;
+ newhandle->info.is_resident = 1;
if (tryall_dlopen (&newhandle, 0, advise, 0) != 0)
{
if (vtable)
{
- *phandle = (lt_dlhandle) lt__zalloc (sizeof (lt__handle));
+ *phandle = (lt_dlhandle) lt__zalloc (sizeof (struct lt__handle));
if (*phandle == NULL)
{
fclose (file);
/* allocate the handle */
- *phandle = (lt_dlhandle) lt__zalloc (sizeof (lt__handle));
+ *phandle = (lt_dlhandle) lt__zalloc (sizeof (struct lt__handle));
if (*phandle == 0)
++errors;
else
{
/* not a libtool module */
- *phandle = (lt_dlhandle) lt__zalloc (sizeof (lt__handle));
+ *phandle = (lt_dlhandle) lt__zalloc (sizeof (struct lt__handle));
if (*phandle == 0)
{
++errors;
register_handle:
MEMREASSIGN (*phandle, newhandle);
- if (((lt__handle *) *phandle)->info.ref_count == 0)
+ if ((*phandle)->info.ref_count == 0)
{
- ((lt__handle *) *phandle)->info.ref_count = 1;
- MEMREASSIGN (((lt__handle *) *phandle)->info.name, name);
+ (*phandle)->info.ref_count = 1;
+ MEMREASSIGN ((*phandle)->info.name, name);
- ((lt__handle *) *phandle)->next = (lt__handle *) handles;
- handles = *phandle;
+ (*phandle)->next = handles;
+ handles = *phandle;
}
LT__SETERRORSTR (saved_error);
int
lt_dladvise_init (lt_dladvise *padvise)
{
- lt__advise *advise = (lt__advise *) lt__zalloc (sizeof (lt__advise));
+ lt_dladvise advise = (lt_dladvise) lt__zalloc (sizeof (struct lt__advise));
*padvise = advise;
return (advise ? 0 : 1);
}
lt_dladvise_ext (lt_dladvise *padvise)
{
assert (padvise && *padvise);
- ((lt__advise *) *padvise)->try_ext = 1;
+ (*padvise)->try_ext = 1;
return 0;
}
lt_dladvise_resident (lt_dladvise *padvise)
{
assert (padvise && *padvise);
- ((lt__advise *) *padvise)->is_resident = 1;
+ (*padvise)->is_resident = 1;
return 0;
}
lt_dladvise_local (lt_dladvise *padvise)
{
assert (padvise && *padvise);
- ((lt__advise *) *padvise)->is_symlocal = 1;
+ (*padvise)->is_symlocal = 1;
return 0;
}
lt_dladvise_global (lt_dladvise *padvise)
{
assert (padvise && *padvise);
- ((lt__advise *) *padvise)->is_symglobal = 1;
+ (*padvise)->is_symglobal = 1;
return 0;
}
int errors = 0;
/* Can't have symbols hidden and visible at the same time! */
- if (advise
- && ((lt__advise *) advise)->is_symlocal
- && ((lt__advise *) advise)->is_symglobal)
+ if (advise && advise->is_symlocal && advise->is_symglobal)
{
LT__SETERROR (CONFLICTING_FLAGS);
return 0;
if (!filename
|| !advise
- || !((lt__advise *) advise)->try_ext
+ || !advise->try_ext
|| has_library_ext (filename))
{
/* Just incase we missed a code path in try_dlopen() that reports
int
lt_dlclose (lt_dlhandle handle)
{
- lt__handle *cur, *last;
+ lt_dlhandle cur, last;
int errors = 0;
/* check whether the handle is valid */
- last = cur = (lt__handle *) handles;
+ last = cur = handles;
while (cur && handle != cur)
{
last = cur;
goto done;
}
- cur = (lt__handle *) handle;
+ cur = handle;
cur->info.ref_count--;
/* Note that even with resident modules, we must track the ref_count
char *sym;
void *address;
lt_user_data data;
- lt__handle *handle;
+ lt_dlhandle handle;
if (!place)
{
return 0;
}
- handle = (lt__handle *) place;
+ handle = place;
if (!symbol)
{
}
else
{
- ((lt__handle *) handle)->info.is_resident = 1;
+ handle->info.is_resident = 1;
}
return errors;
{
int n_elements = 0;
void *stale = (void *) 0;
- lt__handle *cur = (lt__handle *) handle;
+ lt_dlhandle cur = handle;
int i;
if (cur->interface_data)
lt_dlcaller_get_data (lt_dlinterface_id key, lt_dlhandle handle)
{
void *result = (void *) 0;
- lt__handle *cur = (lt__handle *) handle;
+ lt_dlhandle cur = handle;
/* Locate the index of the element with a matching KEY. */
if (cur->interface_data)
return 0;
}
- return &(((lt__handle *) handle)->info);
+ return &(handle->info);
}
lt_dlhandle
lt_dlhandle_iterate (lt_dlinterface_id iface, lt_dlhandle place)
{
- lt__handle *handle = (lt__handle *) place;
+ lt_dlhandle handle = place;
lt__interface_id *iterator = (lt__interface_id *) iface;
assert (iface); /* iface is a required argument */
if (!handle)
- handle = (lt__handle *) handles;
+ handle = handles;
else
handle = handle->next;
handle = handle->next;
}
- return (lt_dlhandle) handle;
+ return handle;
}
while ((handle = lt_dlhandle_iterate (iface, handle)))
{
- lt__handle *cur = (lt__handle *) handle;
+ lt_dlhandle cur = handle;
if (cur && cur->info.name && streq (cur->info.name, module_name))
break;
}
int (*func) (lt_dlhandle handle, void *data), void *data)
{
lt__interface_id *iterator = (lt__interface_id *) iface;
- lt__handle *cur = (lt__handle *) handles;
+ lt_dlhandle cur = handles;
assert (iface); /* iface is a required argument */