mirror of
https://git.code.sf.net/p/ngspice/ngspice
synced 2026-08-22 13:57:32 +02:00
put -lltdl library support back to dev.c (offer better support on mingw that -ldl)
This commit is contained in:
+15
-17
@@ -168,15 +168,9 @@ int DEVflag(int type){
|
|||||||
#if ADMS >= 3
|
#if ADMS >= 3
|
||||||
#include "ngspice/fteext.h" /* for ft_sim */
|
#include "ngspice/fteext.h" /* for ft_sim */
|
||||||
#include "ngspice/cktdefs.h" /* for DEVmaxnum */
|
#include "ngspice/cktdefs.h" /* for DEVmaxnum */
|
||||||
#include <dlfcn.h>
|
#include <ltdl.h>
|
||||||
static void varelink(CKTcircuit *ckt) {
|
static void varelink(CKTcircuit *ckt)
|
||||||
|
{
|
||||||
/*
|
|
||||||
* This replacement done by SDB on 6.11.2003
|
|
||||||
*
|
|
||||||
* ft_sim->numDevices = num_devices();
|
|
||||||
* DEVmaxnum = num_devices();
|
|
||||||
*/
|
|
||||||
ft_sim->numDevices = DEVNUM;
|
ft_sim->numDevices = DEVNUM;
|
||||||
DEVmaxnum = DEVNUM;
|
DEVmaxnum = DEVNUM;
|
||||||
|
|
||||||
@@ -189,27 +183,32 @@ static void varelink(CKTcircuit *ckt) {
|
|||||||
}
|
}
|
||||||
int load_vadev(CKTcircuit *ckt, char *name)
|
int load_vadev(CKTcircuit *ckt, char *name)
|
||||||
{
|
{
|
||||||
char *msg, libname[50];
|
char libname[50];
|
||||||
void *lib;
|
void *lib;
|
||||||
SPICEadmsdev *device;
|
SPICEadmsdev *device;
|
||||||
void* fetch; /* fixme funptr_t */
|
void* fetch; /* fixme funptr_t */
|
||||||
|
|
||||||
|
int l = (int)(strlen("lib") + strlen(name) + strlen(".so"));
|
||||||
|
|
||||||
strcpy(libname, "lib");
|
strcpy(libname, "lib");
|
||||||
strcat(libname,name);
|
strcat(libname,name);
|
||||||
strcat(libname,".so");
|
strcat(libname,".so");
|
||||||
|
libname[l+1] = '\0';
|
||||||
|
|
||||||
lib = dlopen(libname, RTLD_NOW);
|
lt_dlinit();
|
||||||
|
lt_dlsetsearchpath(".");
|
||||||
|
|
||||||
|
lib = lt_dlopen(libname);
|
||||||
|
|
||||||
if(!lib){
|
if(!lib){
|
||||||
msg = dlerror();
|
perror(lt_dlerror());
|
||||||
printf("%s\n", msg);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
strcpy(libname, "get_");
|
strcpy(libname, "get_");
|
||||||
strcat(libname,name);
|
strcat(libname,name);
|
||||||
strcat(libname,"_info");
|
strcat(libname,"_info");
|
||||||
fetch = dlsym(lib,libname);
|
fetch = lt_dlsym(lib, libname);
|
||||||
|
|
||||||
if(fetch)
|
if(fetch)
|
||||||
device = ((SPICEadmsdev * (*)(void)) fetch) ();
|
device = ((SPICEadmsdev * (*)(void)) fetch) ();
|
||||||
@@ -217,16 +216,15 @@ int load_vadev(CKTcircuit *ckt, char *name)
|
|||||||
device = NULL;
|
device = NULL;
|
||||||
|
|
||||||
if(!device) {
|
if(!device) {
|
||||||
msg = dlerror();
|
perror(lt_dlerror());
|
||||||
printf("%s\n", msg);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
device->mkn = CKTmkVolt;
|
device->mkn = CKTmkVolt;
|
||||||
device->mkj = SMPmakeElt;
|
device->mkj = SMPmakeElt;
|
||||||
|
|
||||||
DEVices = TREALLOC(SPICEdev *, DEVices, DEVNUM + 1);
|
|
||||||
printf("Added device: %s from dynamic library %s\n", device->spicedev.DEVpublic.name, libname);
|
printf("Added device: %s from dynamic library %s\n", device->spicedev.DEVpublic.name, libname);
|
||||||
|
DEVices = TREALLOC(SPICEdev *, DEVices, DEVNUM + 1);
|
||||||
DEVices[DEVNUM++] = & (device->spicedev);
|
DEVices[DEVNUM++] = & (device->spicedev);
|
||||||
varelink(ckt);
|
varelink(ckt);
|
||||||
return DEVNUM-1;
|
return DEVNUM-1;
|
||||||
|
|||||||
Reference in New Issue
Block a user