]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
Collapse two almost identical structures into one:
authorGary V. Vaughan <gary@gnu.org>
Thu, 15 Jul 2004 12:26:28 +0000 (12:26 +0000)
committerGary V. Vaughan <gary@gnu.org>
Thu, 15 Jul 2004 12:26:28 +0000 (12:26 +0000)
* libltdl/lt_dlloader.h (lt_dlloader): Add next field.
* libltdl/ltdl.c (lt_user_dlloader): Remove entirely.  Change all
callers to use lt_dlloader instead.  Add a compatibility macro.
(lt_dlloader_add): Remove copy and allocate stage, just hook
directly into the loaders list.

ChangeLog
libltdl/loaders/dld_link.c
libltdl/loaders/dlopen.c
libltdl/loaders/dyld.c
libltdl/loaders/load_add_on.c
libltdl/loaders/loadlibrary.c
libltdl/loaders/preopen.c
libltdl/loaders/shl_load.c
libltdl/lt_dlloader.h
libltdl/ltdl.c

index dbe9587387c223e1c127dd8cd44a6e8f309f9410..a286dad7ce1f8e195e5ab64a4d15ffa8e67d9f83 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2004-07-15  Gary V. Vaughan  <gary@gnu.org>
+
+       Collapse two almost identical structures into one:
+
+       * libltdl/lt_dlloader.h (lt_dlloader): Add next field.
+       * libltdl/ltdl.c (lt_user_dlloader): Remove entirely.  Change all
+       callers to use lt_dlloader instead.  Add a compatibility macro.
+       (lt_dlloader_add): Remove copy and allocate stage, just hook
+       directly into the loaders list.
+
 2004-07-15  Gary V. Vaughan  <gary@gnu.org>
 
        A cleaner way to access the private fields of an lt_dlhandle
index 1b8b9c42fef4824f8592b1ddf28f4dc45d654bd4..51a4d59a817c178b6c636abf314eb983b84148c2 100644 (file)
@@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    be fetched from the preloaded symbol list by lt_dlsym():  */
 #define get_vtable     dld_link_LTX_get_vtable
 
-extern lt_user_dlloader *get_vtable (lt_user_data loader_data);
+extern lt_dlloader *get_vtable (lt_user_data loader_data);
 
 
 /* Boilerplate code to set up the vtable for hooking this loader into
@@ -49,10 +49,10 @@ static void *        vm_sym   (lt_user_data loader_data, lt_module module,
 /* Return the vtable for this loader, only the name and sym_prefix
    attributes (plus the virtual function implementations, obviously)
    change between loaders.  */
-lt_user_dlloader *
+lt_dlloader *
 get_vtable (lt_user_data loader_data)
 {
-  static lt_user_dlloader *vtable = 0;
+  static lt_dlloader *vtable = 0;
 
   if (!vtable)
     {
index af24578cdbe82ba3212e15382f5f44500048fbd8..cfb9a92771cccf8b3e88835abe28e870514d0bd9 100644 (file)
@@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    be fetched from the preloaded symbol list by lt_dlsym():  */
 #define get_vtable     dlopen_LTX_get_vtable
 
-extern lt_user_dlloader *get_vtable (lt_user_data loader_data);
+extern lt_dlloader *get_vtable (lt_user_data loader_data);
 
 
 /* Boilerplate code to set up the vtable for hooking this loader into
@@ -49,10 +49,10 @@ static void *        vm_sym   (lt_user_data loader_data, lt_module module,
 /* Return the vtable for this loader, only the name and sym_prefix
    attributes (plus the virtual function implementations, obviously)
    change between loaders.  */
-lt_user_dlloader *
+lt_dlloader *
 get_vtable (lt_user_data loader_data)
 {
-  static lt_user_dlloader *vtable = 0;
+  static lt_dlloader *vtable = 0;
 
   if (!vtable)
     {
index bd112d427fc3fc03419569d329e8f05411a8e580..0d994b07fe943f4ba8670c9062830e48c09bf3fc 100644 (file)
@@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    be fetched from the preloaded symbol list by lt_dlsym():  */
 #define get_vtable     dyld_LTX_get_vtable
 
-extern lt_user_dlloader *get_vtable (lt_user_data loader_data);
+extern lt_dlloader *get_vtable (lt_user_data loader_data);
 
 
 /* Boilerplate code to set up the vtable for hooking this loader into
@@ -51,10 +51,10 @@ static void *        vm_sym   (lt_user_data loader_data, lt_module module,
 /* Return the vtable for this loader, only the name and sym_prefix
    attributes (plus the virtual function implementations, obviously)
    change between loaders.  */
-lt_user_dlloader *
+lt_dlloader *
 get_vtable (lt_user_data loader_data)
 {
-  static lt_user_dlloader *vtable = 0;
+  static lt_dlloader *vtable = 0;
 
   if (!vtable)
     {
index 7ae6bda21a0e90e0205558068fbfab203daf6ba2..d29bd8261de8bb3ddf01443faa2ded58e5e03015 100644 (file)
@@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    be fetched from the preloaded symbol list by lt_dlsym():  */
 #define get_vtable     load_add_on_LTX_get_vtable
 
-extern lt_user_dlloader *get_vtable (lt_user_data loader_data);
+extern lt_dlloader *get_vtable (lt_user_data loader_data);
 
 
 /* Boilerplate code to set up the vtable for hooking this loader into
@@ -49,10 +49,10 @@ static void *        vm_sym   (lt_user_data loader_data, lt_module module,
 /* Return the vtable for this loader, only the name and sym_prefix
    attributes (plus the virtual function implementations, obviously)
    change between loaders.  */
-lt_user_dlloader *
+lt_dlloader *
 get_vtable (lt_user_data loader_data)
 {
-  static lt_user_dlloader *vtable = 0;
+  static lt_dlloader *vtable = 0;
 
   if (!vtable)
     {
index 210217a2715c1bf59a359d1009456ee50dc1c800..df123d6cb5b4dc16596a247a3e5dfa8819a6eeb5 100644 (file)
@@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    be fetched from the preloaded symbol list by lt_dlsym():  */
 #define get_vtable     loadlibrary_LTX_get_vtable
 
-extern lt_user_dlloader *get_vtable (lt_user_data loader_data);
+extern lt_dlloader *get_vtable (lt_user_data loader_data);
 
 
 /* Boilerplate code to set up the vtable for hooking this loader into
@@ -49,10 +49,10 @@ static void *        vm_sym   (lt_user_data loader_data, lt_module module,
 /* Return the vtable for this loader, only the name and sym_prefix
    attributes (plus the virtual function implementations, obviously)
    change between loaders.  */
-lt_user_dlloader *
+lt_dlloader *
 get_vtable (lt_user_data loader_data)
 {
-  static lt_user_dlloader *vtable = 0;
+  static lt_dlloader *vtable = 0;
 
   if (!vtable)
     {
index d9483804cc39b1747e5dde10c9ce58b532a298dd..171bcc2732eea9fae9fe0651a4a47ee644d72c1e 100644 (file)
@@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    be fetched from the preloaded symbol list by lt_dlsym():  */
 #define get_vtable     preopen_LTX_get_vtable
 
-extern lt_user_dlloader *get_vtable (lt_user_data loader_data);
+extern lt_dlloader *get_vtable (lt_user_data loader_data);
 
 
 /* Boilerplate code to set up the vtable for hooking this loader into
@@ -51,10 +51,10 @@ static void *        vm_sym   (lt_user_data loader_data, lt_module module,
 /* Return the vtable for this loader, only the name and sym_prefix
    attributes (plus the virtual function implementations, obviously)
    change between loaders.  */
-lt_user_dlloader *
+lt_dlloader *
 get_vtable (lt_user_data loader_data)
 {
-  static lt_user_dlloader *vtable = 0;
+  static lt_dlloader *vtable = 0;
 
   if (!vtable)
     {
index 6cd520140c8c9cd9c35dee9666ec2633349edb0e..20635aa1b7930020de36beb4d091a9aa08ae2961 100644 (file)
@@ -36,7 +36,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    be fetched from the preloaded symbol list by lt_dlsym():  */
 #define get_vtable     shl_load_LTX_get_vtable
 
-extern lt_user_dlloader *get_vtable (lt_user_data loader_data);
+extern lt_dlloader *get_vtable (lt_user_data loader_data);
 
 
 /* Boilerplate code to set up the vtable for hooking this loader into
@@ -49,10 +49,10 @@ static void *        vm_sym   (lt_user_data loader_data, lt_module module,
 /* Return the vtable for this loader, only the name and sym_prefix
    attributes (plus the virtual function implementations, obviously)
    change between loaders.  */
-lt_user_dlloader *
+lt_dlloader *
 get_vtable (lt_user_data loader_data)
 {
-  static lt_user_dlloader *vtable = 0;
+  static lt_dlloader *vtable = 0;
 
   if (!vtable)
     {
index b97ad159e36f65957ec7848e02b91e92d976da15..7fd1f904fcc2b42a9e31625e5ff9bcc4b57bb5c9 100644 (file)
@@ -35,15 +35,14 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 
 LT_BEGIN_C_DECLS
 
-typedef struct lt_user_dlloader lt_user_dlloader;
 typedef        struct lt_dlloader      lt_dlloader;
 typedef void *                 lt_user_data;
 typedef void *                 lt_module;
 
 /* Type of a function to get a loader's vtable:  */
-typedef lt_user_dlloader *lt_get_vtable (lt_user_data loader_data);
+typedef lt_dlloader *lt_get_vtable     (lt_user_data loader_data);
 
-/* Function pointer types for creating user defined module loaders:  */
+/* Function pointer types for module loader vtable entries:  */
 typedef int        lt_dlloader_init    (lt_user_data loader_data);
 typedef int        lt_dlloader_exit    (lt_user_data loader_data);
 typedef lt_module   lt_module_open     (lt_user_data loader_data,
@@ -58,7 +57,10 @@ typedef enum {
   LT_DLLOADER_PREPEND = 0, LT_DLLOADER_APPEND
 } lt_dlloader_priority;
 
-struct lt_user_dlloader {
+/* This structure defines a module loader, as populated by the get_vtable
+   entry point of each loader.  */
+struct lt_dlloader {
+  lt_dlloader *                next;
   const char *         name;
   const char *         sym_prefix;
   lt_module_open *     module_open;
@@ -70,14 +72,19 @@ struct lt_user_dlloader {
   lt_dlloader_priority priority;
 };
 
-LT_SCOPE lt_dlloader    *lt_dlloader_next    (lt_dlloader *place);
-LT_SCOPE lt_dlloader    *lt_dlloader_find    (const char *loader_name);
-LT_SCOPE const char     *lt_dlloader_name    (lt_dlloader *place);
-LT_SCOPE lt_user_data   *lt_dlloader_data    (lt_dlloader *place);
-LT_SCOPE int           lt_dlloader_add
-                               (const struct lt_user_dlloader *dlloader,
-                                lt_user_data data);
-LT_SCOPE int           lt_dlloader_remove  (const char *loader_name);
+LT_SCOPE lt_dlloader * lt_dlloader_next   (lt_dlloader *place);
+LT_SCOPE lt_dlloader * lt_dlloader_find   (const char *name);
+LT_SCOPE const char *  lt_dlloader_name   (lt_dlloader *place);
+LT_SCOPE lt_user_data *        lt_dlloader_data   (lt_dlloader *place);
+LT_SCOPE int           lt_dlloader_add    (lt_dlloader *dlloader,
+                                           lt_user_data data);
+LT_SCOPE int           lt_dlloader_remove  (const char *name);
+
+
+
+/* --- Backwards source compatibility ---  */
+
+#define lt_user_dlloader lt_dlloader
 
 
 LT_END_C_DECLS
index a78c4fd844d252df02e5fef19eb04bd83fec4ba1..c519227f363a3d9f9a62cc40a85ba14646658a6d 100644 (file)
@@ -57,23 +57,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
 #define LT_SYMBOL_OVERHEAD     5
 
 
-
-\f
-/* --- OPAQUE STRUCTURES DECLARED IN LTDL.H --- */
-
-
-/* This structure is used for the list of registered loaders. */
-struct lt_dlloader {
-  struct lt_dlloader   *next;
-  const char          *loader_name;    /* identifying name for each loader */
-  const char          *sym_prefix;     /* prefix for symbols */
-  lt_module_open       *module_open;
-  lt_module_close      *module_close;
-  lt_find_sym         *find_sym;
-  lt_dlloader_exit     *dlloader_exit;
-  lt_user_data         dlloader_data;
-};
-
 /* Various boolean flags can be stored in the flags field of an
    lt_dlhandle_struct... */
 #define LT_DLGET_FLAG(handle, flag) (((handle)->flags & (flag)) == (flag))
@@ -177,7 +160,7 @@ loader_init_callback (lt_dlhandle handle)
 static int
 loader_init (lt_get_vtable *vtable_func, lt_user_data data)
 {
-  lt_user_dlloader *vtable = 0;
+  lt_dlloader *vtable = 0;
   int errors = 0;
 
   if (vtable_func)
@@ -216,7 +199,7 @@ loader_init (lt_get_vtable *vtable_func, lt_user_data data)
 #define get_vtable             preopen_LTX_get_vtable
 #define preloaded_symbols      LT_CONC3(lt_, LTDLOPEN, _LTX_preloaded_symbols)
 
-extern lt_user_dlloader *      get_vtable (lt_user_data data);
+extern lt_dlloader *   get_vtable (lt_user_data data);
 extern lt_dlsymlist            preloaded_symbols;
 
 /* Initialize libltdl. */
@@ -2138,11 +2121,10 @@ lt_dlcaller_get_data  (lt_dlcaller_id key, lt_dlhandle handle)
 
 
 int
-lt_dlloader_add (const struct lt_user_dlloader *dlloader,
-                lt_user_data data)
+lt_dlloader_add (lt_dlloader *dlloader, lt_user_data data)
 {
   int errors = 0;
-  lt_dlloader *node = 0, *ptr = 0;
+  lt_dlloader *ptr = 0;
 
   if ((dlloader == 0)  /* diagnose null parameters */
       || (dlloader->module_open == 0)
@@ -2153,35 +2135,19 @@ lt_dlloader_add (const struct lt_user_dlloader *dlloader,
       return 1;
     }
 
-  /* Create a new dlloader node with copies of the user callbacks.  */
-  node = lt__malloc (sizeof *node);
-  if (!node)
-    return 1;
-
-  /* There is no need to record the dlloader->dlloader_init function,
-     since we won't need it again.  */
-  node->next           = 0;
-  node->loader_name    = dlloader->name;
-  node->sym_prefix     = dlloader->sym_prefix;
-  node->module_open    = dlloader->module_open;
-  node->module_close   = dlloader->module_close;
-  node->find_sym       = dlloader->find_sym;
-  node->dlloader_exit  = dlloader->dlloader_exit;
-  node->dlloader_data  = dlloader->dlloader_data;
-
   switch (dlloader->priority)
     {
     case LT_DLLOADER_PREPEND:
       /* Tack NODE on the front of the LOADERS list.  */
-      node->next = loaders;
-      loaders   = node;
+      dlloader->next = loaders;
+      loaders = dlloader;
       break;
 
     case LT_DLLOADER_APPEND:
       /* Add NODE to the end of the LOADERS list.  */
       for (ptr = loaders; ptr->next; ptr = ptr->next)
        /*NOWORK*/;
-      ptr->next = node;
+      ptr->next = dlloader;
       break;
 
     default:
@@ -2194,9 +2160,9 @@ lt_dlloader_add (const struct lt_user_dlloader *dlloader,
 }
 
 int
-lt_dlloader_remove (const char *loader_name)
+lt_dlloader_remove (const char *name)
 {
-  lt_dlloader *place = lt_dlloader_find (loader_name);
+  lt_dlloader *place = lt_dlloader_find (name);
   lt_dlhandle handle;
   int errors = 0;
 
@@ -2227,7 +2193,7 @@ lt_dlloader_remove (const char *loader_name)
       lt_dlloader *prev;
       for (prev = loaders; prev->next; prev = prev->next)
        {
-         if (streq (prev->next->loader_name, loader_name))
+         if (streq (prev->next->name, name))
            {
              break;
            }
@@ -2260,7 +2226,7 @@ lt_dlloader_name (lt_dlloader *place)
 
   if (place)
     {
-      name = place ? place->loader_name : 0;
+      name = place ? place->name : 0;
     }
   else
     {
@@ -2288,13 +2254,13 @@ lt_dlloader_data (lt_dlloader *place)
 }
 
 lt_dlloader *
-lt_dlloader_find (const char *loader_name)
+lt_dlloader_find (const char *name)
 {
   lt_dlloader *place = 0;
 
   for (place = loaders; place; place = place->next)
     {
-      if (streq (place->loader_name, loader_name))
+      if (streq (place->name, name))
        {
          break;
        }