Minor code tidy-up.

This commit is contained in:
Martin Whitaker 2019-10-22 21:48:43 +01:00
parent f5cb5b2d90
commit 79d3a21b65
2 changed files with 10 additions and 17 deletions

View File

@ -240,19 +240,16 @@ bool load_vpi_module(const char*path)
return false;
}
vpip_set_callback_t set_callback = (vpip_set_callback_t)ivl_dlsym(dll, "vpip_set_callback");
if (set_callback == 0) {
void*function = ivl_dlsym(dll, "vpip_set_callback");
if (function == 0) {
cerr << "warning: '" << path << "' has no vpip_set_callback()" << endl;
ivl_dlclose(dll);
return true;
}
vpip_set_callback_t set_callback = (vpip_set_callback_t)function;
set_callback(&vpi_routines);
#ifdef __MINGW32__
void*table = ivl_dlsym(dll, "vlog_startup_routines");
#else
void*table = ivl_dlsym(dll, LU "vlog_startup_routines" TU);
#endif
if (table == 0) {
cerr << "warning: '" << path << "' has no vlog_startup_routines" << endl;
ivl_dlclose(dll);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2018 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2019 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -216,20 +216,16 @@ void vpip_load_module(const char*name)
return;
}
vpip_set_callback_t set_callback = (vpip_set_callback_t)ivl_dlsym(dll, "vpip_set_callback");
if (set_callback == 0) {
fprintf(stderr, "%s: no vpip_set_callback\n", name);
ivl_dlclose(dll);
return;
void*function = ivl_dlsym(dll, "vpip_set_callback");
if (function == 0) {
fprintf(stderr, "%s: no vpip_set_callback()\n", name);
ivl_dlclose(dll);
return;
}
vpip_set_callback_t set_callback = (vpip_set_callback_t)function;
set_callback(&vpi_routines);
#ifdef __MINGW32__
/* For this check MinGW does not want the leading underscore! */
void*table = ivl_dlsym(dll, "vlog_startup_routines");
#else
void*table = ivl_dlsym(dll, LU "vlog_startup_routines" TU);
#endif
if (table == 0) {
fprintf(stderr, "%s: no vlog_startup_routines\n", name);
ivl_dlclose(dll);