common: Move dynamic libary loading definitions into common header.

This commit is contained in:
Solomon Peachy 2020-01-26 00:24:33 -05:00
parent d0d6ef32b4
commit d4b8ec0bc3
4 changed files with 27 additions and 61 deletions

View File

@ -351,4 +351,27 @@ extern struct dyesub_backend BACKEND;
quiet++; \ quiet++; \
break; break;
/* Dynamic library loading */
#if defined(USE_DLOPEN)
#define WITH_DYNAMIC
#include <dlfcn.h>
#define DL_INIT() do {} while(0)
#define DL_OPEN(__x) dlopen(__x, RTLD_NOW)
#define DL_SYM(__x, __y) dlsym(__x, __y)
#define DL_CLOSE(__x) dlclose(__x)
#define DL_EXIT() do {} while(0)
#elif defined(USE_LTDL)
#define WITH_DYNAMIC
#include <ltdl.h>
#define DL_INIT() lt_dlinit()
#define DL_OPEN(__x) lt_dlopen(__x)
#define DL_SYM(__x, __y) lt_dlsym(__x, __y)
#define DL_CLOSE(__x) do {} while(0)
#define DL_EXIT() lt_dlexit()
#else
#define DL_INIT() do {} while(0)
#define DL_CLOSE(__x) do {} while(0)
#define DL_EXIT() do {} while(0)
#endif
#endif /* __BACKEND_COMMON_H */ #endif /* __BACKEND_COMMON_H */

View File

@ -33,26 +33,7 @@
#include <config.h> #include <config.h>
#endif #endif
#if defined(USE_DLOPEN) #ifndef WITH_DYNAMIC
#define WITH_DYNAMIC
#include <dlfcn.h>
#define DL_INIT() do {} while(0)
#define DL_OPEN(__x) dlopen(__x, RTLD_NOW)
#define DL_SYM(__x, __y) dlsym(__x, __y)
#define DL_CLOSE(__x) dlclose(__x)
#define DL_EXIT() do {} while(0)
#elif defined(USE_LTDL)
#define WITH_DYNAMIC
#include <ltdl.h>
#define DL_INIT() lt_dlinit()
#define DL_OPEN(__x) lt_dlopen(__x)
#define DL_SYM(__x, __y) lt_dlsym(__x, __y)
#define DL_CLOSE(__x) do {} while(0)
#define DL_EXIT() lt_dlexit()
#else
#define DL_INIT() do {} while(0)
#define DL_CLOSE(__x) do {} while(0)
#define DL_EXIT() do {} while(0)
#warning "No dynamic loading support!" #warning "No dynamic loading support!"
#endif #endif

View File

@ -1,7 +1,7 @@
/* /*
* Mitsubishi CP-9xxx Photo Printer Family CUPS backend * Mitsubishi CP-9xxx Photo Printer Family CUPS backend
* *
* (c) 2014-2019 Solomon Peachy <pizza@shaftnet.org> * (c) 2014-2020 Solomon Peachy <pizza@shaftnet.org>
* *
* The latest version of this program can be found at: * The latest version of this program can be found at:
* *
@ -33,26 +33,7 @@
#include <config.h> #include <config.h>
#endif #endif
#if defined(USE_DLOPEN) #ifndef WITH_DYNAMIC
#define WITH_DYNAMIC
#include <dlfcn.h>
#define DL_INIT() do {} while(0)
#define DL_OPEN(__x) dlopen(__x, RTLD_NOW)
#define DL_SYM(__x, __y) dlsym(__x, __y)
#define DL_CLOSE(__x) dlclose(__x)
#define DL_EXIT() do {} while(0)
#elif defined(USE_LTDL)
#define WITH_DYNAMIC
#include <ltdl.h>
#define DL_INIT() lt_dlinit()
#define DL_OPEN(__x) lt_dlopen(__x)
#define DL_SYM(__x, __y) lt_dlsym(__x, __y)
#define DL_CLOSE(__x) do {} while(0)
#define DL_EXIT() lt_dlexit()
#else
#define DL_INIT() do {} while(0)
#define DL_CLOSE(__x) do {} while(0)
#define DL_EXIT() do {} while(0)
#warning "No dynamic loading support!" #warning "No dynamic loading support!"
#endif #endif

View File

@ -47,26 +47,7 @@
#include <config.h> #include <config.h>
#endif #endif
#if defined(USE_DLOPEN) #ifndef WITH_DYNAMIC
#define WITH_DYNAMIC
#include <dlfcn.h>
#define DL_INIT() do {} while(0)
#define DL_OPEN(__x) dlopen(__x, RTLD_NOW)
#define DL_SYM(__x, __y) dlsym(__x, __y)
#define DL_CLOSE(__x) dlclose(__x)
#define DL_EXIT() do {} while(0)
#elif defined(USE_LTDL)
#define WITH_DYNAMIC
#include <ltdl.h>
#define DL_INIT() lt_dlinit()
#define DL_OPEN(__x) lt_dlopen(__x)
#define DL_SYM(__x, __y) lt_dlsym(__x, __y)
#define DL_CLOSE(__x) do {} while(0)
#define DL_EXIT() lt_dlexit()
#else
#define DL_INIT() do {} while(0)
#define DL_CLOSE(__x) do {} while(0)
#define DL_EXIT() do {} while(0)
#warning "No dynamic loading support!" #warning "No dynamic loading support!"
#endif #endif