These files all define get_vtable the same way, so create a single header file to hold it. This would fix desync problems like we had with some defining the return value as const, and it'll make it a bit easier to workaround GNU indent issues related to the defines.
* Makefile.am (pkgltdl_files): Add lt_vtable.h. * libltdl/ltdl.mk (libltdl_libltdl_la_SOURCES): Likewise. * libtoolize.in (all_pkgltdl_files): Likewise. * libltdl/loaders/dld_link.c: Replace get_vtable prototype with lt_vtable.h include. * 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/ltdl.c: Likewise. * libltdl/lt_vtable.h: New file. --- Makefile.am | 1 + libltdl/loaders/dld_link.c | 5 +--- libltdl/loaders/dlopen.c | 5 +--- libltdl/loaders/dyld.c | 5 +--- libltdl/loaders/load_add_on.c | 5 +--- libltdl/loaders/loadlibrary.c | 5 +--- libltdl/loaders/preopen.c | 5 +--- libltdl/loaders/shl_load.c | 5 +--- libltdl/lt_vtable.h | 44 +++++++++++++++++++++++++++++++++++ libltdl/ltdl.c | 4 +--- libltdl/ltdl.mk | 1 + libtoolize.in | 2 +- 12 files changed, 55 insertions(+), 32 deletions(-) create mode 100644 libltdl/lt_vtable.h diff --git a/Makefile.am b/Makefile.am index 904f3d73fc89..34384c5acf26 100644 --- a/Makefile.am +++ b/Makefile.am @@ -479,6 +479,7 @@ pkgltdl_files = COPYING.LIB \ lt__strl.c \ lt_dlloader.c \ lt_error.c \ + lt_vtable.h \ ltdl.c \ ltdl.h \ ltdl.mk \ diff --git a/libltdl/loaders/dld_link.c b/libltdl/loaders/dld_link.c index 9dc220d96c07..7e7541c7338d 100644 --- a/libltdl/loaders/dld_link.c +++ b/libltdl/loaders/dld_link.c @@ -37,10 +37,7 @@ or obtained by writing to the Free Software Foundation, Inc., Use the "<module_name>_LTX_" prefix so that the symbol addresses can be fetched from the preloaded symbol list by lt_dlsym(): */ #define get_vtable dld_link_LTX_get_vtable - -LT_BEGIN_C_DECLS -LT_SCOPE const lt_dlvtable *get_vtable (lt_user_data loader_data); -LT_END_C_DECLS +#include "lt_vtable.h" /* Boilerplate code to set up the vtable for hooking this loader into diff --git a/libltdl/loaders/dlopen.c b/libltdl/loaders/dlopen.c index 5ec46b7f126b..c8c03bf42e25 100644 --- a/libltdl/loaders/dlopen.c +++ b/libltdl/loaders/dlopen.c @@ -37,10 +37,7 @@ or obtained by writing to the Free Software Foundation, Inc., Use the "<module_name>_LTX_" prefix so that the symbol addresses can be fetched from the preloaded symbol list by lt_dlsym(): */ #define get_vtable dlopen_LTX_get_vtable - -LT_BEGIN_C_DECLS -LT_SCOPE const lt_dlvtable *get_vtable (lt_user_data loader_data); -LT_END_C_DECLS +#include "lt_vtable.h" /* Boilerplate code to set up the vtable for hooking this loader into diff --git a/libltdl/loaders/dyld.c b/libltdl/loaders/dyld.c index 2c62c6fb0642..bfd35b24c590 100644 --- a/libltdl/loaders/dyld.c +++ b/libltdl/loaders/dyld.c @@ -37,10 +37,7 @@ or obtained by writing to the Free Software Foundation, Inc., Use the "<module_name>_LTX_" prefix so that the symbol addresses can be fetched from the preloaded symbol list by lt_dlsym(): */ #define get_vtable dyld_LTX_get_vtable - -LT_BEGIN_C_DECLS -LT_SCOPE const lt_dlvtable *get_vtable (lt_user_data loader_data); -LT_END_C_DECLS +#include "lt_vtable.h" /* Boilerplate code to set up the vtable for hooking this loader into diff --git a/libltdl/loaders/load_add_on.c b/libltdl/loaders/load_add_on.c index 513daa4c147a..6b07cd521e22 100644 --- a/libltdl/loaders/load_add_on.c +++ b/libltdl/loaders/load_add_on.c @@ -37,10 +37,7 @@ or obtained by writing to the Free Software Foundation, Inc., Use the "<module_name>_LTX_" prefix so that the symbol addresses can be fetched from the preloaded symbol list by lt_dlsym(): */ #define get_vtable load_add_on_LTX_get_vtable - -LT_BEGIN_C_DECLS -LT_SCOPE const lt_dlvtable *get_vtable (lt_user_data loader_data); -LT_END_C_DECLS +#include "lt_vtable.h" /* Boilerplate code to set up the vtable for hooking this loader into diff --git a/libltdl/loaders/loadlibrary.c b/libltdl/loaders/loadlibrary.c index 10e44490548a..d8995eb5f2bc 100644 --- a/libltdl/loaders/loadlibrary.c +++ b/libltdl/loaders/loadlibrary.c @@ -41,10 +41,7 @@ or obtained by writing to the Free Software Foundation, Inc., Use the "<module_name>_LTX_" prefix so that the symbol addresses can be fetched from the preloaded symbol list by lt_dlsym(): */ #define get_vtable loadlibrary_LTX_get_vtable - -LT_BEGIN_C_DECLS -LT_SCOPE const lt_dlvtable *get_vtable (lt_user_data loader_data); -LT_END_C_DECLS +#include "lt_vtable.h" /* Boilerplate code to set up the vtable for hooking this loader into diff --git a/libltdl/loaders/preopen.c b/libltdl/loaders/preopen.c index e5440d3e07ac..4f61c03b3bda 100644 --- a/libltdl/loaders/preopen.c +++ b/libltdl/loaders/preopen.c @@ -37,10 +37,7 @@ or obtained by writing to the Free Software Foundation, Inc., Use the "<module_name>_LTX_" prefix so that the symbol addresses can be fetched from the preloaded symbol list by lt_dlsym(): */ #define get_vtable preopen_LTX_get_vtable - -LT_BEGIN_C_DECLS -LT_SCOPE const lt_dlvtable *get_vtable (lt_user_data loader_data); -LT_END_C_DECLS +#include "lt_vtable.h" /* Boilerplate code to set up the vtable for hooking this loader into diff --git a/libltdl/loaders/shl_load.c b/libltdl/loaders/shl_load.c index cf2e4df91a7a..d1bf9bea45bf 100644 --- a/libltdl/loaders/shl_load.c +++ b/libltdl/loaders/shl_load.c @@ -37,10 +37,7 @@ or obtained by writing to the Free Software Foundation, Inc., Use the "<module_name>_LTX_" prefix so that the symbol addresses can be fetched from the preloaded symbol list by lt_dlsym(): */ #define get_vtable shl_load_LTX_get_vtable - -LT_BEGIN_C_DECLS -LT_SCOPE const lt_dlvtable *get_vtable (lt_user_data loader_data); -LT_END_C_DECLS +#include "lt_vtable.h" /* Boilerplate code to set up the vtable for hooking this loader into diff --git a/libltdl/lt_vtable.h b/libltdl/lt_vtable.h new file mode 100644 index 000000000000..01b24ff6b7dc --- /dev/null +++ b/libltdl/lt_vtable.h @@ -0,0 +1,44 @@ +/* lt_vtable.h -- Some common vtable boilerplate. + + Copyright (C) 2024 Free Software Foundation, Inc. + + NOTE: The canonical source of this file is maintained with the + GNU Libtool package. Report bugs to bug-libt...@gnu.org. + +GNU Libltdl is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2 of the License, or (at your option) any later version. + +As a special exception to the GNU Lesser General Public License, +if you distribute this file as part of a program or library that +is built using GNU Libtool, you may include this file under the +same distribution terms that you use for the rest of that program. + +GNU Libltdl is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with GNU Libltdl; see the file COPYING.LIB. If not, a +copy can be downloaded from http://www.gnu.org/licenses/lgpl.html, +or obtained by writing to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +*/ + +#if !defined LT_VTABLE_H +#define LT_VTABLE_H 1 + +#include "lt_dlloader.h" +#include "lt_system.h" + +#ifndef get_vtable +# error "get_vtable must be defined first" +#endif + +LT_BEGIN_C_DECLS +LT_SCOPE const lt_dlvtable *get_vtable (lt_user_data loader_data); +LT_END_C_DECLS + +#endif /*!LT_VTABLE_H*/ diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index db4905de1563..fb566f0a82e8 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -211,11 +211,9 @@ loader_init (lt_get_vtable *vtable_func, lt_user_data data) /* Bootstrap the loader loading with the preopening loader. */ #define get_vtable preopen_LTX_get_vtable +#include "lt_vtable.h" #define preloaded_symbols LT_CONC3(lt_, LTDLOPEN, _LTX_preloaded_symbols) -LT_BEGIN_C_DECLS -LT_SCOPE const lt_dlvtable * get_vtable (lt_user_data data); -LT_END_C_DECLS #ifdef HAVE_LIBDLLOADER extern LT_DLSYM_CONST lt_dlsymlist preloaded_symbols[]; #endif diff --git a/libltdl/ltdl.mk b/libltdl/ltdl.mk index bebbfefd201f..707a6ef40989 100644 --- a/libltdl/ltdl.mk +++ b/libltdl/ltdl.mk @@ -68,6 +68,7 @@ libltdl_libltdl_la_SOURCES = libltdl/libltdl/lt__alloc.h \ libltdl/lt__alloc.c \ libltdl/lt_dlloader.c \ libltdl/lt_error.c \ + libltdl/lt_vtable.h \ libltdl/ltdl.c \ libltdl/ltdl.h \ libltdl/slist.c diff --git a/libtoolize.in b/libtoolize.in index ecdf07f8af63..c9d668183e5a 100644 --- a/libtoolize.in +++ b/libtoolize.in @@ -1893,7 +1893,7 @@ func_require_seen_libtool () # Automake. Similarly, do not remove Gnulib files. all_pkgaux_files="compile depcomp missing ltmain.sh" all_pkgmacro_files="libtool.m4 ltargz.m4 ltdl.m4 ltoptions.m4 ltsugar.m4 ltversion.in ltversion.m4 lt~obsolete.m4" - all_pkgltdl_files="COPYING.LIB Makefile Makefile.in Makefile.inc Makefile.am README acinclude.m4 aclocal.m4 argz_.h argz.c config.h.in config-h.in configure configure.ac configure.in libltdl/lt__alloc.h libltdl/lt__argz.h libltdl/lt__dirent.h libltdl/lt__glibc.h libltdl/lt__private.h libltdl/lt__strl.h libltdl/lt_dlloader.h libltdl/lt_error.h libltdl/lt_system.h libltdl/slist.h loaders/dld_link.c loaders/dlopen.c loaders/dyld.c loaders/load_add_on.c loaders/loadlibrary.c loaders/preopen.c loaders/shl_load.c lt__alloc.c lt__argz.c lt__dirent.c lt__strl.c lt_dlloader.c lt_error.c ltdl.c ltdl.h ltdl.mk slist.c" + all_pkgltdl_files="COPYING.LIB Makefile Makefile.in Makefile.inc Makefile.am README acinclude.m4 aclocal.m4 argz_.h argz.c config.h.in config-h.in configure configure.ac configure.in libltdl/lt__alloc.h libltdl/lt__argz.h libltdl/lt__dirent.h libltdl/lt__glibc.h libltdl/lt__private.h libltdl/lt__strl.h libltdl/lt_dlloader.h libltdl/lt_error.h libltdl/lt_system.h libltdl/slist.h loaders/dld_link.c loaders/dlopen.c loaders/dyld.c loaders/load_add_on.c loaders/loadlibrary.c loaders/preopen.c loaders/shl_load.c lt__alloc.c lt__argz.c lt__dirent.c lt__strl.c lt_dlloader.c lt_error.c lt_vtable.h ltdl.c ltdl.h ltdl.mk slist.c" # Files installed by func_install_*, some files are missing from these # lists deliberately because their respective func_install has to handle -- 2.43.0