summaryrefslogtreecommitdiffstats
path: root/src/daemon/ltdl-bind-now.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/ltdl-bind-now.c')
-rw-r--r--src/daemon/ltdl-bind-now.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/src/daemon/ltdl-bind-now.c b/src/daemon/ltdl-bind-now.c
index b1770674..92e5d40d 100644
--- a/src/daemon/ltdl-bind-now.c
+++ b/src/daemon/ltdl-bind-now.c
@@ -24,21 +24,20 @@
#include <config.h>
#endif
-#if HAVE_DLFCN_H
+#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
-#if HAVE_SYS_DL_H
+#ifdef HAVE_SYS_DL_H
#include <sys/dl.h>
#endif
-#ifndef HAVE_STRUCT_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>
@@ -54,9 +53,9 @@
#undef PA_BIND_NOW
#endif
-static pa_mutex *libtool_mutex = NULL;
+#ifdef HAVE_LT_DLMUTEX_REGISTER
-PA_STATIC_TLS_DECLARE_NO_FREE(libtool_tls);
+static pa_mutex *libtool_mutex = NULL;
static void libtool_lock(void) {
pa_mutex_lock(libtool_mutex);
@@ -66,6 +65,10 @@ static void libtool_unlock(void) {
pa_mutex_unlock(libtool_mutex);
}
+#endif
+
+PA_STATIC_TLS_DECLARE_NO_FREE(libtool_tls);
+
static void libtool_set_error(const char *error) {
PA_STATIC_TLS_SET(libtool_tls, (char*) error);
}
@@ -89,16 +92,19 @@ static const char *libtool_get_error(void) {
*/
#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) {
+static lt_module bind_now_open(lt_user_data d, const char *fname, lt_dladvise advise)
#endif
+{
lt_module m;
pa_assert(fname);
if (!(m = dlopen(fname, PA_BIND_NOW))) {
+#ifdef HAVE_LT_DLMUTEX_REGISTER
libtool_set_error(dlerror());
+#endif
return NULL;
}
@@ -110,7 +116,9 @@ static int bind_now_close(lt_user_data d, lt_module m) {
pa_assert(m);
if (dlclose(m) != 0){
+#ifdef HAVE_LT_DLMUTEX_REGISTER
libtool_set_error(dlerror());
+#endif
return 1;
}
@@ -124,7 +132,9 @@ static lt_ptr bind_now_find_sym(lt_user_data d, lt_module m, const char *symbol)
pa_assert(symbol);
if (!(ptr = dlsym(m, symbol))) {
+#ifdef HAVE_LT_DLMUTEX_REGISTER
libtool_set_error(dlerror());
+#endif
return NULL;
}
@@ -150,8 +160,9 @@ void pa_ltdl_init(void) {
#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(libtool_mutex = pa_mutex_new(TRUE, FALSE));
pa_assert_se(lt_dlmutex_register(libtool_lock, libtool_unlock, libtool_set_error, libtool_get_error) == 0);
#endif
@@ -163,14 +174,15 @@ void pa_ltdl_init(void) {
/* 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.");
+ 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));
@@ -182,14 +194,16 @@ 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.");
+ pa_log_warn(_("Failed to add bind-now-loader."));
# endif
#endif
}
void pa_ltdl_done(void) {
pa_assert_se(lt_dlexit() == 0);
+
+#ifdef HAVE_LT_DLMUTEX_REGISTER
pa_mutex_free(libtool_mutex);
libtool_mutex = NULL;
+#endif
}
-