Jspice3
error.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3e2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1985 Wayne A. Christopher
5  1992 Stephen R. Whiteley
6 ****************************************************************************/
7 
8 /*
9  *
10  * Print out in more detail what a floating point error was.
11  */
12 
13 #include "spice.h"
14 #include "ftedefs.h"
15 #ifdef HAVE_SIGNAL
16 #include <signal.h>
17 #endif
18 
19 /* global error message buffer */
20 char ErrorMessage[1024];
21 
22 #ifdef HAVE_VAX_FPERRORS
23 
24 static char *fperrs[] = {
25  "FPE 0",
26  "Integer overflow",
27  "Integer divide by zero",
28  "Floating overflow",
29  "Floating / decimal divide by zero",
30  "Floating underflow",
31  "Decimal overflow",
32  "Subscript out of range",
33  "Floating overflow fault",
34  "Divide by zero floating fault",
35  "Floating underflow fault"
36  } ;
37 
38 static int nfperrs = 11;
39 
40 void
41 fperror(mess, code)
42  char *mess;
43 {
44  if ((code < 0) || (code >= nfperrs))
45  fprintf(cp_err, "%s: Unknown floating point error (# %d).\n",
46  mess, code);
47  else
48  fprintf(cp_err, "%s: %s.\n", mess, fperrs[code]);
49  return;
50 }
51 
52 #else
53 
54 /*ARGSUSED*/
55 void
56 fperror(mess, code)
57  char *mess;
58 {
59  fprintf(cp_err, "%s: floating point exception.\n", mess);
60  return;
61 }
62 
63 #endif
64 
65 /* Print a spice error message. */
66 
67 void
68 ft_sperror(code, mess)
69  char *mess;
70 {
71  fprintf(cp_err, "%s: %s\n", mess, if_errstring(code));
72  return;
73 }
74 
75 void
77 {
78  cp_ccon(false);
79 #ifdef HAVE_SIGNAL
80 #ifdef FTEDEBUG
81 #ifdef SIGQUIT
82  (void) signal(SIGQUIT, SIG_DFL);
83  (void) kill(getpid(), SIGQUIT);
84 #endif
85 #endif
86 #endif
87  exit(EXIT_BAD);
88 }
89 
90 /* These error messages are from internal consistency checks. */
92 char *message;
93 {
94 
95  fprintf(stderr, "internal error: %s\n", message);
96 
97 }
98 
99 /* These errors are from external routines like fopen. */
101 char *message;
102 {
103 
104  fprintf(stderr, "external error: %s\n", message);
105 
106 }
char * if_errstring(code)
Definition: main.c:237
char ErrorMessage[1024]
Definition: error.c:20
internalerror(char *message)
Definition: error.c:91
void ft_sperror(code, char *mess)
Definition: error.c:68
FILE * cp_err
Definition: help.c:101
void fatal()
Definition: error.c:76
void fperror(char *mess, code)
Definition: error.c:56
int getpid()
Definition: libfuncs.c:137
static void message(char *instr, char *outstr)
Definition: hcopy.c:13
#define EXIT_BAD
Definition: misc.h:26
externalerror(char *message)
Definition: error.c:100
void cp_ccon()