From 4dfac864ce924fe68635d1bb40271e8cf3d49b00 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Thu, 5 Mar 2026 12:01:03 +0000 Subject: [PATCH] Remove duplicated typeders and functions from t-dll.h and t-dll.c These duplicate the contents of ivl_dlfcn.h --- t-dll.cc | 76 +++----------------------------------------------------- t-dll.h | 14 +---------- 2 files changed, 5 insertions(+), 85 deletions(-) diff --git a/t-dll.cc b/t-dll.cc index 77836c737..6a99ec8d6 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -38,74 +38,6 @@ using namespace std; struct dll_target dll_target_obj; -#if defined(__WIN32__) - -inline ivl_dll_t ivl_dlopen(const char *name) -{ - ivl_dll_t res = static_cast(LoadLibrary(name)); - return res; -} - - -inline void * ivl_dlsym(ivl_dll_t dll, const char *nm) -{ - return reinterpret_cast(GetProcAddress((HMODULE)dll, nm)); -} - -inline void ivl_dlclose(ivl_dll_t dll) -{ - FreeLibrary((HMODULE)dll); -} - -const char *dlerror(void) -{ - static char msg[256]; - unsigned long err = GetLastError(); - FormatMessage( - FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, - err, - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language - (LPTSTR) &msg, - sizeof(msg) - 1, - NULL - ); - return msg; -} -#elif defined(HAVE_DLFCN_H) -inline ivl_dll_t ivl_dlopen(const char*name) -{ return dlopen(name,RTLD_LAZY); } - -inline void* ivl_dlsym(ivl_dll_t dll, const char*nm) -{ - void*sym = dlsym(dll, nm); - /* Not found? try without the leading _ */ - if (sym == 0 && nm[0] == '_') - sym = dlsym(dll, nm+1); - return sym; -} - -inline void ivl_dlclose(ivl_dll_t dll) -{ dlclose(dll); } - -#elif defined(HAVE_DL_H) -inline ivl_dll_t ivl_dlopen(const char*name) -{ return shl_load(name, BIND_IMMEDIATE, 0); } - -inline void* ivl_dlsym(ivl_dll_t dll, const char*nm) -{ - void*sym; - int rc = shl_findsym(&dll, nm, TYPE_PROCEDURE, &sym); - return (rc == 0) ? sym : 0; -} - -inline void ivl_dlclose(ivl_dll_t dll) -{ shl_unload(dll); } - -inline const char*dlerror(void) -{ return strerror( errno ); } -#endif - ivl_scope_s::ivl_scope_s() : func_type(IVL_VT_NO_TYPE) { @@ -667,13 +599,13 @@ bool dll_target::start_design(const Design*des) { const char*dll_path_ = des->get_flag("DLL"); - dll_ = ivl_dlopen(dll_path_); + dll_ = ivl_dlopen(dll_path_, false); if ((dll_ == 0) && (dll_path_[0] != '/')) { size_t len = strlen(basedir) + 1 + strlen(dll_path_) + 1; char*tmp = new char[len]; snprintf(tmp, len, "%s/%s", basedir, dll_path_); - dll_ = ivl_dlopen(tmp); + dll_ = ivl_dlopen(tmp, false); delete[]tmp; } @@ -2852,13 +2784,13 @@ bool dll_target::signal_paths(const NetNet*net) void dll_target::test_version(const char*target_name) { - dll_ = ivl_dlopen(target_name); + dll_ = ivl_dlopen(target_name, false); if ((dll_ == 0) && (target_name[0] != '/')) { size_t len = strlen(basedir) + 1 + strlen(target_name) + 1; char*tmp = new char[len]; snprintf(tmp, len, "%s/%s", basedir, target_name); - dll_ = ivl_dlopen(tmp); + dll_ = ivl_dlopen(tmp, false); delete[]tmp; } diff --git a/t-dll.h b/t-dll.h index 2953a4877..4dc074247 100644 --- a/t-dll.h +++ b/t-dll.h @@ -22,24 +22,12 @@ # include "target.h" # include "ivl_target.h" # include "ivl_target_priv.h" +# include "ivl_dlfcn.h" # include "StringHeap.h" # include "netlist.h" # include # include -#if defined(__MINGW32__) -#include -typedef void *ivl_dll_t; -#elif defined(HAVE_DLFCN_H) -# include -typedef void* ivl_dll_t; -#elif defined(HAVE_DL_H) -# include -typedef shl_t ivl_dll_t; -#else -# error No DLL stub support for this target. -#endif - /* * The DLL target type loads a named object file to handle the process * of scanning the netlist. When it is time to start the design, I