From 19ebfb18874ac83bd3df45a4151f55180df172da Mon Sep 17 00:00:00 2001 From: Holger Vogt Date: Wed, 18 Oct 2023 22:46:27 +0200 Subject: [PATCH] Add a code model function cm_exit(const int exitcode). This function calls controlled_exit(exitcode) to shut down gracefully. --- src/include/ngspice/cmproto.h | 2 ++ src/include/ngspice/dllitf.h | 1 + src/xspice/cm/cmexport.c | 3 ++- src/xspice/cm/cmutil.c | 9 +++++++-- src/xspice/icm/dlmain.c | 4 ++++ 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/include/ngspice/cmproto.h b/src/include/ngspice/cmproto.h index aa987d584..5f7fc4c11 100644 --- a/src/include/ngspice/cmproto.h +++ b/src/include/ngspice/cmproto.h @@ -125,4 +125,6 @@ FILE *fopen_with_path(const char *path, const char *mode); #define CM_IGNORE(x) (void) (x) +void cm_cexit(const int); + #endif /* include guard */ diff --git a/src/include/ngspice/dllitf.h b/src/include/ngspice/dllitf.h index b3a68c65d..1d9295d81 100644 --- a/src/include/ngspice/dllitf.h +++ b/src/include/ngspice/dllitf.h @@ -83,6 +83,7 @@ struct coreInfo_t { void * ((*dllitf_tmalloc)(size_t)); void * ((*dllitf_trealloc)(const void *, size_t)); void ((*dllitf_txfree)(const void *)); + void ((*dllitf_cexit)(const int)); #ifdef KLU int ((*dllitf_MIFbindCSC) (GENmodel *, CKTcircuit *)) ; diff --git a/src/xspice/cm/cmexport.c b/src/xspice/cm/cmexport.c index 2240eaf01..0e65a1f75 100644 --- a/src/xspice/cm/cmexport.c +++ b/src/xspice/cm/cmexport.c @@ -81,7 +81,8 @@ struct coreInfo_t coreInfo = txfree, tmalloc, trealloc, - txfree + txfree, + cm_cexit #else GC_malloc, tcalloc, diff --git a/src/xspice/cm/cmutil.c b/src/xspice/cm/cmutil.c index c1953192c..ee69a0f99 100644 --- a/src/xspice/cm/cmutil.c +++ b/src/xspice/cm/cmutil.c @@ -36,7 +36,7 @@ INTERFACES cm_complex_subtract() cm_complex_multiply() cm_complex_divide() - + cm_cexit() REFERENCED FILES @@ -51,6 +51,8 @@ NON-STANDARD FEATURES #include #include #include "ngspice/cm.h" + +extern void controlled_exit(const int); /* Corner Smoothing Function ************************************ * * @@ -525,4 +527,7 @@ Complex_t cm_complex_divide(Complex_t x, Complex_t y) return(c); } - +void cm_cexit(const int exitcode) +{ + controlled_exit(exitcode); +} diff --git a/src/xspice/icm/dlmain.c b/src/xspice/icm/dlmain.c index c64668991..87f6050f9 100644 --- a/src/xspice/icm/dlmain.c +++ b/src/xspice/icm/dlmain.c @@ -430,6 +430,10 @@ void txfree(const void *ptr) { (coreitf->dllitf_txfree)(ptr); } +void cm_cexit(const int exitcode) { + (coreitf->dllitf_cexit)(exitcode); +} + #ifdef KLU int MIFbindCSC (GENmodel *inModel, CKTcircuit *ckt) { return (coreitf->dllitf_MIFbindCSC) (inModel, ckt) ;