2003-11-11 Gary V. Vaughan <gary@gnu.org>
+ * libltdl/ltdl.c (lt_dlinit): Save a function call for each loader
+ added to the list, in exchange for appending loaders to the list
+ with O(N) rather than O(1). The longest the loader list can ever
+ get is 4 (on cygwin with dld installed) so it probably constitutes
+ a small speedup, in addition to making the code much more readable.
+
* m4/libtool.m4 (AC_LIBTOOL_SETUP): Don't define the value for
ltmain unconditionally.
(_LT_PROG_LTMAIN): New macro to ensure that the
handles = 0;
user_search_path = 0; /* empty search path */
-#if defined(__WINDOWS__) || defined(__CYGWIN__)
- errors += lt_dlloader_add (lt_dlloader_next (0), &sys_wll, "dlopen");
-#endif
-#if HAVE_LIBDL
- errors += lt_dlloader_add (lt_dlloader_next (0), &sys_dl, "dlopen");
+ /* Append the available loaders to the internal list in the order
+ they should be used -- if the first fails, then try again with
+ the next loader in the chain. */
+# define LOADER_APPEND 0
+
+ errors += lt_dlloader_add (LOADER_APPEND, &presym, "dlpreload");
+#if HAVE_DLD
+ errors += lt_dlloader_add (LOADER_APPEND, &sys_dld, "dld");
#endif
-#if HAVE_SHL_LOAD
- errors += lt_dlloader_add (lt_dlloader_next (0), &sys_shl, "dlopen");
+#if HAVE_DYLD
+ errors += lt_dlloader_add (LOADER_APPEND, &sys_dyld, "dyld");
+ errors += sys_dyld_init();
#endif
#ifdef __BEOS__
- errors += lt_dlloader_add (lt_dlloader_next (0), &sys_bedl, "dlopen");
+ errors += lt_dlloader_add (LOADER_APPEND, &sys_bedl, "dlopen");
#endif
-#if HAVE_DLD
- errors += lt_dlloader_add (lt_dlloader_next (0), &sys_dld, "dld");
+#if HAVE_SHL_LOAD
+ errors += lt_dlloader_add (LOADER_APPEND, &sys_shl, "dlopen");
#endif
-#if HAVE_DYLD
- errors += lt_dlloader_add (lt_dlloader_next (0), &sys_dyld, "dyld");
- errors += sys_dyld_init();
+#if HAVE_LIBDL
+ errors += lt_dlloader_add (LOADER_APPEND, &sys_dl, "dlopen");
+#endif
+#if defined(__WINDOWS__) || defined(__CYGWIN__)
+ errors += lt_dlloader_add (LOADER_APPEND, &sys_wll, "dlopen");
#endif
- errors += lt_dlloader_add (lt_dlloader_next (0), &presym, "dlpreload");
if (presym_init (presym.dlloader_data))
{