From ff8c7d9b16f65e1a64af0d6c919b51e591ad497d Mon Sep 17 00:00:00 2001 From: Martin Kepplinger Date: Fri, 12 May 2017 11:12:39 +0200 Subject: [PATCH] use dlfcn.h dynamic loading function only if libdl is available --- src/ts_close.c | 5 ++++- src/ts_config.c | 8 +++++++- src/ts_load_module.c | 10 ++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/ts_close.c b/src/ts_close.c index 3632f626..2a51b592 100644 --- a/src/ts_close.c +++ b/src/ts_close.c @@ -14,7 +14,9 @@ #ifdef HAVE_UNISTD_H #include #endif +#ifdef HAVE_LIBDL #include +#endif #include "tslib-private.h" @@ -35,9 +37,10 @@ int ts_close(struct tsdev *ts) info->ops->fini(info); else free(info); - + #ifdef HAVE_LIBDL if (handle) dlclose(handle); + #endif info = next; } diff --git a/src/ts_config.c b/src/ts_config.c index 8800bf8b..3cb8ba46 100644 --- a/src/ts_config.c +++ b/src/ts_config.c @@ -13,10 +13,15 @@ #include #include #include + #ifdef HAVE_UNISTD_H #include #endif + +#ifdef HAVE_LIBDL #include +#endif + #include #if !defined(HAVE_STRSEP) @@ -164,9 +169,10 @@ int ts_reconfig(struct tsdev *ts) if (info->ops->fini) info->ops->fini(info); - + #ifdef HAVE_LIBDL if (handle) dlclose(handle); + #endif info = next; } diff --git a/src/ts_load_module.c b/src/ts_load_module.c index 56205bc1..db0053cc 100644 --- a/src/ts_load_module.c +++ b/src/ts_load_module.c @@ -14,10 +14,14 @@ #ifdef HAVE_ALLOCA_H #include #endif + #include #include #include + +#ifdef HAVE_LIBDL #include +#endif #include "tslib-private.h" @@ -138,6 +142,7 @@ static struct tslib_module_info *__ts_load_module_static(struct tsdev *ts, #define PLUGIN_DIR_LEN 1024 +#ifdef HAVE_LIBDL static struct tslib_module_info *__ts_load_module_shared(struct tsdev *ts, const char *module, const char *params) @@ -190,6 +195,7 @@ static struct tslib_module_info *__ts_load_module_shared(struct tsdev *ts, return info; } +#endif /* HAVE_LIBDL */ static int __ts_load_module(struct tsdev *ts, const char *module, const char *params, int raw) @@ -206,8 +212,10 @@ static int __ts_load_module(struct tsdev *ts, const char *module, #endif info = __ts_load_module_static(ts, module, params); +#ifdef HAVE_LIBDL if (!info) info = __ts_load_module_shared(ts, module, params); +#endif if (!info) return -1; @@ -225,8 +233,10 @@ static int __ts_load_module(struct tsdev *ts, const char *module, if (info->ops->fini) info->ops->fini(info); +#ifdef HAVE_LIBDL if (handle) dlclose(handle); +#endif } return ret;