From b85f6bbc7d25183b06fd5f43362019f2d8b82b34 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Tue, 31 Jul 2012 17:54:51 +0200 Subject: [PATCH] controlled_exit() instead of exit() --- src/frontend/trannoise/1-f-code.c | 4 +++- src/misc/alloc.c | 6 ++++-- src/spicelib/analysis/cktsens.c | 3 ++- src/spicelib/devices/txl/txlacct.c | 3 ++- src/spicelib/devices/txl/txlsetup.c | 3 ++- src/spicelib/parser/inpgmod.c | 2 +- src/spicelib/parser/inpptree.c | 6 ++++-- src/xspice/mif/mif_inp2.c | 4 ++-- 8 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/frontend/trannoise/1-f-code.c b/src/frontend/trannoise/1-f-code.c index d6544088c..0d827b059 100644 --- a/src/frontend/trannoise/1-f-code.c +++ b/src/frontend/trannoise/1-f-code.c @@ -20,6 +20,8 @@ #include "ngspice/fftext.h" #include "ngspice/wallace.h" +extern void controlled_exit(int status); + void f_alpha(int n_pts, int n_exp, double X[], double Q_d, double alpha) @@ -134,7 +136,7 @@ trnoise_state_gen(struct trnoise_state *this, CKTcircuit *ckt) if(this->top + 1 >= this->oneof_length) { fprintf(stderr,"ouch, noise data exhausted\n"); - exit(1); + controlled_exit(1); } ra1 += this->oneof[this->top] - this->oneof[0]; diff --git a/src/misc/alloc.c b/src/misc/alloc.c index 971d5554b..449011645 100644 --- a/src/misc/alloc.c +++ b/src/misc/alloc.c @@ -9,6 +9,8 @@ Copyright 1990 Regents of the University of California. All rights reserved. #ifndef HAVE_LIBGC +extern void controlled_exit(int status); + /*saj For Tcl module locking*/ #ifdef TCL_MODULE #include @@ -42,7 +44,7 @@ tmalloc(size_t num) #endif if (!s){ fprintf(stderr,"malloc: Internal Error: can't allocate %ld bytes. \n",(long)num); - exit(EXIT_FAILURE); + controlled_exit(EXIT_FAILURE); } return(s); } @@ -78,7 +80,7 @@ trealloc(void *ptr, size_t num) } if (!s) { fprintf(stderr,"realloc: Internal Error: can't allocate %ld bytes.\n", (long)num); - exit(EXIT_FAILURE); + controlled_exit(EXIT_FAILURE); } return(s); } diff --git a/src/spicelib/analysis/cktsens.c b/src/spicelib/analysis/cktsens.c index 22417dd2e..74760dbbf 100644 --- a/src/spicelib/analysis/cktsens.c +++ b/src/spicelib/analysis/cktsens.c @@ -4,6 +4,7 @@ Modified: 2000 AlanFixes **********/ #include "ngspice/ngspice.h" +#include "ngspice/fteext.h" #include "ngspice/ifsim.h" #include "ngspice/sperror.h" #include "ngspice/spmatrix.h" @@ -222,7 +223,7 @@ int sens_sens(CKTcircuit *ckt, int restart) output_values = NULL; output_cvalues = NULL; fprintf(stderr, "ERROR: restore is not implemented for cktsens\n"); - exit(1); + controlled_exit(1); } #ifdef ASDEBUG diff --git a/src/spicelib/devices/txl/txlacct.c b/src/spicelib/devices/txl/txlacct.c index 197dbc3da..0e4367f73 100644 --- a/src/spicelib/devices/txl/txlacct.c +++ b/src/spicelib/devices/txl/txlacct.c @@ -6,6 +6,7 @@ Author: 1992 Charles Hough #include "ngspice/ngspice.h" +#include "ngspice/fteext.h" #include "ngspice/cktdefs.h" #include "txldefs.h" #include "ngspice/sperror.h" @@ -53,7 +54,7 @@ TXLaccept(CKTcircuit *ckt, GENmodel *inModel) else { /* can't happen. */ printf("zero h detected\n"); - exit(1); + controlled_exit(1); } } } diff --git a/src/spicelib/devices/txl/txlsetup.c b/src/spicelib/devices/txl/txlsetup.c index 22bf204f7..9a176a7b4 100644 --- a/src/spicelib/devices/txl/txlsetup.c +++ b/src/spicelib/devices/txl/txlsetup.c @@ -6,6 +6,7 @@ Author: 1992 Charles Hough #include "ngspice/ngspice.h" +#include "ngspice/fteext.h" #include "ngspice/smpdefs.h" #include "txldefs.h" #include "ngspice/sperror.h" @@ -1157,7 +1158,7 @@ find_roots(double a1, double a2, double a3, double *x1, double *x2, double *x3) t = a1 * a1 - 4.0 * a2; if (t < 0) { printf("***** Two Imaginary Roots in Characteristic Admittance.\n"); - exit(EXIT_FAILURE); + controlled_exit(EXIT_FAILURE); } t *= 1.0e-18; diff --git a/src/spicelib/parser/inpgmod.c b/src/spicelib/parser/inpgmod.c index e850dafec..fbe5fb290 100644 --- a/src/spicelib/parser/inpgmod.c +++ b/src/spicelib/parser/inpgmod.c @@ -118,7 +118,7 @@ create_model( CKTcircuit* ckt, INPmodel* modtmp, INPtables* tab ) /* Check for various possible errors */ if ((errno == ERANGE && dval == HUGE_VAL) || errno != 0) { perror("strtod"); - exit(EXIT_FAILURE); + controlled_exit(EXIT_FAILURE); } if (endptr == parm) { /* it was no number - it is really a string */ temp = TMALLOC(char, 40 + strlen(parm)); diff --git a/src/spicelib/parser/inpptree.c b/src/spicelib/parser/inpptree.c index 944b514cd..cff52a398 100644 --- a/src/spicelib/parser/inpptree.c +++ b/src/spicelib/parser/inpptree.c @@ -11,6 +11,8 @@ Author: 1987 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ngspice/inpptree.h" #include "inp.h" +extern void controlled_exit(int status); + static INPparseNode *mkcon(double value); static INPparseNode *mkb(int type, INPparseNode * left, INPparseNode * right); @@ -857,7 +859,7 @@ static INPparseNode *prepare_PTF_PWL(INPparseNode *p) if (p->funcnum != PTF_PWL) { fprintf(stderr, "PWL-INFO: %s, very unexpected\n", __func__); - exit(1); + controlled_exit(1); } #ifdef TRACE @@ -1343,7 +1345,7 @@ void free_tree(INPparseNode *pt) if(pt->usecnt) { fprintf(stderr, "ERROR: fatal internal error, %s\n", __func__); - exit(1); + controlled_exit(1); } switch (pt->type) { diff --git a/src/xspice/mif/mif_inp2.c b/src/xspice/mif/mif_inp2.c index 485cf472f..c95e254b6 100644 --- a/src/xspice/mif/mif_inp2.c +++ b/src/xspice/mif/mif_inp2.c @@ -40,7 +40,7 @@ NON-STANDARD FEATURES /* #include "prefix.h" */ /* jgroves */ #include "ngspice/ngspice.h" #include -//#include "util.h" +#include "ngspice/fteext.h" #include "ngspice/ifsim.h" #include "ngspice/inpdefs.h" #include "ngspice/devdefs.h" @@ -587,7 +587,7 @@ static void MIFinit_inst( break; default: printf("\nERROR - Impossible direction type in MIFinit_inst\n"); - exit(1); + controlled_exit(1); } }