libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] add lt_dlopen_preloaded to libltdl API


From: Kevin P. Fleming
Subject: [PATCH] add lt_dlopen_preloaded to libltdl API
Date: Sun, 19 Oct 2003 12:50:54 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5) Gecko/20030925

This patch supplies a new function to the libltdl API, lt_dlopen_preloaded. This function iterates over the preloaded_symbols lists, and for each non-self (@PROGRAM@) module it finds there, it calls lt_dlopen to get a handle structure created for that module. The handles returned from lt_dlopen are _not_ returned to the caller; the intent of this function is that the caller can then use the standard lt_dlforeach function to iterate over all the opened modules.

A count is kept of lt_dlopen failures during this function, although they should not really occur and would be a sign of very bad things happening... the count is returned to the caller, in any case.
? foo
Index: ltdl.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/ltdl.c,v
retrieving revision 1.181
diff -u -b -r1.181 ltdl.c
--- ltdl.c      7 Oct 2003 22:29:05 -0000       1.181
+++ ltdl.c      19 Oct 2003 19:46:18 -0000
@@ -2276,6 +2276,34 @@
 }
 
 int
+lt_dlopen_preloaded ()
+{
+  lt_dlsymlists_t     *list;
+  int                errors = 0;
+  unsigned int        index;
+  const lt_dlsymlist *symbol;
+  lt_dlhandle         handle;
+
+  LT_DLMUTEX_LOCK ();
+
+  list = preloaded_symbols;
+  while (list)
+    {
+      for (index = 0; (symbol = &list->syms[index])->name != 0; index++) {
+       if ((symbol->address == 0) && strcmp(symbol->name, "@PROGRAM@"))
+         {
+           if ((handle = lt_dlopen(symbol->name)) == NULL)
+             errors++;
+         }
+      }
+      list = list->next;
+    }
+
+  LT_DLMUTEX_UNLOCK ();
+  return errors;
+}
+
+int
 lt_dlexit ()
 {
   /* shut down libltdl */
Index: ltdl.h
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/ltdl.h,v
retrieving revision 1.58
diff -u -b -r1.58 ltdl.h
--- ltdl.h      1 Aug 2003 18:31:55 -0000       1.58
+++ ltdl.h      19 Oct 2003 19:46:18 -0000
@@ -227,6 +227,8 @@
 LT_SCOPE       int     lt_dlpreload_default
                                LT_PARAMS((const lt_dlsymlist *preloaded));
 
+LT_SCOPE       int     lt_dlopen_preloaded     LT_PARAMS((void));
+
 #define LTDL_SET_PRELOADED_SYMBOLS()           LT_STMT_START{  \
        extern const lt_dlsymlist lt_preloaded_symbols[];               \
        lt_dlpreload_default(lt_preloaded_symbols);                     \

reply via email to

[Prev in Thread] Current Thread [Next in Thread]