From: Gary V. Vaughan Date: Thu, 15 Jul 2004 12:22:48 +0000 (+0000) Subject: A cleaner way to access the private fields of an lt_dlhandle X-Git-Tag: release-1-9b~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d8529860b52e58846a641b18b652faefda1af42;p=thirdparty%2Flibtool.git A cleaner way to access the private fields of an lt_dlhandle than my move of the module field into lt_dlinfo: * libltdl/ltdl.c (lt_caller_data, lt_dlhandle_struct): Move from here... * libltdl/lt__private.h (lt_caller_data, lt_dlhandle_struct): ...to here. And put the module field back here... * libltdl/ltdl.h (lt_dlinfo): ...instead of here. * libltdl/loaders/loadlibrary.c (vm_open): Adjust. --- diff --git a/ChangeLog b/ChangeLog index 3e5080d9c..dbe958738 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2004-07-15 Gary V. Vaughan + + A cleaner way to access the private fields of an lt_dlhandle + than my move of the module field into lt_dlinfo: + + * libltdl/ltdl.c (lt_caller_data, lt_dlhandle_struct): Move from + here... + * libltdl/lt__private.h (lt_caller_data, lt_dlhandle_struct): + ...to here. And put the module field back here... + * libltdl/ltdl.h (lt_dlinfo): ...instead of here. + * libltdl/loaders/loadlibrary.c (vm_open): Adjust. + 2004-07-15 Gary V. Vaughan * libltdl/lt__private.h (streq, strneq): New macros to make strcmp diff --git a/libltdl/loaders/loadlibrary.c b/libltdl/loaders/loadlibrary.c index 2e30b5f15..210217a27 100644 --- a/libltdl/loaders/loadlibrary.c +++ b/libltdl/loaders/loadlibrary.c @@ -151,14 +151,13 @@ vm_open (lt_user_data loader_data, const char *filename) find one. */ while (cur = lt_dlhandle_next (cur)) { - const lt_dlinfo *info = lt_dlgetinfo (cur); - if (!info->module) + if (!cur->module) { cur = 0; break; } - if (info->module == module) + if (cur->module == module) { break; } diff --git a/libltdl/lt__private.h b/libltdl/lt__private.h index bf258dbaa..e5e7b602f 100644 --- a/libltdl/lt__private.h +++ b/libltdl/lt__private.h @@ -88,6 +88,28 @@ void lt__alloc_die_callback (void); +/* --- OPAQUE STRUCTURES DECLARED IN LTDL.H --- */ + +/* This type is used for the array of caller data sets in each handler. */ +typedef struct { + lt_dlcaller_id key; + void * data; +} lt_caller_data; + +struct lt_dlhandle_struct { + struct lt_dlhandle_struct *next; + lt_dlloader *loader; /* dlopening interface */ + lt_dlinfo info; /* user visible fields */ + 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 */ +}; + + + /* --- ERROR HANDLING --- */ /* Extract the diagnostic strings from the error table macro in the same diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index ff00782cd..a78c4fd84 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -58,18 +58,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - -/* --- TYPE DEFINITIONS -- */ - - -/* This type is used for the array of caller data sets in each handler. */ -typedef struct { - lt_dlcaller_id key; - void * data; -} lt_caller_data; - - - /* --- OPAQUE STRUCTURES DECLARED IN LTDL.H --- */ @@ -86,17 +74,6 @@ struct lt_dlloader { lt_user_data dlloader_data; }; -struct lt_dlhandle_struct { - struct lt_dlhandle_struct *next; - lt_dlloader *loader; /* dlopening interface */ - lt_dlinfo info; - int depcount; /* number of dependencies */ - lt_dlhandle *deplibs; /* dependencies */ - void * system; /* system specific data */ - lt_caller_data *caller_data; /* per caller associated data */ - int flags; /* various boolean stats */ -}; - /* 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)) @@ -414,9 +391,9 @@ tryall_dlopen (lt_dlhandle *handle, const char *filename) { lt_user_data data = loader->dlloader_data; - cur->info.module = loader->module_open (data, filename); + cur->module = loader->module_open (data, filename); - if (cur->info.module != 0) + if (cur->module != 0) { break; } @@ -1724,7 +1701,7 @@ lt_dlclose (lt_dlhandle handle) handles = handle->next; } - errors += handle->loader->module_close (data, handle->info.module); + errors += handle->loader->module_close (data, handle->module); errors += unload_deplibs(handle); /* It is up to the callers to free the data itself. */ @@ -1807,7 +1784,7 @@ lt_dlsym (lt_dlhandle handle, const char *symbol) strcat(sym, symbol); /* try "modulename_LTX_symbol" */ - address = handle->loader->find_sym (data, handle->info.module, sym); + address = handle->loader->find_sym (data, handle->module, sym); if (address) { if (sym != lsym) @@ -1830,7 +1807,7 @@ lt_dlsym (lt_dlhandle handle, const char *symbol) strcpy(sym, symbol); } - address = handle->loader->find_sym (data, handle->info.module, sym); + address = handle->loader->find_sym (data, handle->module, sym); if (sym != lsym) { FREE (sym); diff --git a/libltdl/ltdl.h b/libltdl/ltdl.h index 7c22dd928..b2fb7db6e 100644 --- a/libltdl/ltdl.h +++ b/libltdl/ltdl.h @@ -116,7 +116,6 @@ typedef struct { 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);