Only use VPI routine jump table in Windows.

This commit is contained in:
Martin Whitaker 2019-10-25 10:07:57 +01:00
parent f0326bc9c2
commit 3f1253039a
6 changed files with 25 additions and 0 deletions

View File

@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/ */
#if defined(__MINGW32__) || defined (__CYGWIN32__)
#include "vpi_user.h" #include "vpi_user.h"
vpip_routines_s*vpip_routines = 0; vpip_routines_s*vpip_routines = 0;
@ -25,3 +27,11 @@ DLLEXPORT void vpip_set_callback(vpip_routines_s*routines)
{ {
vpip_routines = routines; vpip_routines = routines;
} }
#else
void __libvpi_c_dummy_function(void)
{
}
#endif

View File

@ -184,6 +184,7 @@ vpiHandle vpi_register_systf(const struct t_vpi_systf_data*ss)
return 0; return 0;
} }
#if defined(__MINGW32__) || defined (__CYGWIN32__)
vpip_routines_s vpi_routines = { vpip_routines_s vpi_routines = {
.register_cb = vpi_register_cb, .register_cb = vpi_register_cb,
.remove_cb = vpi_remove_cb, .remove_cb = vpi_remove_cb,
@ -229,6 +230,7 @@ vpip_routines_s vpi_routines = {
}; };
typedef void (*vpip_set_callback_t)(vpip_routines_s*); typedef void (*vpip_set_callback_t)(vpip_routines_s*);
#endif
typedef void (*vlog_startup_routines_t)(void); typedef void (*vlog_startup_routines_t)(void);
bool load_vpi_module(const char*path) bool load_vpi_module(const char*path)
@ -240,6 +242,7 @@ bool load_vpi_module(const char*path)
return false; return false;
} }
#if defined(__MINGW32__) || defined (__CYGWIN32__)
void*function = ivl_dlsym(dll, "vpip_set_callback"); void*function = ivl_dlsym(dll, "vpip_set_callback");
if (function == 0) { if (function == 0) {
cerr << "warning: '" << path << "' has no vpip_set_callback()" << endl; cerr << "warning: '" << path << "' has no vpip_set_callback()" << endl;
@ -248,6 +251,7 @@ bool load_vpi_module(const char*path)
} }
vpip_set_callback_t set_callback = (vpip_set_callback_t)function; vpip_set_callback_t set_callback = (vpip_set_callback_t)function;
set_callback(&vpi_routines); set_callback(&vpi_routines);
#endif
void*table = ivl_dlsym(dll, LU "vlog_startup_routines" TU); void*table = ivl_dlsym(dll, LU "vlog_startup_routines" TU);
if (table == 0) { if (table == 0) {

View File

@ -675,6 +675,7 @@ extern void vpip_count_drivers(vpiHandle ref, unsigned idx,
# define _vpi_at_APV 6 # define _vpi_at_APV 6
#endif #endif
#if defined(__MINGW32__) || defined (__CYGWIN32__)
/* /*
* In Linux, when loaded, a shared library can automatically bind to functions * In Linux, when loaded, a shared library can automatically bind to functions
* provided by its client. In Windows, a DLL can only do this statically at * provided by its client. In Windows, a DLL can only do this statically at
@ -780,6 +781,8 @@ extern vpip_routines_s*vpip_routines;
#endif // IVL_VPI_MODULE #endif // IVL_VPI_MODULE
#endif // defined(__MINGW32__) || defined (__CYGWIN32__)
EXTERN_C_END EXTERN_C_END
#endif /* VPI_USER_H */ #endif /* VPI_USER_H */

View File

@ -30,7 +30,9 @@
static ivl_dll_t*dll_list = 0; static ivl_dll_t*dll_list = 0;
static unsigned dll_list_cnt = 0; static unsigned dll_list_cnt = 0;
#if defined(__MINGW32__) || defined (__CYGWIN32__)
typedef void (*vpip_set_callback_t)(vpip_routines_s*); typedef void (*vpip_set_callback_t)(vpip_routines_s*);
#endif
typedef void (*vlog_startup_routines_t)(void); typedef void (*vlog_startup_routines_t)(void);
# define VPIP_MODULE_PATH_MAX 64 # define VPIP_MODULE_PATH_MAX 64
@ -216,6 +218,7 @@ void vpip_load_module(const char*name)
return; return;
} }
#if defined(__MINGW32__) || defined (__CYGWIN32__)
void*function = ivl_dlsym(dll, "vpip_set_callback"); void*function = ivl_dlsym(dll, "vpip_set_callback");
if (function == 0) { if (function == 0) {
fprintf(stderr, "%s: no vpip_set_callback()\n", name); fprintf(stderr, "%s: no vpip_set_callback()\n", name);
@ -224,6 +227,7 @@ void vpip_load_module(const char*name)
} }
vpip_set_callback_t set_callback = (vpip_set_callback_t)function; vpip_set_callback_t set_callback = (vpip_set_callback_t)function;
set_callback(&vpi_routines); set_callback(&vpi_routines);
#endif
void*table = ivl_dlsym(dll, LU "vlog_startup_routines" TU); void*table = ivl_dlsym(dll, LU "vlog_startup_routines" TU);
if (table == 0) { if (table == 0) {

View File

@ -1635,6 +1635,7 @@ extern "C" void vpip_count_drivers(vpiHandle ref, unsigned idx,
rfp->node->count_drivers(idx, counts); rfp->node->count_drivers(idx, counts);
} }
#if defined(__MINGW32__) || defined (__CYGWIN32__)
vpip_routines_s vpi_routines = { vpip_routines_s vpi_routines = {
.register_cb = vpi_register_cb, .register_cb = vpi_register_cb,
.remove_cb = vpi_remove_cb, .remove_cb = vpi_remove_cb,
@ -1678,3 +1679,4 @@ vpip_routines_s vpi_routines = {
.mcd_rawwrite = vpip_mcd_rawwrite, .mcd_rawwrite = vpip_mcd_rawwrite,
.set_return_value = vpip_set_return_value, .set_return_value = vpip_set_return_value,
}; };
#endif

View File

@ -48,7 +48,9 @@ typedef struct __vpiArray* vvp_array_t;
* header file elsewhere. * header file elsewhere.
*/ */
#if defined(__MINGW32__) || defined (__CYGWIN32__)
extern vpip_routines_s vpi_routines; extern vpip_routines_s vpi_routines;
#endif
/* /*
* Routines/definitions used to build the file/line number tracing object. * Routines/definitions used to build the file/line number tracing object.