2000-04-27 22:03:57 +02:00
|
|
|
/**********
|
|
|
|
|
Copyright 1990 Regents of the University of California. All rights reserved.
|
|
|
|
|
Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
|
|
|
|
|
**********/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Print out in more detail what a floating point error was.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-12-11 19:05:00 +01:00
|
|
|
#include "ngspice/ngspice.h"
|
|
|
|
|
#include "ngspice/cpdefs.h"
|
|
|
|
|
#include "ngspice/ftedefs.h"
|
2000-04-27 22:03:57 +02:00
|
|
|
#include <signal.h>
|
|
|
|
|
|
|
|
|
|
|
2013-03-23 09:54:44 +01:00
|
|
|
#ifdef HAS_WINGUI
|
2012-09-20 20:30:53 +02:00
|
|
|
void winmessage(char *new_msg);
|
2021-07-05 23:15:22 +02:00
|
|
|
extern void UpdateMainText(void);
|
2013-03-23 17:58:11 +01:00
|
|
|
#elif defined SHARED_MODULE
|
2015-12-15 21:47:44 +01:00
|
|
|
extern ATTRIBUTE_NORETURN void shared_exit(int status);
|
2010-01-30 14:21:27 +01:00
|
|
|
#endif
|
|
|
|
|
|
2013-03-23 17:58:11 +01:00
|
|
|
/* global error message buffer */
|
|
|
|
|
char ErrorMessage[1024];
|
|
|
|
|
|
2012-01-02 13:52:56 +01:00
|
|
|
|
2015-12-13 21:11:03 +01:00
|
|
|
ATTRIBUTE_NORETURN void
|
2010-01-30 14:21:27 +01:00
|
|
|
controlled_exit(int status)
|
|
|
|
|
{
|
2013-03-23 09:54:44 +01:00
|
|
|
#ifdef HAS_WINGUI
|
2021-07-05 23:15:22 +02:00
|
|
|
if (status) {
|
|
|
|
|
UpdateMainText(); /* get any remaining error messages into main text window */
|
2012-01-02 13:52:56 +01:00
|
|
|
winmessage("Fatal error in NGSPICE");
|
2021-07-05 23:15:22 +02:00
|
|
|
}
|
2013-03-23 17:58:11 +01:00
|
|
|
exit(status);
|
|
|
|
|
#elif defined SHARED_MODULE
|
|
|
|
|
/* do not exit, if shared ngspice, but call back */
|
|
|
|
|
shared_exit(status);
|
2010-01-30 14:21:27 +01:00
|
|
|
#else
|
2012-01-02 13:52:56 +01:00
|
|
|
if (status)
|
|
|
|
|
fprintf(stderr, "\nERROR: fatal error in ngspice, exit(%d)\n", status);
|
|
|
|
|
exit(status);
|
2013-03-23 17:58:11 +01:00
|
|
|
#endif
|
2010-01-30 14:21:27 +01:00
|
|
|
}
|
|
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
fperror(char *mess, int code)
|
|
|
|
|
{
|
2010-11-16 21:38:24 +01:00
|
|
|
NG_IGNORE(code);
|
2000-04-27 22:03:57 +02:00
|
|
|
fprintf(cp_err, "%s: floating point exception.\n", mess);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Print a spice error message. */
|
|
|
|
|
void
|
|
|
|
|
ft_sperror(int code, char *mess)
|
|
|
|
|
{
|
2016-03-28 14:43:35 +02:00
|
|
|
char *errstring = if_errstring(code);
|
|
|
|
|
fprintf(cp_err, "%s: %s\n", mess, errstring);
|
|
|
|
|
tfree(errstring);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-01-02 13:52:56 +01:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
void
|
|
|
|
|
fatal(void)
|
|
|
|
|
{
|
2012-01-02 13:52:56 +01:00
|
|
|
#if defined(FTEDEBUG) && defined(SIGQUIT)
|
2000-04-27 22:03:57 +02:00
|
|
|
(void) signal(SIGQUIT, SIG_DFL);
|
|
|
|
|
(void) kill(getpid(), SIGQUIT);
|
|
|
|
|
#endif
|
2012-01-02 13:52:56 +01:00
|
|
|
|
2013-03-23 17:58:11 +01:00
|
|
|
#if defined SHARED_MODULE
|
|
|
|
|
/* do not exit, if shared ngspice, but call back */
|
|
|
|
|
shared_exit(EXIT_BAD);
|
|
|
|
|
#else
|
2000-04-27 22:03:57 +02:00
|
|
|
exit(EXIT_BAD);
|
2013-03-23 17:58:11 +01:00
|
|
|
#endif
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-01-02 13:52:56 +01:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* These error messages are from internal consistency checks. */
|
|
|
|
|
void
|
|
|
|
|
internalerror(char *message)
|
|
|
|
|
{
|
2011-08-10 18:39:46 +02:00
|
|
|
fprintf(stderr, "ERROR: (internal) %s\n", message);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|
|
|
|
|
|
2012-01-02 13:52:56 +01:00
|
|
|
|
2000-04-27 22:03:57 +02:00
|
|
|
/* These errors are from external routines like fopen. */
|
|
|
|
|
void
|
|
|
|
|
externalerror(char *message)
|
|
|
|
|
{
|
2011-08-10 18:39:46 +02:00
|
|
|
fprintf(stderr, "ERROR: (external) %s\n", message);
|
2000-04-27 22:03:57 +02:00
|
|
|
}
|