SCP, makefile: Rename build conditional HAVE_DLOPEN to SIM_HAVE_DLOPEN

Some dependent packages on some platforms may also define HAVE_DLOPEN
and that definition may have different syntax or semantics.  This change
avoids the potential symbol conflict.

As reported in #1098
This commit is contained in:
Mark Pizzolato 2021-12-04 17:44:57 -08:00
parent 3621db4e6a
commit c5cd38afbf
6 changed files with 23 additions and 23 deletions

View file

@ -577,21 +577,21 @@ ifeq (${WIN32},) #*nix Environments (&& cygwin)
endif
ifneq (,$(call find_include,dlfcn))
ifneq (,$(call find_lib,dl))
OS_CCDEFS += -DHAVE_DLOPEN=$(LIBSOEXT)
OS_CCDEFS += -DSIM_HAVE_DLOPEN=$(LIBSOEXT)
OS_LDFLAGS += -ldl
$(info using libdl: $(call find_lib,dl) $(call find_include,dlfcn))
else
ifneq (,$(findstring BSD,$(OSTYPE))$(findstring AIX,$(OSTYPE))$(findstring Haiku,$(OSTYPE)))
OS_CCDEFS += -DHAVE_DLOPEN=so
OS_CCDEFS += -DSIM_HAVE_DLOPEN=so
$(info using libdl: $(call find_include,dlfcn))
else
ifneq (,$(call find_lib,dld))
OS_CCDEFS += -DHAVE_DLOPEN=$(LIBSOEXT)
OS_CCDEFS += -DSIM_HAVE_DLOPEN=$(LIBSOEXT)
OS_LDFLAGS += -ldld
$(info using libdld: $(call find_lib,dld) $(call find_include,dlfcn))
else
ifeq (Darwin,$(OSTYPE))
OS_CCDEFS += -DHAVE_DLOPEN=dylib
OS_CCDEFS += -DSIM_HAVE_DLOPEN=dylib
$(info using macOS dlopen with .dylib)
endif
endif

18
scp.c
View file

@ -238,7 +238,7 @@
#endif
#include <setjmp.h>
#if defined(HAVE_DLOPEN) /* Dynamic Readline support */
#if defined(SIM_HAVE_DLOPEN) /* Dynamic Readline support */
#include <dlfcn.h>
#endif
@ -10091,7 +10091,7 @@ return read_line_p (NULL, cptr, size, stream);
char *read_line_p (const char *prompt, char *cptr, int32 size, FILE *stream)
{
char *tptr;
#if defined(HAVE_DLOPEN)
#if defined(SIM_HAVE_DLOPEN)
static int initialized = 0;
typedef char *(*readline_func)(const char *);
static readline_func p_readline = NULL;
@ -10104,15 +10104,15 @@ if (prompt && (!initialized)) {
#define S__STR_QUOTE(tok) #tok
#define S__STR(tok) S__STR_QUOTE(tok)
handle = dlopen("libncurses." S__STR(HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
handle = dlopen("libcurses." S__STR(HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
handle = dlopen("libreadline." S__STR(HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
handle = dlopen("libncurses." S__STR(SIM_HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
handle = dlopen("libcurses." S__STR(SIM_HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
handle = dlopen("libreadline." S__STR(SIM_HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
if (!handle)
handle = dlopen("libreadline." S__STR(HAVE_DLOPEN) ".7", RTLD_NOW|RTLD_GLOBAL);
handle = dlopen("libreadline." S__STR(SIM_HAVE_DLOPEN) ".7", RTLD_NOW|RTLD_GLOBAL);
if (!handle)
handle = dlopen("libreadline." S__STR(HAVE_DLOPEN) ".6", RTLD_NOW|RTLD_GLOBAL);
handle = dlopen("libreadline." S__STR(SIM_HAVE_DLOPEN) ".6", RTLD_NOW|RTLD_GLOBAL);
if (!handle)
handle = dlopen("libreadline." S__STR(HAVE_DLOPEN) ".5", RTLD_NOW|RTLD_GLOBAL);
handle = dlopen("libreadline." S__STR(SIM_HAVE_DLOPEN) ".5", RTLD_NOW|RTLD_GLOBAL);
if (handle) {
p_readline = (readline_func)((size_t)dlsym(handle, "readline"));
p_add_history = (add_history_func)((size_t)dlsym(handle, "add_history"));
@ -10165,7 +10165,7 @@ if ((*cptr == ';') || (*cptr == '#')) { /* ignore comment */
*cptr = 0;
}
#if defined (HAVE_DLOPEN)
#if defined (SIM_HAVE_DLOPEN)
if (prompt && p_add_history && *cptr) /* Save non blank lines in history */
p_add_history (cptr);
#endif

View file

@ -5222,7 +5222,7 @@ if (UuidCreate_c)
else
_rand_uuid_gen (uuidaddr);
}
#elif defined (HAVE_DLOPEN)
#elif defined (SIM_HAVE_DLOPEN)
#include <dlfcn.h>
static void
@ -5233,7 +5233,7 @@ void *handle;
#define S__STR_QUOTE(tok) #tok
#define S__STR(tok) S__STR_QUOTE(tok)
handle = dlopen("libuuid." S__STR(HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
handle = dlopen("libuuid." S__STR(SIM_HAVE_DLOPEN), RTLD_NOW|RTLD_GLOBAL);
if (handle)
uuid_generate_c = (void (*)(void *))((size_t)dlsym(handle, "uuid_generate"));
if (uuid_generate_c)

View file

@ -1225,11 +1225,11 @@ extern "C" {
#include <winreg.h>
#endif
#ifdef HAVE_DLOPEN
#ifdef SIM_HAVE_DLOPEN
#include <dlfcn.h>
#endif
#if defined(USE_SHARED) && (defined(_WIN32) || defined(HAVE_DLOPEN))
#if defined(USE_SHARED) && (defined(_WIN32) || defined(SIM_HAVE_DLOPEN))
/* Dynamic DLL loading technique and modified source comes from
Etherial/WireShark capture_pcap.c */
@ -1249,7 +1249,7 @@ static const char* lib_name =
#elif defined(__APPLE__)
"/usr/lib/libpcap.A.dylib";
#else
"libpcap." __STR(HAVE_DLOPEN);
"libpcap." __STR(SIM_HAVE_DLOPEN);
#endif
static char no_pcap[PCAP_ERRBUF_SIZE] =
@ -1258,7 +1258,7 @@ static char no_pcap[PCAP_ERRBUF_SIZE] =
#elif defined(__APPLE__)
"/usr/lib/libpcap.A.dylib failed to load, install libpcap to use pcap networking";
#else
"libpcap." __STR(HAVE_DLOPEN) " failed to load, install libpcap to use pcap networking";
"libpcap." __STR(SIM_HAVE_DLOPEN) " failed to load, install libpcap to use pcap networking";
#endif
#undef __STR
#undef __STR_QUOTE
@ -1529,7 +1529,7 @@ int pcap_setnonblock(pcap_t* a, int nonblock, char *errbuf) {
return 0;
}
}
#endif /* defined(USE_SHARED) && (defined(_WIN32) || defined(HAVE_DLOPEN)) */
#endif /* defined(USE_SHARED) && (defined(_WIN32) || defined(SIM_HAVE_DLOPEN)) */
/* Some platforms have always had pcap_sendpacket */
#if defined(_WIN32) || defined(__VMS)

View file

@ -124,8 +124,8 @@ extern "C" {
#if defined(USE_NETWORK) && defined(USE_SHARED)
#undef USE_SHARED
#endif
/* USE_SHARED only works on Windows or if HAVE_DLOPEN */
#if defined(USE_SHARED) && !defined(_WIN32) && !defined(HAVE_DLOPEN)
/* USE_SHARED only works on Windows or if SIM_HAVE_DLOPEN */
#if defined(USE_SHARED) && !defined(_WIN32) && !defined(SIM_HAVE_DLOPEN)
#undef USE_SHARED
#endif

View file

@ -55,7 +55,7 @@ extern "C" {
#include <ws2tcpip.h>
#endif
#ifdef HAVE_DLOPEN
#ifdef SIM_HAVE_DLOPEN
#include <dlfcn.h>
#endif