]> code.delx.au - pulseaudio/blobdiff - src/daemon/ltdl-bind-now.c
Update code to use libtool 2.2. Use convenience recursive libltdl.
[pulseaudio] / src / daemon / ltdl-bind-now.c
index d569fea89bedeaaf9a9943ca7a938f7072097b57..6821aac4220a3c5ec7f120647c0920c9c5f786b1 100644 (file)
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
 #include <sys/dl.h>
 #endif
 
-#ifndef HAVE_LT_USER_DLLOADER
-/* Only used with ltdl 2.2 */
 #include <string.h>
-#endif
 
 #include <ltdl.h>
 
+#include <pulse/i18n.h>
+
 #include <pulsecore/macro.h>
 #include <pulsecore/mutex.h>
 #include <pulsecore/thread.h>
 #undef PA_BIND_NOW
 #endif
 
-static pa_mutex *libtool_mutex = NULL;
-
-PA_STATIC_TLS_DECLARE_NO_FREE(libtool_tls);
-
-static void libtool_lock(void) {
-    pa_mutex_lock(libtool_mutex);
-}
-
-static void libtool_unlock(void) {
-    pa_mutex_unlock(libtool_mutex);
-}
-
-static void libtool_set_error(const char *error) {
-    PA_STATIC_TLS_SET(libtool_tls, (char*) error);
-}
-
-static const char *libtool_get_error(void) {
-    return PA_STATIC_TLS_GET(libtool_tls);
-}
-
 #ifdef PA_BIND_NOW
 
 /*
@@ -90,11 +67,8 @@ static const char *libtool_get_error(void) {
   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) {
-#else
-  static lt_module bind_now_open(lt_user_data d, const char *fname, lt_dladvise advise) {
-#endif
+static lt_module bind_now_open(lt_user_data d, const char *fname, lt_dladvise advise)
+{
     lt_module m;
 
     pa_assert(fname);
@@ -138,41 +112,20 @@ static lt_ptr bind_now_find_sym(lt_user_data d, lt_module m, const char *symbol)
 void pa_ltdl_init(void) {
 
 #ifdef PA_BIND_NOW
-# ifdef HAVE_LT_USER_DLLOADER
-    lt_dlloader *place;
-    static const struct lt_user_dlloader loader = {
-        .module_open = bind_now_open,
-        .module_close = bind_now_close,
-        .find_sym = bind_now_find_sym
-    };
-# else
     static const lt_dlvtable *dlopen_loader;
     static lt_dlvtable bindnow_loader;
-# endif
 #endif
 
     pa_assert_se(lt_dlinit() == 0);
-    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);
-#endif
 
 #ifdef PA_BIND_NOW
-# ifdef HAVE_LT_USER_DLLOADER
-
-    if (!(place = lt_dlloader_find("dlopen")))
-        place = lt_dlloader_next(NULL);
-
-    /* Add our BIND_NOW loader as the default module loader. */
-    if (lt_dlloader_add(place, &loader, "bind-now-loader") != 0)
-        pa_log_warn("Failed to add bind-now-loader.");
-# else
     /* Already initialised */
-    if ( dlopen_loader != NULL ) return;
+    if (dlopen_loader)
+        return;
 
     if (!(dlopen_loader = lt_dlloader_find("dlopen"))) {
-      pa_log_warn("Failed to find original dlopen loader.");
-      return;
+        pa_log_warn(_("Failed to find original dlopen loader."));
+        return;
     }
 
     memcpy(&bindnow_loader, dlopen_loader, sizeof(bindnow_loader));
@@ -184,14 +137,10 @@ void pa_ltdl_init(void) {
 
     /* 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
+        pa_log_warn(_("Failed to add bind-now-loader."));
 #endif
 }
 
 void pa_ltdl_done(void) {
     pa_assert_se(lt_dlexit() == 0);
-    pa_mutex_free(libtool_mutex);
-    libtool_mutex = NULL;
 }
-