Build and run using libltdl from libtool 2.2. The user module loader support has changed drastically.

git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@2113 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Diego Petteno 2008-03-08 23:30:08 +00:00
parent 46d804da4c
commit 9ad7bb6188
2 changed files with 43 additions and 0 deletions

View file

@ -172,6 +172,12 @@ AC_SUBST(LTDLINCL)
AC_SUBST(LIBLTDL) AC_SUBST(LIBLTDL)
AC_CONFIG_SUBDIRS(libltdl) AC_CONFIG_SUBDIRS(libltdl)
old_LIBS=$LIBS
LIBS="$LIBS $LIBLTDL"
AC_CHECK_FUNCS([lt_dlmutex_register])
LIBS=$old_LIBS
AC_CHECK_TYPES([lt_user_dlloader, lt_dladvise], , , [#include <ltdl.h>])
if test "x$enable_ltdl_install" = "xno" && test "x$ac_cv_lib_ltdl_lt_dlinit" = "xno" ; then if test "x$enable_ltdl_install" = "xno" && test "x$ac_cv_lib_ltdl_lt_dlinit" = "xno" ; then
AC_MSG_ERROR([[ AC_MSG_ERROR([[

View file

@ -34,6 +34,11 @@
#include <sys/dl.h> #include <sys/dl.h>
#endif #endif
#ifndef HAVE_LT_USER_DLLOADER
/* Only used with ltdl 2.2 */
#include <string.h>
#endif
#include <ltdl.h> #include <ltdl.h>
#include <pulsecore/macro.h> #include <pulsecore/macro.h>
@ -85,7 +90,11 @@ static const char *libtool_get_error(void) {
to set $LT_BIND_NOW before starting the pulsaudio binary. to set $LT_BIND_NOW before starting the pulsaudio binary.
*/ */
#ifndef HAVE_LT_DLADVISE
static lt_module bind_now_open(lt_user_data d, const char *fname) { static lt_module bind_now_open(lt_user_data d, const char *fname) {
#else
static lt_module bind_now_open(lt_user_data d, const char *fname, lt_dladvise advise) {
#endif
lt_module m; lt_module m;
pa_assert(fname); pa_assert(fname);
@ -129,19 +138,27 @@ static lt_ptr bind_now_find_sym(lt_user_data d, lt_module m, const char *symbol)
void pa_ltdl_init(void) { void pa_ltdl_init(void) {
#ifdef PA_BIND_NOW #ifdef PA_BIND_NOW
# ifdef HAVE_LT_USER_DLLOADER
lt_dlloader *place; lt_dlloader *place;
static const struct lt_user_dlloader loader = { static const struct lt_user_dlloader loader = {
.module_open = bind_now_open, .module_open = bind_now_open,
.module_close = bind_now_close, .module_close = bind_now_close,
.find_sym = bind_now_find_sym .find_sym = bind_now_find_sym
}; };
# else
static const lt_dlvtable *dlopen_loader;
static lt_dlvtable bindnow_loader;
# endif
#endif #endif
pa_assert_se(lt_dlinit() == 0); pa_assert_se(lt_dlinit() == 0);
pa_assert_se(libtool_mutex = pa_mutex_new(TRUE, FALSE)); pa_assert_se(libtool_mutex = pa_mutex_new(TRUE, FALSE));
#ifdef HAVE_LT_DLMUTEX_REGISTER
pa_assert_se(lt_dlmutex_register(libtool_lock, libtool_unlock, libtool_set_error, libtool_get_error) == 0); pa_assert_se(lt_dlmutex_register(libtool_lock, libtool_unlock, libtool_set_error, libtool_get_error) == 0);
#endif
#ifdef PA_BIND_NOW #ifdef PA_BIND_NOW
# ifdef HAVE_LT_USER_DLLOADER
if (!(place = lt_dlloader_find("dlopen"))) if (!(place = lt_dlloader_find("dlopen")))
place = lt_dlloader_next(NULL); place = lt_dlloader_next(NULL);
@ -149,6 +166,26 @@ void pa_ltdl_init(void) {
/* Add our BIND_NOW loader as the default module loader. */ /* Add our BIND_NOW loader as the default module loader. */
if (lt_dlloader_add(place, &loader, "bind-now-loader") != 0) if (lt_dlloader_add(place, &loader, "bind-now-loader") != 0)
pa_log_warn("Failed to add bind-now-loader."); pa_log_warn("Failed to add bind-now-loader.");
# else
/* Already initialised */
if ( dlopen_loader != NULL ) return;
if (!(dlopen_loader = lt_dlloader_find("dlopen"))) {
pa_log_warn("Failed to find original dlopen loader.");
return;
}
memcpy(&bindnow_loader, dlopen_loader, sizeof(bindnow_loader));
bindnow_loader.name = "bind-now-loader";
bindnow_loader.module_open = bind_now_open;
bindnow_loader.module_close = bind_now_close;
bindnow_loader.find_sym = bind_now_find_sym;
bindnow_loader.priority = LT_DLLOADER_PREPEND;
/* Add our BIND_NOW loader as the default module loader. */
if (lt_dlloader_add(&bindnow_loader) != 0)
pa_log_warn("Failed to add bind-now-loader.");
# endif
#endif #endif
} }